Skip to content

Commit fcd9671

Browse files
committed
[cmake] also do static-vs-linker work-around in runtimes/CMakeLists.txt
1 parent 6ade702 commit fcd9671

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

runtimes/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ filter_prefixed("${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMA
104104
filter_prefixed("${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
105105
filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES)
106106

107+
# Disable linker for CMake flag compatibility checks
108+
#
109+
# Due to https://gitlab.kitware.com/cmake/cmake/-/issues/23454, we need to
110+
# disable CMAKE_REQUIRED_LINK_OPTIONS (c.f. CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG),
111+
# for static targets; cache the target type here, and reset it after the various
112+
# checks have been performed.
113+
set(_previous_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
114+
set(_previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
115+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
116+
set(CMAKE_REQUIRED_LINK_OPTIONS)
117+
107118
# The compiler driver may be implicitly trying to link against libunwind,
108119
# which might not work if libunwind doesn't exist yet. Try to check if
109120
# --unwindlib=none is supported, and use that if possible.
@@ -132,6 +143,10 @@ if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
132143
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++")
133144
endif()
134145

146+
# reset CMAKE_TRY_COMPILE_TARGET_TYPE & CMAKE_REQUIRED_LINK_OPTIONS after flag checks
147+
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_previous_CMAKE_TRY_COMPILE_TARGET_TYPE})
148+
set(CMAKE_REQUIRED_LINK_OPTIONS ${_previous_CMAKE_REQUIRED_LINK_OPTIONS})
149+
135150
# Avoid checking whether the compiler is working.
136151
set(LLVM_COMPILER_CHECKED ON)
137152

0 commit comments

Comments
 (0)