Skip to content

[runtimes] Append -nostd*++ flags only if necessary #151930

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mgorny
Copy link
Member

@mgorny mgorny commented Aug 4, 2025

Append -nostd*++ flags only if we have checked that a trivial C++ program cannot link without them. This is meant as a workaround for #90332. While the flags could still incorrectly be passed to the C compiler, this should at least no longer happen when we are using a C++ compiler with the C++ runtime provided, which is the case Gentoo was hitting.

Fixes #90332

Append `-nostd*++` flags only if we have checked that a trivial C++
program cannot link without them.  This is meant as a workaround
for llvm#90332.  While the flags could still incorrectly be passed
to the C compiler, this should at least no longer happen when we are
using a C++ compiler with the C++ runtime provided, which is the case
Gentoo was hitting.

Fixes llvm#90332

Signed-off-by: Michał Górny <[email protected]>
Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need the required flags for again? I'm guessing this is just for checking C/C++ flags?

@mgorny
Copy link
Member Author

mgorny commented Aug 4, 2025

That's my understanding — we're adding them, so CMake checks don't fail prior to the runtimes being built.

Unfortunately, looks like my idea breaks some stuff still. That said, I'm not 100% convinced it just doesn't reveal an existing bug:

Performing C++ SOURCE FILE Test CXX_SUPPORTS_NOSTDINCXX_FLAG failed with the following output:
Change Dir: /home/runner/_work/llvm-project/llvm-project/build/generic-asan/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/local/bin/ninja cmTC_779c6 && [1/2] Building CXX object CMakeFiles/cmTC_779c6.dir/src.cxx.o
[2/2] Linking CXX executable cmTC_779c6
FAILED: cmTC_779c6 
: && /usr/bin/clang++-21 -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer -fsanitize=address -fdiagnostics-color -ffunction-sections -fdata-sections  --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments  CMakeFiles/cmTC_779c6.dir/src.cxx.o -o cmTC_779c6   && :
/usr/bin/ld: /usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_unwind_linux_libcdep.cpp.o): undefined reference to symbol '_Unwind_Backtrace@@GCC_3.3'
/usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
clang++-21: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

I'm guessing that the code relied on -nostdlib++ just hiding the issue.

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

Successfully merging this pull request may close these issues.

[runtimes] [openmp] -nostdlib++ added to CMAKE_REQUIRED_FLAGS breaks hwloc detection for OMPT
3 participants