Skip to content

Commit 1515c2c

Browse files
committed
[cmake] switch to CMake's native check_compiler_flag, delete LLVMCheckCompilerLinkerFlag.cmake
now that CMake baseline has moved past 3.19; see https://cmake.org/cmake/help/latest/module/CheckCompilerFlag.html
1 parent 1df587e commit 1515c2c

File tree

7 files changed

+30
-65
lines changed

7 files changed

+30
-65
lines changed

cmake/Modules/LLVMCheckCompilerLinkerFlag.cmake

Lines changed: 0 additions & 35 deletions
This file was deleted.

compiler-rt/cmake/config-ix.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include(CheckCCompilerFlag)
55
include(CheckCXXCompilerFlag)
66
include(CheckIncludeFiles)
77
include(CheckLibraryExists)
8-
include(LLVMCheckCompilerLinkerFlag)
8+
include(CheckCompilerFlag)
99
include(CheckSymbolExists)
1010
include(TestBigEndian)
1111

@@ -15,8 +15,8 @@ include(TestBigEndian)
1515
# in tree version of runtimes, we'd be linking against the just-built
1616
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
1717
# built libunwind isn't installed yet). For those cases, it'd be good to
18-
# link with --uwnindlib=none. Check if that option works.
19-
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
18+
# link with --unwindlib=none. Check if that option works.
19+
check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
2020

2121
check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)
2222
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
@@ -190,12 +190,12 @@ check_library_exists(c++ __cxa_throw "" COMPILER_RT_HAS_LIBCXX)
190190
check_library_exists(stdc++ __cxa_throw "" COMPILER_RT_HAS_LIBSTDCXX)
191191

