[feature request] Makefile: Additional CXX_USER_FLAGS only for C++ Compilation
jpf91 opened this issue ยท 3 comments
Is your feature request related to a problem? Please describe.
When compilling C++ code, I sometimes need flags which are not valid for C code, for example -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics
. I can just pass them to USER_FLAGS
, but then they also get passed when compiling C files. in that case, GCC complains with warnings:
cc1: warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for C
Describe the solution you'd like
Split CC_OPTS
into C_OPTS
and CXX_OPTS
. Introduce CXX_USER_FLAGS
and only use those for CXX_OPTS
and in cpp compilation.
Though I guess there are other options to implement this as well. In the end, anything that allows specifying flags in the user Makefile that only get passed to the C++ compiler should work.
In addition, it would be nice to have a variable only affecting link flags. AFAIK -fwhole-program
behaves differently at compile and link time.
Hey @jpf91!
Sounds like a good idea! However, I am not an experienced C++ user... ๐ Would you draft a PR so we can see which way this is going? ๐
Hey @stnolting
I've drafted a PR in #862 . It seems those variables even have somewhat standardized names, I always thought it's just a convention.
I didn't any flags yet, as that is a completely different and probably controversial topic :-)
For example, I recently experimented with -flto and -fwhole-program which worked fine when executing code from IRAM but broke execution in XIP mode. I still don't know why ;-)
But this change alone should enable users to specify any C++ and/or linker flags by themselves. I guess we can continue the discussion in #862