[libcxx-commits] [libcxx] [libcxxabi] [libunwind] [llvm] [runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler (PR #108357)
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 18 04:03:55 PST 2024
mstorsjo wrote:
Ok, now I tried this myself (and indeed, it wasn't very hard to set up - sorry for not trying it earlier).
Here's the effect on the configure run, caused by this patch:
```diff
--- log-good-truncated 2024-12-18 13:59:16.334711800 +0200
+++ log-bad 2024-12-18 13:58:07.287917504 +0200
@@ -29,10 +29,19 @@
-- Could NOT find Clang (missing: Clang_DIR)
-- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG
-- Performing Test CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG - Failed
--- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG
--- Performing Test CXX_SUPPORTS_NOSTDLIBXX_FLAG - Failed
--- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG
--- Performing Test CXX_SUPPORTS_NOSTDINCXX_FLAG - Success
+-- Performing Test C_SUPPORTS_NOSTDLIBXX_FLAG
+-- Performing Test C_SUPPORTS_NOSTDLIBXX_FLAG - Success
+-- Performing Test C_SUPPORTS_NOSTDINCXX_FLAG
+-- Performing Test C_SUPPORTS_NOSTDINCXX_FLAG - Success
-- Linker detection: LLD
-- Performing Test CXX_SUPPORTS_CUSTOM_LINKER
--- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Success
+-- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Failed
+CMake Error at /home/martin/code/llvm-project/llvm/cmake/modules/HandleLLVMOpti
ons.cmake:412 (message):
+ Host compiler does not support '-fuse-ld=lld'. Please make sure that 'lld'
+ is installed and that your host compiler can compile a simple program when
+ given the option '-fuse-ld=lld'.
+Call Stack (most recent call first):
+ CMakeLists.txt:179 (include)
+
+
+-- Configuring incomplete, errors occurred!
```
So previously, `CXX_SUPPORTS_NOSTDLIBXX_FLAG` failed, so we didn't add `-nostdlib++`. It failed due to the issue that does get fixed by https://github.com/llvm/llvm-project/pull/120370. By applying this change, we happen to go around that issue, so we end up adding `-nostdlib++`, even when it fails to link in C++ mode.
So, indeed, https://github.com/llvm/llvm-project/pull/120370 seems like a proper fix for this. Thanks!
(Ideally, we probably should probe for support for these flags separately for C and C++ mode, but it would require CMake to have something like `CMAKE_REQUIRED_FLAGS` separately for C and C++, which it doesn't - that's the whole root cause for this mess.)
https://github.com/llvm/llvm-project/pull/108357
More information about the libcxx-commits
mailing list