Skip to content

[Runtimes] -nostdlib++ and -nostdinc++ in CMAKE_REQUIRED_FLAGS breaks systems introspection #139771

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

Open
Meinersbur opened this issue May 13, 2025 · 2 comments
Assignees
Labels
cmake Build system in general and CMake in particular

Comments

@Meinersbur
Copy link
Member

The flags -nostdlib++ and -nostdinc++ are added to CMAKE_REQUIRED_FLAGS whenever supported by the compiler:

set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++")

set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")

For a normal bootstrapping build the compiler is Clang, so it will always be added. It inherits to all runtimes libraries.

While it may make sense for libc++ to not depend on itself or another C++ standard library, the assumption breaks for any other LLVM runtime library that use C++, which included any GTest-based unittests. Tracking its history, it seems to have first been added in d3ebe71, but just temporarily. The temporary part was dropped at some point. The flags should only be added in those libraries that need it.

Adding those flags globally for all runtimes causes problems in system introspection. e.g.:

@mstorsjo
Copy link
Member

For context; I made some effort at fixing this earlier, in #108357 (75d0281), but that had to be reverted.

@Meinersbur
Copy link
Member Author

#108357 is solving a specific problem that C++ flag is also used for check_c_source_compiles which break with gcc. But I don't want -nostdlib++ at all in CMAKE_REQUIRED_FLAGS -- independent of whether it is accepted by the C and/or C++ compiler. The entire underlying assumption that none of the runtime libraries will not use the pre-installed standard library is conceptionally wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular
Projects
None yet
Development

No branches or pull requests

9 participants