Community
Participate
Working Groups
If a new option is added to a tool in a toolchain. Opening the .cproject in an older Eclipse leads to corruption / breaking of the .cproject. For example: In 7.0 a -include option was added to the Compiler Tool. This results in an option entry like: <option id="gnu.c.compiler.option.include.files.19755955" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files"/> If you open a .cproject in a previous CDT with this option, and change the build settings, this option gets changed to: <option id="gnu.c.compiler.option.include.files.19755955" name="Include files (-include)"/> Note its dropped the superClass attribute. There are two problems with the .cproject now: - No other options work: -Ds, -Is, etc. are all ignored by MBS and not passed to the compiler tool - There are no errors / warnings, so there's no way for the user to resolve. A few things should be fixed: - If we don't know about an option type, we should ignore it, and preserve the element if we can - We should warn the user when we don't know about a particular option type, but still continue to process other options - We shouldn't emit option entries when they're identical to the default value (in this case the empty list).
Option#getValueType can throw a buildException. This is thrown all the way out to GnuMakefileGenerator: Option.getValueType() line: 1469 Tool.getToolCommandFlags(IPath, IPath, SupplierBasedCdtVariableSubstitutor, IMacroContextInfoProvider) line: 2545 Tool.getToolCommandFlags(IPath, IPath) line: 2682 GnuMakefileGenerator.addRuleForSource(String, StringBuffer, IResource, IPath, IResourceInfo, boolean, Vector<IPath>, Vector<IPath>) line: 2637 GnuMakefileGenerator.addFragmentMakefileEntriesForSource(LinkedHashMap<String,String>, StringBuffer, IFolder, String, IResource, IPath, IResourceInfo, String, boolean) line: 2080 This is then silently eaten by the GnuMakefileGenerator: // Get the tool command line options try { flags = tool.getToolCommandFlags(sourceLocation, outputLocation); } catch( BuildException ex ) { // TODO add some routines to catch this flags = EMPTY_STRING_ARRAY; } This is pretty bad. #getToolCommandFlags iterates over all the tool options. So one bad option breaks all the others...
Chris, Andrew: AFAICS #getToolCommandFlags(IPath, IPath, ...) should never throw BuildException as *all* 21 indirect callers (as viewed by show call hierarchy) _silently_ eat this exception. So for fixing point 2, I'd say that getToolCaommandFlags shouldn't throw a build exception but rather should log the exception and carry on processing other options.
Created attachment 170632 [details] patch 1 The attached patch fixes issues 1 & 2. The warning emitted to the error log, looks like: Problem discovering arguments for Tool option: Include files (-include) (gnu.c.compiler.option.include.files.953373612) <backtrace> The patch is straightforward; I'll target 7.0.1. Detailed changes: - ManagedBuildCorePlugin: Incorrectly logs CoreExceptions (see CoreException#getStatus() - Option.java: attempt to preserve superClassId even if superClass == null - Tool.java#getToolCommandFlags(... SupplierBasedCdtVariableSubstitutor ...) + no longer throws BuildException. + Logs exceptions (like above is something goes wrong) The 3rd issue mentioned in comment 0: it seems that options are only emitted in the .cproject if they're ever changed. Unfortunately, resetting them to defaultValue doesn't remove them. This is a less severe issue, so not tackling this.
Why not fix it 7.0? it seems safe. People often switch between versions...
(In reply to comment #4) > Why not fix it 7.0? it seems safe. People often switch between versions... Ok. I just needed review. This is pretty serious for us, so I've put the fix into our product, will commit to CDT.
Fixed in 7.0
*** cdt cvs genie on behalf of jblackburn *** Bug 315187 Unknown tool option silently breaks ManagedBuild tool command line generation [*] PluginResources.properties 1.58 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties?root=Tools_Project&r1=1.57&r2=1.58 [*] Option.java 1.47 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java?root=Tools_Project&r1=1.46&r2=1.47 [*] Tool.java 1.98 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java?root=Tools_Project&r1=1.97&r2=1.98 [*] BuildMacroProvider.java 1.10 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/BuildMacroProvider.java?root=Tools_Project&r1=1.9&r2=1.10 [*] ManagedBuilderCorePlugin.java 1.28 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java?root=Tools_Project&r1=1.27&r2=1.28 [*] ToolSettingsPrefStore.java 1.7 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/ToolSettingsPrefStore.java?root=Tools_Project&r1=1.6&r2=1.7