Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366519

Summary: Unexpected "shared" option appears when restoring defaults
Product: [Tools] CDT Reporter: David Pochet <dpochet>
Component: cdt-coreAssignee: Project Inbox <cdt-core-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: normal    
Priority: P3 CC: ddk, eostroukhov, mohamed_azab, yevshif
Version: 8.0.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/106038
https://git.eclipse.org/r/114455
Whiteboard:

Description David Pochet CLA 2011-12-13 07:37:06 EST
Very simple to reproduce.
Create a new hello world sample executable project, built it: all is ok
Go to property page > C/C++ Build > Settings
Click "Restore Defaults"

--> "Shared" option will now be enabled in the GCC C Linker > Shared Library Settings category!
And obviously, project doesn't link anymore.
Comment 1 Eugene Ostroukhov CLA 2011-12-16 17:06:03 EST
*** Bug 347498 has been marked as a duplicate of this bug. ***
Comment 2 Eugene Ostroukhov CLA 2011-12-16 17:46:54 EST
This problem is caused by ArtifactTab::performDefaults setting artifact type to shared library (in a call to setProjectType(wrong)) which changes variable values. Subsequent call to "setProjectType(right)" restores proper project type but does not recompute the option values.
Comment 3 Eugene Ostroukhov CLA 2011-12-16 18:00:32 EST
Apparently, the problem is that only options from "extension elements" get recomputed (see HoldsOptions::adjustOptions). What happens is:

1. Set artifact type to shared (setProjectType(wrong)) will set Linker::shared option to "true" and will redeclare this option in the non-extension Linker "subclass".
2. Set artifact type to exe (setProjectType(right)) will not change the option default value.

I see same problem in our toolchain with custom build property and custom option.
Comment 4 Mohamed Azab CLA 2014-05-29 07:05:17 EDT
So (In reply to Eugene Ostroukhov from comment #3)
> Apparently, the problem is that only options from "extension elements" get
> recomputed (see HoldsOptions::adjustOptions). What happens is:
> 
> 1. Set artifact type to shared (setProjectType(wrong)) will set
> Linker::shared option to "true" and will redeclare this option in the
> non-extension Linker "subclass".
> 2. Set artifact type to exe (setProjectType(right)) will not change the
> option default value.
> 
> I see same problem in our toolchain with custom build property and custom
> option.

This patch: < https://git.eclipse.org/r/#/c/27520/ > makes the updates for all options. Is there a specific problem with this?
Comment 5 Eclipse Genie CLA 2017-09-29 16:13:43 EDT
New Gerrit change created: https://git.eclipse.org/r/106038
Comment 6 Eclipse Genie CLA 2017-12-20 03:30:26 EST
New Gerrit change created: https://git.eclipse.org/r/114455