Skip to content

Commit 833b0b0

Browse files
h-vetinarirprichard
andcommitted
[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 Co-Authored-By: Ryan Prichard <[email protected]>
1 parent 84f2af3 commit 833b0b0

File tree

4 files changed

+6
-25
lines changed

4 files changed

+6
-25
lines changed

clang/tools/clang-repl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export_executable_symbols_for_plugins(clang-repl)
6969
# gold. This flag tells the linker to build a PLT for the full address range.
7070
# Linkers without this flag are assumed to support proper PLTs by default.
7171
set(flag_long_plt "-Wl,--long-plt")
72-
llvm_check_linker_flag(CXX ${flag_long_plt} HAVE_LINKER_FLAG_LONG_PLT)
72+
check_linker_flag(CXX ${flag_long_plt} HAVE_LINKER_FLAG_LONG_PLT)
7373
if(HAVE_LINKER_FLAG_LONG_PLT)
7474
target_link_options(clang-repl PRIVATE ${flag_long_plt})
7575
endif()
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
include(CMakePushCheckState)
2-
3-
include(CheckCompilerFlag OPTIONAL)
4-
5-
if(NOT COMMAND check_compiler_flag)
6-
include(CheckCCompilerFlag)
7-
include(CheckCXXCompilerFlag)
8-
endif()
2+
include(CheckCompilerFlag)
93

104
function(llvm_check_compiler_linker_flag lang flag out_var)
11-
# If testing a flag with check_c_compiler_flag, it gets added to the compile
5+
# If testing a flag with check_compiler_flag, it gets added to the compile
126
# command only, but not to the linker command in that test. If the flag
137
# is vital for linking to succeed, the test would fail even if it would
148
# have succeeded if it was included on both commands.
@@ -18,18 +12,6 @@ function(llvm_check_compiler_linker_flag lang flag out_var)
1812

1913
cmake_push_check_state()
2014
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
21-
if(COMMAND check_compiler_flag)
22-
check_compiler_flag("${lang}" "" ${out_var})
23-
else()
24-
# Until the minimum CMAKE version is 3.19
25-
# cmake builtin compatible, except we assume lang is C or CXX
26-
if("${lang}" STREQUAL "C")
27-
check_c_compiler_flag("" ${out_var})
28-
elseif("${lang}" STREQUAL "CXX")
29-
check_cxx_compiler_flag("" ${out_var})
30-
else()
31-
message(FATAL_ERROR "\"${lang}\" is not C or CXX")
32-
endif()
33-
endif()
15+
check_compiler_flag("${lang}" "" ${out_var})
3416
cmake_pop_check_state()
3517
endfunction()

compiler-rt/cmake/config-ix.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
include(CMakePushCheckState)
22
include(AddLLVM)
3-
include(LLVMCheckCompilerLinkerFlag)
43
include(CheckCCompilerFlag)
54
include(CheckCXXCompilerFlag)
65
include(CheckIncludeFiles)
@@ -15,7 +14,7 @@ include(TestBigEndian)
1514
# in tree version of runtimes, we'd be linking against the just-built
1615
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
1716
# built libunwind isn't installed yet). For those cases, it'd be good to
18-
# link with --uwnindlib=none. Check if that option works.
17+
# link with --unwindlib=none. Check if that option works.
1918
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
2019

2120
check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)

libcxx/cmake/config-ix.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ 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.
15+
# link with --unwindlib=none. Check if that option works.
1616
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
1717

1818
if (NOT LIBCXX_USE_COMPILER_RT)

0 commit comments

Comments
 (0)