-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add all flags to scanner discovery #158
Add all flags to scanner discovery #158
Conversation
e00ad5c
to
92abfbf
Compare
@jld01 @T-Svensson I would appreciate your thoughts on this while I work to make sure it doesn't regress anything - I wrote the N&N entries too: |
0bcc12c
to
9c7a8d7
Compare
NewAndNoteworthy/CDT-11.0.md
Outdated
## Scanner Discovery considering all flags | ||
|
||
The default for the scanner has changed to include _all_ command line options when querying the compiler for built-in includes and defines. | ||
This is because many more compiler options affect the includes and defines than those that were traditionally included when running the scanner, such as `-ansi`, `-fPIC`, `-fstack-protector-all`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because a lot more..
NewAndNoteworthy/CDT-11.0.md
Outdated
The default for the scanner has changed to include _all_ command line options when querying the compiler for built-in includes and defines. | ||
This is because many more compiler options affect the includes and defines than those that were traditionally included when running the scanner, such as `-ansi`, `-fPIC`, `-fstack-protector-all`. | ||
|
||
To address this a new variable called `${ALL_FLAGS}` is included by default when performing scanner discovery. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To address this, a new variable called ${ALL_FLAGS}
is included by default when performing scanner discovery.
@@ -46,14 +43,6 @@ public ManagedBuildCoreTests(String name) { | |||
super(name); | |||
} | |||
|
|||
public static Test suite() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this block should be removed in it's own commit?
<attribute name="excludeFromScannerDiscovery" type="boolean"> | ||
<annotation> | ||
<documentation> | ||
An optional field to allow the option to be excluded from scanner discovery's ${ALL_FLAGS} variable. The default is false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to change this from "The default is false." to "The default is to include option in scanner discovery." or something like that?
False can be interpreted as either that it's excluded and included...
@@ -578,6 +588,14 @@ protected void loadFromProject(ICStorageElement element) { | |||
} | |||
} | |||
|
|||
// isNotForScannerDiscovery | |||
if (element.getAttribute(EXCLUDE_FROM_SCANNER_DISCOVERY) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you fetching the same attribute 2 times and checking for null 2 times?
* except for those specifically excluded from scanner discovery | ||
* with {@link IOption#isExcludedFromScannerDiscovery()} | ||
* | ||
* @param languageId - language ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should drop the "-" here.
@@ -101,7 +101,8 @@ AbstractPage_6=Configuration:\u0020 | |||
AbstractPage_7=Exclude resource from build | |||
AbstractPage_8=Cannot apply | |||
AbstractPage_9=Internal error | |||
AbstractPage_rebuildIndex_question=Changes made will not be reflected in the index until it is rebuilt. Do you wish to rebuild it now? | |||
AbstractPage_Rebuild_Index=Rebuild Index | |||
AbstractPage_rebuildIndex_question=Some build settings changes may affect the index. These changes won't take effect until the index until it is rebuilt. Do you wish to rebuild it now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes to build settings may affect the index. These changes won't take effect until the index is rebuilt. Do you wish to rebuild it now?
Thanks @Torbjorn-Svensson for the review. I agree with all your changes. At the high level, is this change a good idea, or cause you any concern? I am pretty confident about most of it, the only thing that concerns me is if I should change the default for new projects to include |
My first reaction was "why is this needed...", but after reading the entire PR and the changes in it, I suppose it makes senses. |
This change adds the ALL_FLAGS that does not limit tool options to those declared as IOption::isForScannerDiscovery when launching the compiler to discover compiler built-ins. This is needed as many other flags, either entered manually in "Other flags" or some of the existing flags with checkboxes such as "-ansi", "-fPIC", and "-fstack-protector-all" which all affect scanner discovery as they can all change what macros are built-in to the compiler. The current solution has as a drawback that some settings, like -I and -D then appear twice. For example in the "Includes" node in the "Project Explorer" My only reservation about this change is if there is an option that can be specified successfully at build time, but when used at scanner discovery time causes the compiler to fail, or return incorrect results. Therefore I have added a new field, excludeFromScannerDiscovery to tool options (buildDefinitions extension point) that allows tool integrators to always exclude a command line option from ALL_FLAGS. I have also added a new "Other flags (excluded from discovery)" to the "Miscellaneous" tab to allow compiler options to be entered by the user.
9c7a8d7
to
5b08c5d
Compare
I don't have confidence to change the default, so this latest version adds the new
Short answer is that I didn't come up with a good way. So this feature is there for those that know about it (who read the N&N/docs). Separately, it may be worth going to set |
I just had another thought about this. |
I think that has the same risks of breaking existing projects as making ALL_FLAGS the default. In practice it will mean that all existing options will be effectively useByScannerDiscovery == true. But unlike the ALL_FLAGS being default, there will be no way for users to get it to work if there is a conflict between the option and scanner discovery (except to move those options into the new option field I added, which isn't even possible for some enum type options) Your proposal should have been the original design! |
I guess you are right, but the ALL_FLAGS workaround means that after you do that, it's strictly CDT11 as the symbol is unavailable in CDT10. Isn't that worse of a break? I'm not saying that we should do A or B, I'm just venting our options. |
I don't think that is a break at all. The change is backwards compatible, but not forwards compatible. |
I was thinking more about if someone adopts the ALL_FLAGS instead of FLAGS, then that project will not work with CDT10, while the solution to invert the default value for useByScannerDiscovery would work for both, but "forces" the toolchain integration provider to have the correct value on the options. |
I fear you may be right, this change is backwards compatible, but not forwards compatible. Basically what level of support should we provide users who open a project created with CDT 11 in CDT < 11? |
BTW there is too separate parts of the conversation, changing useByScannerDiscovery default to true is not backwards compatible, so I don't think that can be changed at all. So now my concern is by introducing ALL_FLAGS we have something that is not forwards compatible from pre-CDT 11 to CDT 11. I'm going to look at how we handled that kind of not forward compatible change in the past and we'll see what we do from there. |
On review I don't think we have handled these types of forward compatibility problems properly in the past, so I don't think we need to worry about it now. For example if in version N a new compiler option is added to the UI, a user checks it, and then opens that project up in version N-1, the option will be silently ignored, which, depending on the option, will lead to compiler error, or differently compiled code. It would probably be nice to have a warning for projects, similar to what happens when you try to open a workspace in an older version of eclipse, but I think that is outside the scope of this issue. |
Fixes Bug 571722.
This change adds the ALL_FLAGS that does not limit tool options to
those declared as IOption::isForScannerDiscovery when launching the
compiler to discover compiler built-ins.
This is needed as many other flags, either entered manually in "Other
flags" or some of the existing flags with checkboxes such as "-ansi",
"-fPIC", and "-fstack-protector-all" which all affect scanner discovery
as they can all change what macros are built-in to the compiler.
The current solution has as a drawback that some settings, like -I and -D
then appear twice. For example in the "Includes" node in the "Project
Explorer"
My only reservation about this change is if there is an option
that can be specified successfully at build time, but when used
at scanner discovery time causes the compiler to fail, or return
incorrect results. Therefore I have added a new field,
excludeFromScannerDiscovery to tool options (buildDefinitions
extension point) that allows tool integrators to always exclude
a command line option from ALL_FLAGS. I have also added
a new "Other flags (excluded from discovery)" to the
"Miscellaneous" tab to allow compiler options to be entered
by the user.
TODO: