-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Remember LLVM_ENABLE_LIBCXX setting in installed configuration #139712
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
base: main
Are you sure you want to change the base?
Remember LLVM_ENABLE_LIBCXX setting in installed configuration #139712
Conversation
This doesn't fix the issue for me, on the same system that #139569 does. My cmake line is:
and then |
Note: It makes no difference if I add |
Why doesn't it add |
@Meinersbur we're trying to build it with this script: https://github.com/arm/arm-toolchain/blob/arm-software/arm-software/linux/build.sh, it used to work for months before problem started a week ago. After my failed attempt to fix the building issue with applying this PR, @DavidTruby has pointed me at some issue with this scipt: building libc++ in a separate step is not a recommended way, it should be built at all steps and the separate step should be dropped. I'll try that later. EDIT: I don't like the proposed idea. The bootstrap compiler is being dropped after the final compiler is ready. If we start building libc++ at that step, the final compiler will be linked against the (shared) libs that will be gone later. EDIT: another proposed idea was to use the |
My issue here is separate to the script; I'm just trying to get a simple case working outside of the script.
EDIT: |
Looking at the output of CXX_COMPILER_SUPPORTS_STDLIB_CHRONO in the runtimes folder: |
Regardless I'm not convinced this check is correct anyway. If there's a mismatch between the requested C++ runtime and the one actually being used, we should error out with a cmake message, not just allow it to continue and silently do the wrong thing. |
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.
Even with the comment I've added, which does make this work, this seems to cause a lot of extra warnings in the other runtimes builds for me. It looks like -stdlib=libc++
is being passed there too, and is then giving the not used at compile time
warning because -nostdinc++
is also being passed.
I believe we only want to add -stdlib=libc++
for runtimes that don't pass -nostdinc++
.
@@ -19,7 +20,11 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED) | |||
if(LLVM_COMPILER_IS_GCC_COMPATIBLE) | |||
check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB) | |||
check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB) | |||
if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB) | |||
cmake_push_check_state() | |||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -stdlib=libc++") |
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.
When this is processed in the runtimes cmake sub-command, CMAKE_REQUIRED_FLAGS
contains -nostdinc++
. You could fix this with:
string(REPLACE "-nostdinc++" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
Which makes the PR work for me.
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.
Just saw your updated PR; I think we do need to still inherit CMAKE_REQUIRED_FLAGS, for cases where the path to the c++ lib is being added as a flag etc. We just need to specifically remove -nostdinc++
.
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.
Ah, never mind, that's not how CMAKE_REQUIRED_FLAGS works :). It will still be populated with CMAKE_CXX_FLAGS here. I think what you have now is fine.
This works for me now, except for the extra warnings during the compiler-rt build. Could we change the |
Your #139569 will fail some buildbots for the same reasons that #134990 was reverted for and would need the same code to check whether -stdlib=libc++ is actually working. It also passes LLVM_ENABLE_LIBCXX to compiler-rt in a bootstrapping builds and therefore will cause the very same warnings you don't like about this PR. IMHO it is an issue with compiler-rt, the same warning you would get if building compiler-rt in a standalone build with
The Whether If you like I can withdraw this PR and we iterate in #139569. |
I think this is probably better than what I was doing in #139569 so we should stick with this. All I'm saying about |
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.
Just to clarify, I'm happy with this PR now except that it introduces a bunch of warnings to my builds that weren't there before. This was true of my attempt as well, for what it's worth, I just hadn't clocked it at the time.
If you'd rather that gets fixed on the compiler-rt side I can post a fix to compiler-rt to strip -stdlib=libc++
in there so the warnings go away. It might also be necessary for the other runtimes though. Probably all of them except flang-rt?
Updated version of #134990 which was reverted because of the buildbot openmp-offload-amdgpu-runtime-2 failing. Its configuration has
LLVM_ENABLE_LIBCXX=ON
set although it does not even have libc++ installed. In addition to #134990, this PR adds a check whether C++ libraries are actually available.#include <chrono>
was chosen because this is the library that openmp-offload-amdgpu-runtime-2 failed with.Original summary:
The buidbot flang-aarch64-libcxx is currently failing with an ABI issue. The suspected reason is that LLVMSupport.a is built using libc++, but the unittests are using the default C++ standard library, libstdc++ in this case. This predefined
llvm_gtest
target uses the LLVMSupport fromfind_package(LLVM)
, which finds the libc++-built LLVMSupport.To fix, store the
LLVM_ENABLE_LIBCXX
setting in the LLVMConfig.cmake such that everything that links to LLVM libraries use the same standard library. In this case discussed in llvm/llvm-zorg#387 it was the flang-rt unittests, but other runtimes with GTest unittests should have the same issue (e.g. offload), and any external project that usesfind_package(LLVM)
. This patch fixed the problem for me locally.llvm_gtest
defined here:llvm-project/third-party/unittest/CMakeLists.txt
Line 51 in 74f69c4
Used by flang-rt unittests here:
llvm-project/flang-rt/unittests/CMakeLists.txt
Line 20 in 74f69c4
Used by offload here:
llvm-project/offload/CMakeLists.txt
Line 391 in 74f69c4
Use by libc here (but I don't see where it is added):
llvm-project/libc/benchmarks/CMakeLists.txt
Line 42 in 74f69c4