summaryrefslogtreecommitdiff
path: root/runtimes
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2023-02-21 01:02:42 +0000
committerPetr Hosek <phosek@google.com>2023-03-28 07:37:47 +0000
commit7765e5d9a14c683ac770f835f0463b882c6db5e0 (patch)
tree33ba323fa8213a1bd57fcf7451561acbbf0c60a0 /runtimes
parent6b971325e9eac315b83aa474c01da85b81062d17 (diff)
downloadllvm-7765e5d9a14c683ac770f835f0463b882c6db5e0.tar.gz
[runtimes][CMake] Drop the check to see if linker works
This isn't needed anymore. Differential Revision: https://reviews.llvm.org/D144440
Diffstat (limited to 'runtimes')
-rw-r--r--runtimes/CMakeLists.txt62
1 files changed, 32 insertions, 30 deletions
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index ea5e7d9b0fb1..be6ab65fcf43 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -103,36 +103,38 @@ filter_prefixed("${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMA
filter_prefixed("${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES)
-check_c_compiler_flag("" LLVM_RUNTIMES_LINKING_WORKS)
-if (NOT LLVM_RUNTIMES_LINKING_WORKS)
- # The compiler driver may be implicitly trying to link against libunwind,
- # which might not work if libunwind doesn't exist yet. Try to check if
- # --unwindlib=none is supported, and use that if possible.
- # Don't add this if not necessary to fix linking, as it can break using
- # 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()
+# The compiler driver may be implicitly trying to link against libunwind,
+# which might not work if libunwind doesn't exist yet. Try to check if
+# --unwindlib=none is supported, and use that if possible.
+#
+# TODO: Note that this is problematic when LLVM_USE_SANITIZER is used
+# because some sanitizers require the unwinder and so the combination of
+# -fsanitize=... --unwindlib=none will always result in a linking error.
+# Currently, we counteract this issue by adding -fno-sanitize=all flag in
+# the project specific code within */cmake/config-ix.cmake files but that's
+# brittle. We should ideally move this to runtimes/CMakeLists.txt.
+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()