[libcxx-commits] [PATCH] D124377: [runtimes] [CMake] Fix checks for -Werror when building with incomplete toolchains

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 12 14:30:45 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4169b5251f58: [runtimes] [CMake] Fix checks for -Werror when building with incomplete… (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124377/new/

https://reviews.llvm.org/D124377

Files:
  runtimes/CMakeLists.txt


Index: runtimes/CMakeLists.txt
===================================================================
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -102,7 +102,27 @@
   # e.g. ASAN/TSAN.
   llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
   if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
+    set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
+    # TODO: When we can require CMake 3.14, we should use
+    # CMAKE_REQUIRED_LINK_OPTIONS here. Until then, we need a workaround:
+    # When using CMAKE_REQUIRED_FLAGS, this option gets added both to
+    # compilation and linking commands. That causes warnings in the
+    # compilation commands during cmake tests. This is normally benign, but
+    # when testing whether -Werror works, that test fails (due to the
+    # preexisting warning).
+    #
+    # Therefore, before we can use CMAKE_REQUIRED_LINK_OPTIONS, check if we
+    # can use --start-no-unused-arguments to silence the warnings about
+    # --unwindlib=none during compilation.
+    #
+    # We must first add --unwindlib=none to CMAKE_REQUIRED_FLAGS above, to
+    # allow this subsequent test to succeed, then rewrite CMAKE_REQUIRED_FLAGS
+    # below.
+    check_c_compiler_flag("--start-no-unused-arguments" C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
+    if (C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
+      set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS} --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments")
+    endif()
   endif()
 endif()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124377.429079.patch
Type: text/x-patch
Size: 1611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220512/bb3714b3/attachment.bin>


More information about the libcxx-commits mailing list