| Summary: | GnuMakefileGenerator does not properly handle tools which have more than one primary input type | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Chris Recoskie <recoskie> | ||||
| Component: | cdt-build-managed | Assignee: | Chris Recoskie <recoskie> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Chris Recoskie <recoskie> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | cdt-build-managed-inbox, vivkong | ||||
| Version: | 7.0 | ||||||
| Target Milestone: | 7.0.1 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Applied to cdt_7_0 and HEAD. *** cdt cvs genie on behalf of crecoskie *** Bug 324816 - GnuMakefileGenerator does not properly handle tools which have more than one primary input type [*] GnuMakefileGenerator.java 1.92.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java?root=Tools_Project&r1=1.92&r2=1.92.2.1 [*] GnuMakefileGenerator.java 1.97 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuMakefileGenerator.java?root=Tools_Project&r1=1.96&r2=1.97 |
Created attachment 178475 [details] proposed patch If a tool has more than one input type which has it's primaryInput attribute set to true (e.g., you have a C++ compiler that compiles both C and C++ files, which is how the xlC toolchain is setup), then GnuMakefileGenerator generates an incorrect subdir.mk In GnuMakefileGenerator.getAdditionalResourcesForSource(ITool), the code looks for "additional inputs" to the tool, and adds these as command line parameters to the pattern rule for the given input type. The problem is the way that it determines whether a given input type is a primary or secondary input. The way it does this is by calling ITool.getPrimaryInput() and comparing that to the input type. This doesn't account for the fact that a tool may have more than one primary input type, so any resources in the project that are of an input type marked as primary, but not returned by ITool.getPrimaryInput(), will be assumed to be secondary inputs. So, if for example the C input type happens to be what is returned from ITool.getPrimaryInput(), then all C++ files will be considered secondary inputs, and this means they will be added as command line parameters to the pattern rule for the tool. E.g., if you have a.cpp, b.cpp, c.cpp, then the rule looks something like: %.o : %.cpp your_cpp_compiler "$>" -o"$@" a.cpp b.cpp c.cpp Obviously this is bad, because you end up recompiling every file in the project in one command line. Not all tools are able to handle that. Furthermore, each operating system generally has a fixed limit on the length (and possibly, number) of command line parameters that can be used in a command. For a large project, it is easy to imagine exceeding that limit. Furthermore, compiling all files in one step ruins the ability to parallelize the build, e.g. with make's -j option. The solution I propose is fairly simple. Instead of just querying the tool for its primary input type and comparing to it, also ask the input type whether it is a primary input. This way all input types that are set to be primary inputs will be treated as such, and the makefile is generated correctly. Unfortunately it seems a lot of input types do not specify that they are primary inputs, as if there is only one input then it's assumed to be the primary input. This means that we can't rely only upon whether an input type is primary or not. We also need to ask the tool for its primary input and compare to that as well. The one-line patch is attached.