192192
# Linker flags.
193-
llvm_check_compiler_linker_flag(C "-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT)
194-
llvm_check_compiler_linker_flag(C "-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG)
193+
check_compiler_flag(C "-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT)
194+
check_compiler_flag(C "-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG)
195195

196196
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
197197
set(VERS_COMPAT_OPTION "-Wl,-z,gnu-version-script-compat")
198-
llvm_check_compiler_linker_flag(C "${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
198+
check_compiler_flag(C "${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
199199
endif()
200200

201201
set(DUMMY_VERS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/dummy.vers)
@@ -206,10 +206,10 @@ if(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
206206
# -z gnu-version-script-compat.
207207
string(APPEND VERS_OPTION " ${VERS_COMPAT_OPTION}")
208208
endif()
209-
llvm_check_compiler_linker_flag(C "${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT)
209+
check_compiler_flag(C "${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT)
210210

211211
if(ANDROID)
212-
llvm_check_compiler_linker_flag(C "-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL)
212+
check_compiler_flag(C "-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL)
213213
check_library_exists(log __android_log_write "" COMPILER_RT_HAS_LIBLOG)
214214
endif()
215215

@@ -481,7 +481,7 @@ if(APPLE)
481481
-lc++
482482
-lc++abi)
483483

484-
llvm_check_compiler_linker_flag(C "-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION)
484+
check_compiler_flag(C "-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION)
485485
if(COMPILER_RT_HAS_APP_EXTENSION)
486486
list(APPEND DARWIN_COMMON_LINK_FLAGS "-fapplication-extension")
487487
endif()

libcxx/cmake/config-ix.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include(CMakePushCheckState)
22
include(CheckLibraryExists)
33
include(CheckSymbolExists)
4-
include(LLVMCheckCompilerLinkerFlag)
4+
include(CheckCompilerFlag)
55
include(CheckCCompilerFlag)
66
include(CheckCXXCompilerFlag)
77
include(CheckCSourceCompiles)
@@ -12,8 +12,8 @@ include(CheckCSourceCompiles)
1212
# LIBCXXABI_USE_LLVM_UNWINDER set, we'd be linking against the just-built
1313
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
1414
# built libunwind isn't installed yet). For those cases, it'd be good to
15-
# link with --uwnindlib=none. Check if that option works.
16-
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
15+
# link with --unwindlib=none. Check if that option works.
16+
check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
1717

1818
if (NOT LIBCXX_USE_COMPILER_RT)
1919
if(WIN32 AND NOT MINGW)

libunwind/cmake/config-ix.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ include(CMakePushCheckState)
22
include(CheckCCompilerFlag)
33
include(CheckCXXCompilerFlag)
44
include(CheckLibraryExists)
5-
include(LLVMCheckCompilerLinkerFlag)
5+
include(CheckCompilerFlag)
66
include(CheckSymbolExists)
77
include(CheckCSourceCompiles)
88

99
# The compiler driver may be implicitly trying to link against libunwind, which
1010
# might not work if libunwind doesn't exist yet. Try to check if
1111
# --unwindlib=none is supported, and use that if possible.
12-
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
12+
check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
1313

1414
if (HAIKU)
1515
check_library_exists(root fopen "" LIBUNWIND_HAS_ROOT_LIB)
@@ -35,11 +35,11 @@ endif()
3535
# required for the link to go through. We remove sanitizers from the
3636
# configuration checks to avoid spurious link errors.
3737

38-
llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
38+
check_compiler_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
3939
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
4040
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
4141
else()
42-
llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
42+
check_compiler_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
4343
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
4444
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
4545
endif()

offload/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ endif()
294294

295295
if(OPENMP_STANDALONE_BUILD OR TARGET omp)
296296
# Check LIBOMP_HAVE_VERSION_SCRIPT_FLAG
297-
include(LLVMCheckCompilerLinkerFlag)
297+
include(CheckCompilerFlag)
298298
if(NOT APPLE)
299-
llvm_check_compiler_linker_flag(C "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/../openmp/runtime/src/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
299+
check_compiler_flag(C "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/../openmp/runtime/src/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
300300
endif()
301301
endif()
302302

openmp/runtime/cmake/config-ix.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#//===----------------------------------------------------------------------===//
99
#
1010

11+
include(CheckCompilerFlag)
1112
include(CheckCCompilerFlag)
1213
include(CheckCSourceCompiles)
1314
include(CheckCXXSourceCompiles)
@@ -17,7 +18,6 @@ include(CheckLibraryExists)
1718
include(CheckIncludeFiles)
1819
include(CheckSymbolExists)
1920
include(LibompCheckFortranFlag)
20-
include(LLVMCheckCompilerLinkerFlag)
2121

2222
# Check for versioned symbols
2323
function(libomp_check_version_symbols retval)
@@ -128,13 +128,13 @@ check_symbol_exists(_aligned_malloc "malloc.h" LIBOMP_HAVE__ALIGNED_MALLOC)
128128

129129
# Check linker flags
130130
if(WIN32)
131-
llvm_check_compiler_linker_flag(C /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG)
131+
check_compiler_flag(C /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG)
132132
elseif(NOT APPLE)
133-
llvm_check_compiler_linker_flag(C -Wl,-x LIBOMP_HAVE_X_FLAG)
134-
llvm_check_compiler_linker_flag(C -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
135-
llvm_check_compiler_linker_flag(C "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
136-
llvm_check_compiler_linker_flag(C -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
137-
llvm_check_compiler_linker_flag(C -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
133+
check_compiler_flag(C -Wl,-x LIBOMP_HAVE_X_FLAG)
134+
check_compiler_flag(C -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
135+
check_compiler_flag(C "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
136+
check_compiler_flag(C -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
137+
check_compiler_flag(C -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
138138
endif()
139139

140140
# Check Intel(R) C Compiler specific flags
@@ -145,8 +145,8 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Intel" OR CMAKE_C_COMPILER_ID STREQUAL "IntelLL
145145
check_cxx_compiler_flag(-Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG)
146146
check_cxx_compiler_flag(-falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG)
147147
check_cxx_compiler_flag("-opt-streaming-stores never" LIBOMP_HAVE_OPT_STREAMING_STORES_FLAG)
148-
llvm_check_compiler_linker_flag(C -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG)
149-
llvm_check_compiler_linker_flag(C -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)
148+
check_compiler_flag(C -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG)
149+
check_compiler_flag(C -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)
150150
check_library_exists(irc_pic _intel_fast_memcpy "" LIBOMP_HAVE_IRC_PIC_LIBRARY)
151151
endif()
152152

runtimes/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
7979
set(LLVM_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
8080

8181
include(CheckLibraryExists)
82-
include(LLVMCheckCompilerLinkerFlag)
82+
include(CheckCompilerFlag)
8383
include(CheckCCompilerFlag)
8484
include(CheckCXXCompilerFlag)
8585

@@ -114,7 +114,7 @@ filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} C
114114
# Currently, we counteract this issue by adding -fno-sanitize=all flag in
115115
# the project specific code within */cmake/config-ix.cmake files but that's
116116
# brittle. We should ideally move this to runtimes/CMakeLists.txt.
117-
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
117+
check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
118118
if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
119119
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
120120
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none")
@@ -143,7 +143,7 @@ endif()
143143
# Check for -nostdlib++ first; if there's no C++ standard library yet,
144144
# all check_cxx_compiler_flag commands will fail until we add -nostdlib++
145145
# (or -nodefaultlibs).
146-
llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
146+
check_compiler_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
147147
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
148148
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
149149
endif()

0 commit comments

Comments
 (0)