Skip to content

Commit 7765e5d

Browse files
committed
[runtimes][CMake] Drop the check to see if linker works
This isn't needed anymore. Differential Revision: https://reviews.llvm.org/D144440
1 parent 6b97132 commit 7765e5d

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

runtimes/CMakeLists.txt

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,36 +103,38 @@ filter_prefixed("${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMA
103103
filter_prefixed("${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
104104
filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES)
105105

106-
check_c_compiler_flag("" LLVM_RUNTIMES_LINKING_WORKS)
107-
if (NOT LLVM_RUNTIMES_LINKING_WORKS)
108-
# The compiler driver may be implicitly trying to link against libunwind,
109-
# which might not work if libunwind doesn't exist yet. Try to check if
110-
# --unwindlib=none is supported, and use that if possible.
111-
# Don't add this if not necessary to fix linking, as it can break using
112-
# e.g. ASAN/TSAN.
113-
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
114-
if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
115-
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
116-
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
117-
# TODO: When we can require CMake 3.14, we should use
118-
# CMAKE_REQUIRED_LINK_OPTIONS here. Until then, we need a workaround:
119-
# When using CMAKE_REQUIRED_FLAGS, this option gets added both to
120-
# compilation and linking commands. That causes warnings in the
121-
# compilation commands during cmake tests. This is normally benign, but
122-
# when testing whether -Werror works, that test fails (due to the
123-
# preexisting warning).
124-
#
125-
# Therefore, before we can use CMAKE_REQUIRED_LINK_OPTIONS, check if we
126-
# can use --start-no-unused-arguments to silence the warnings about
127-
# --unwindlib=none during compilation.
128-
#
129-
# We must first add --unwindlib=none to CMAKE_REQUIRED_FLAGS above, to
130-
# allow this subsequent test to succeed, then rewrite CMAKE_REQUIRED_FLAGS
131-
# below.
132-
check_c_compiler_flag("--start-no-unused-arguments" C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
133-
if (C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
134-
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS} --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments")
135-
endif()
106+
# The compiler driver may be implicitly trying to link against libunwind,
107+
# which might not work if libunwind doesn't exist yet. Try to check if
108+
# --unwindlib=none is supported, and use that if possible.
109+
#
110+
# TODO: Note that this is problematic when LLVM_USE_SANITIZER is used
111+
# because some sanitizers require the unwinder and so the combination of
112+
# -fsanitize=... --unwindlib=none will always result in a linking error.
113+
# Currently, we counteract this issue by adding -fno-sanitize=all flag in
114+
# the project specific code within */cmake/config-ix.cmake files but that's
115+
# brittle. We should ideally move this to runtimes/CMakeLists.txt.
116+
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
117+
if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
118+
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
119+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
120+
# TODO: When we can require CMake 3.14, we should use
121+
# CMAKE_REQUIRED_LINK_OPTIONS here. Until then, we need a workaround:
122+
# When using CMAKE_REQUIRED_FLAGS, this option gets added both to
123+
# compilation and linking commands. That causes warnings in the
124+
# compilation commands during cmake tests. This is normally benign, but
125+
# when testing whether -Werror works, that test fails (due to the
126+
# preexisting warning).
127+
#
128+
# Therefore, before we can use CMAKE_REQUIRED_LINK_OPTIONS, check if we
129+
# can use --start-no-unused-arguments to silence the warnings about
130+
# --unwindlib=none during compilation.
131+
#
132+
# We must first add --unwindlib=none to CMAKE_REQUIRED_FLAGS above, to
133+
# allow this subsequent test to succeed, then rewrite CMAKE_REQUIRED_FLAGS
134+
# below.
135+
check_c_compiler_flag("--start-no-unused-arguments" C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
136+
if (C_SUPPORTS_START_NO_UNUSED_ARGUMENTS)
137+
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS} --start-no-unused-arguments --unwindlib=none --end-no-unused-arguments")
136138
endif()
137139
endif()
138140

0 commit comments

Comments
 (0)