-
Notifications
You must be signed in to change notification settings - Fork 7.4k
cmake: Don't use -nostdinc with CXX #18189
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
cmake: Don't use -nostdinc with CXX #18189
Conversation
It is observed that the C++ standard library headers can not be found when -nostdinc is used. To fix this we omit -nostdinc when building for C++. To reproduce the issue use the latest zephyr master and add #include <vector> to the list of includes in samples/cpp_synchronization. Without this fix the sample will not build for for gnuarmemb or the Zephyr SDK. Signed-off-by: Sebastian Bøe <[email protected]>
If we do this for C++ why wouldn't we do it for C? |
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.
Generally when using C++ you need CONFIG_NEWLIB_LIBC=y to access the C++ standard headers. In that case this branch is already bypassed, so the fix doesn't work.
@pabigot : Would you kindly post steps to reproduce (where this fix doesn't work) with the latest Zephyr master and SDK/gnuarmemb versions? |
Using -nostdinc is inherited from the Linux kernel: Why the linux kernel does this I do not know. IIRC I attempted to get rid of it at some point but was unable to. That being said, if there are some unwanted side-effects of dropping -nostdinc then I would rather find out in the C++ build than have it crop up in the more mainstream C build. |
Do exactly the case that works with this patch, but instead of Using this PR and gcc-arm-none-eabi-8-2019-q3-update the build fails even without adding I've done some diagnostic builds and there's no difference in compiler/preprocessor invocation between the Zephyr toolchain and the ARM one except the path to the system include directory. There's no obvious difference in the contents of the system include directory, ignoring newlib version 3.1 vs 3.0. There must be a difference in the way gcc and newlib are configured in the Zephyr SDK that changes the behavior. My setup is:
|
I don't see Nor |
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.
Please add a testcase as part of this for using stdlib C++ functionality. So that way we know if this breaks in the future.
Something like:
void test_main(void)
{
/* Does nothing. This is a compile only test. */
vector v;
std::vector<int> v;
v.push_back(10);
}
Closing as this was not the correct approach. |
It is observed that the C++ standard library headers can not be found
when -nostdinc is used. To fix this we omit -nostdinc when building
for C++.
To reproduce the issue use the latest zephyr master and add
#include <vector>
to the list of includes in samples/cpp_synchronization.
Without this fix the sample will not build for for gnuarmemb or the
Zephyr SDK.
This fixes #15603 and uses the fix suggested here: #15603 (comment)