Build info collection ignores CXXFLAGS
migel opened this issue · 4 comments
It looks like the process that is run to collect include paths and preprocessor macros is not passed the CXXFLAGS
. This can cause problems when the CXXFLAGS
affects the results. For example using --std=c++11
flag defines the macro __cplusplus 201103L
; without it the eclipse c++ indexer will not properly parse c++ 11 code. Another example is using --stdlib=libc++
with clang++
, it adds /usr/include/c++/v1
to the list of include paths.
This issue still exists as of 2016-02-08. I've hacked together a fix for this as follows:
Extract BuildInfoCollector.py from the plugin (eclipse/plugins/ch.hsr.ifs.sconsolidator.core_0.6.0.201511051319.jar).
Edit the top part of the collect_sys_macros method like so:
def get_compiler_flags(lang, environ):
return (environ['CXXFLAGS'] if lang == 'c++' else environ['CCFLAGS'])
def collect_sys_macros(lang, environ):
command = [get_compiler(environ), '-E', '-dM', get_gcc_lang_param(lang)] + get_compiler_flags(lang, environ) + ['-']
process = SCons.Action._subproc(environ, command, stdin='devnull', stderr=subprocess.PIPE, stdout=subprocess.PIPE)
Note the addition and use the get_compiler_flags method. After editing, put this back into the plugin in the same place (7-Zip does a fine job of this.)
This solves the problem for me, although I suspect there may be a more elegant way to do this (separate the options into another environment variable? or have a discovery cmd environment variable that can be set.)
Cheers!
@IMLizKing Thanks a lot for your fix. So basically you are using the configured flags in CXXFLAGS/CCFLAGS to collect the built-in compiler macros which in turn might be dependent on the chosen language level configured with the flags (e.g., C++11)?
@migel If this also works for you I'm happy to include this fix into the plug-in. Please let me know.
Looks good, thanks for the fix.
@mrueegg Yep, this works for me since my CXXFLAGS explicitly include -std=gnu++11
.
I think that the collect_sys_includes
may also benefit from the inclusion of these flags (CCFLAGS or CXXFLAGS), if indeed the options alter the system include paths as @migel indicates. I haven't tested that though as my needs are currently being met...