[libcxx-commits] [PATCH] D145596: [runtimes] Fixes building with CMake 3.26.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 8 09:57:06 PST 2023


Mordante created this revision.
Herald added a project: All.
Mordante requested review of this revision.
Herald added projects: libc++, libc++abi.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.

Using -nostdinc++ as a linker flag in CMake 3.26 will cause compilation
failures due to -Wunused-command-line-argument. This causes several
compiler flags to be rejected. This will cause libunwind to refuse to
build since its required flags aren't supported by the compiler.

Note CMake 3.26 has not been released yet. This has been tested with
RC5. CMake 3.26 is used to test with C++ modules in libc++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145596

Files:
  runtimes/CMakeLists.txt


Index: runtimes/CMakeLists.txt
===================================================================
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -144,6 +144,13 @@
 if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 endif()
+# When present, the -nostdinc++ flag gets propagated to the linker flags. In
+# CMake 3.26 this causes try_compile to fail for other compile options. Which
+# results in flags not being set, even when present.
+check_c_compiler_flag("-Wno-unused-command-line-argument" C_SUPPORTS_START_NO_UNUSED_COMMAND_LINE_ARGUMENTS)
+if (C_SUPPORTS_START_NO_UNUSED_COMMAND_LINE_ARGUMENTS)
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-unused-command-line-argument")
+endif()
 check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)
 if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145596.503420.patch
Type: text/x-patch
Size: 931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230308/bca87a00/attachment.bin>


More information about the libcxx-commits mailing list