-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cmake] switch to CMake's native check_{compiler,linker}_flag
#96171
Conversation
@llvm/pr-subscribers-offload @llvm/pr-subscribers-libcxx Author: None (h-vetinari) ChangesBroken out from #93429 Somewhat closing the loop opened by 7017e6c Full diff: https://github.com/llvm/llvm-project/pull/96171.diff 12 Files Affected:
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index 290bf2a42536d..018605c2fd4f2 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -107,7 +107,7 @@ endif()
if(CLANG_ORDER_FILE AND
(LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
- include(LLVMCheckLinkerFlag)
+ include(CheckLinkerFlag)
if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
@@ -118,7 +118,7 @@ if(CLANG_ORDER_FILE AND
endif()
# This is a test to ensure the actual order file works with the linker.
- llvm_check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
+ check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
# Passing an empty order file disables some linker layout optimizations.
# To work around this and enable workflows for re-linking when the order file
diff --git a/cmake/Modules/LLVMCheckCompilerLinkerFlag.cmake b/cmake/Modules/LLVMCheckCompilerLinkerFlag.cmake
deleted file mode 100644
index f61ec0585f9a4..0000000000000
--- a/cmake/Modules/LLVMCheckCompilerLinkerFlag.cmake
+++ /dev/null
@@ -1,35 +0,0 @@
-include(CMakePushCheckState)
-
-include(CheckCompilerFlag OPTIONAL)
-
-if(NOT COMMAND check_compiler_flag)
- include(CheckCCompilerFlag)
- include(CheckCXXCompilerFlag)
-endif()
-
-function(llvm_check_compiler_linker_flag lang flag out_var)
- # If testing a flag with check_c_compiler_flag, it gets added to the compile
- # command only, but not to the linker command in that test. If the flag
- # is vital for linking to succeed, the test would fail even if it would
- # have succeeded if it was included on both commands.
- #
- # Therefore, try adding the flag to CMAKE_REQUIRED_FLAGS, which gets
- # added to both compiling and linking commands in the tests.
-
- cmake_push_check_state()
- set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
- if(COMMAND check_compiler_flag)
- check_compiler_flag("${lang}" "" ${out_var})
- else()
- # Until the minimum CMAKE version is 3.19
- # cmake builtin compatible, except we assume lang is C or CXX
- if("${lang}" STREQUAL "C")
- check_c_compiler_flag("" ${out_var})
- elseif("${lang}" STREQUAL "CXX")
- check_cxx_compiler_flag("" ${out_var})
- else()
- message(FATAL_ERROR "\"${lang}\" is not C or CXX")
- endif()
- endif()
- cmake_pop_check_state()
-endfunction()
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 75e4d3677703a..e90e95438c069 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -5,7 +5,7 @@ include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckIncludeFiles)
include(CheckLibraryExists)
-include(LLVMCheckCompilerLinkerFlag)
+include(CheckCompilerFlag)
include(CheckSymbolExists)
include(TestBigEndian)
@@ -15,8 +15,8 @@ include(TestBigEndian)
# in tree version of runtimes, we'd be linking against the just-built
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
# built libunwind isn't installed yet). For those cases, it'd be good to
-# link with --uwnindlib=none. Check if that option works.
-llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
+# link with --unwindlib=none. Check if that option works.
+check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
@@ -190,12 +190,12 @@ check_library_exists(c++ __cxa_throw "" COMPILER_RT_HAS_LIBCXX)
check_library_exists(stdc++ __cxa_throw "" COMPILER_RT_HAS_LIBSTDCXX)
# Linker flags.
-llvm_check_compiler_linker_flag(C "-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT)
-llvm_check_compiler_linker_flag(C "-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG)
+check_compiler_flag(C "-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT)
+check_compiler_flag(C "-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG)
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
set(VERS_COMPAT_OPTION "-Wl,-z,gnu-version-script-compat")
- llvm_check_compiler_linker_flag(C "${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
+ check_compiler_flag(C "${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
endif()
set(DUMMY_VERS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/dummy.vers)
@@ -206,10 +206,10 @@ if(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
# -z gnu-version-script-compat.
string(APPEND VERS_OPTION " ${VERS_COMPAT_OPTION}")
endif()
-llvm_check_compiler_linker_flag(C "${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT)
+check_compiler_flag(C "${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT)
if(ANDROID)
- llvm_check_compiler_linker_flag(C "-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL)
+ check_compiler_flag(C "-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL)
check_library_exists(log __android_log_write "" COMPILER_RT_HAS_LIBLOG)
endif()
@@ -481,7 +481,7 @@ if(APPLE)
-lc++
-lc++abi)
- llvm_check_compiler_linker_flag(C "-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION)
+ check_compiler_flag(C "-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION)
if(COMPILER_RT_HAS_APP_EXTENSION)
list(APPEND DARWIN_COMMON_LINK_FLAGS "-fapplication-extension")
endif()
diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 7406fba482e69..a214c17dacdbb 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -1,7 +1,7 @@
include(CMakePushCheckState)
include(CheckLibraryExists)
include(CheckSymbolExists)
-include(LLVMCheckCompilerLinkerFlag)
+include(CheckCompilerFlag)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckCSourceCompiles)
@@ -12,8 +12,8 @@ include(CheckCSourceCompiles)
# LIBCXXABI_USE_LLVM_UNWINDER set, we'd be linking against the just-built
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
# built libunwind isn't installed yet). For those cases, it'd be good to
-# link with --uwnindlib=none. Check if that option works.
-llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
+# link with --unwindlib=none. Check if that option works.
+check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
if (NOT LIBCXX_USE_COMPILER_RT)
if(WIN32 AND NOT MINGW)
diff --git a/libunwind/cmake/config-ix.cmake b/libunwind/cmake/config-ix.cmake
index 126c872f0d489..77bdd5eb5aaf8 100644
--- a/libunwind/cmake/config-ix.cmake
+++ b/libunwind/cmake/config-ix.cmake
@@ -2,14 +2,14 @@ include(CMakePushCheckState)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
-include(LLVMCheckCompilerLinkerFlag)
+include(CheckCompilerFlag)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
# 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.
-llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
+check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
if (HAIKU)
check_library_exists(root fopen "" LIBUNWIND_HAS_ROOT_LIB)
@@ -35,11 +35,11 @@ endif()
# required for the link to go through. We remove sanitizers from the
# configuration checks to avoid spurious link errors.
-llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_compiler_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
else()
- llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
+ check_compiler_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
endif()
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 03f4e1f190fd9..cac5470435d91 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -327,8 +327,8 @@ function(add_link_opts target_name)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
# Support for ld -z discard-unused=sections was only added in
# Solaris 11.4. GNU ld ignores it, but warns every time.
- include(LLVMCheckLinkerFlag)
- llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
+ include(CheckLinkerFlag)
+ check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,discard-unused=sections")
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c5..bdbd36174fc7a 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1061,8 +1061,8 @@ if (LLVM_USE_SPLIT_DWARF AND
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-gsplit-dwarf>)
- include(LLVMCheckLinkerFlag)
- llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
+ include(CheckLinkerFlag)
+ check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
@@ -1083,8 +1083,8 @@ endif()
# lld doesn't print colored diagnostics when invoked from Ninja
if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja")
- include(LLVMCheckLinkerFlag)
- llvm_check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
+ include(CheckLinkerFlag)
+ check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
diff --git a/llvm/cmake/modules/HandleLLVMStdlib.cmake b/llvm/cmake/modules/HandleLLVMStdlib.cmake
index 7afc10cff74ff..a7e138aa0789b 100644
--- a/llvm/cmake/modules/HandleLLVMStdlib.cmake
+++ b/llvm/cmake/modules/HandleLLVMStdlib.cmake
@@ -13,12 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
endfunction()
include(CheckCXXCompilerFlag)
- include(LLVMCheckLinkerFlag)
+ include(CheckLinkerFlag)
set(LLVM_LIBCXX_USED 0)
if(LLVM_ENABLE_LIBCXX)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
- llvm_check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+ check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
append("-stdlib=libc++"
CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
@@ -36,7 +36,7 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-static-libstdc++"
CXX_COMPILER_SUPPORTS_STATIC_STDLIB)
- llvm_check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
+ check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
if(CXX_COMPILER_SUPPORTS_STATIC_STDLIB AND
CXX_LINKER_SUPPORTS_STATIC_STDLIB)
append("-static-libstdc++"
diff --git a/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake b/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
deleted file mode 100644
index e09bbc66f2d26..0000000000000
--- a/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-include(CheckLinkerFlag OPTIONAL)
-
-if (COMMAND check_linker_flag)
- macro(llvm_check_linker_flag)
- check_linker_flag(${ARGN})
- endmacro()
-else()
- # Until the minimum CMAKE version is 3.18
-
- include(CheckCXXCompilerFlag)
-
- # cmake builtin compatible, except we assume lang is C or CXX
- function(llvm_check_linker_flag lang flag out_var)
- cmake_policy(PUSH)
- cmake_policy(SET CMP0056 NEW)
- set(_CMAKE_EXE_LINKER_FLAGS_SAVE ${CMAKE_EXE_LINKER_FLAGS})
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
- if("${lang}" STREQUAL "C")
- check_c_compiler_flag("" ${out_var})
- elseif("${lang}" STREQUAL "CXX")
- check_cxx_compiler_flag("" ${out_var})
- else()
- message(FATAL_ERROR "\"${lang}\" is not C or CXX")
- endif()
- set(CMAKE_EXE_LINKER_FLAGS ${_CMAKE_EXE_LINKER_FLAGS_SAVE})
- cmake_policy(POP)
- endfunction()
-endif()
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index ead2aed414ffe..800a34ccb194a 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -294,9 +294,9 @@ endif()
if(OPENMP_STANDALONE_BUILD OR TARGET omp)
# Check LIBOMP_HAVE_VERSION_SCRIPT_FLAG
- include(LLVMCheckCompilerLinkerFlag)
+ include(CheckCompilerFlag)
if(NOT APPLE)
- 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)
+ check_compiler_flag(C "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/../openmp/runtime/src/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
endif()
endif()
diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake
index 337fe2e599648..ad389e76208ec 100644
--- a/openmp/runtime/cmake/config-ix.cmake
+++ b/openmp/runtime/cmake/config-ix.cmake
@@ -8,6 +8,7 @@
#//===----------------------------------------------------------------------===//
#
+include(CheckCompilerFlag)
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
@@ -17,7 +18,6 @@ include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(LibompCheckFortranFlag)
-include(LLVMCheckCompilerLinkerFlag)
# Check for versioned symbols
function(libomp_check_version_symbols retval)
@@ -128,13 +128,13 @@ check_symbol_exists(_aligned_malloc "malloc.h" LIBOMP_HAVE__ALIGNED_MALLOC)
# Check linker flags
if(WIN32)
- llvm_check_compiler_linker_flag(C /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG)
+ check_compiler_flag(C /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG)
elseif(NOT APPLE)
- llvm_check_compiler_linker_flag(C -Wl,-x LIBOMP_HAVE_X_FLAG)
- llvm_check_compiler_linker_flag(C -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
- llvm_check_compiler_linker_flag(C "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
- llvm_check_compiler_linker_flag(C -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
- llvm_check_compiler_linker_flag(C -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
+ check_compiler_flag(C -Wl,-x LIBOMP_HAVE_X_FLAG)
+ check_compiler_flag(C -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
+ check_compiler_flag(C "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
+ check_compiler_flag(C -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
+ check_compiler_flag(C -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
endif()
# 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
check_cxx_compiler_flag(-Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG)
check_cxx_compiler_flag(-falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG)
check_cxx_compiler_flag("-opt-streaming-stores never" LIBOMP_HAVE_OPT_STREAMING_STORES_FLAG)
- llvm_check_compiler_linker_flag(C -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG)
- llvm_check_compiler_linker_flag(C -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)
+ check_compiler_flag(C -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG)
+ check_compiler_flag(C -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)
check_library_exists(irc_pic _intel_fast_memcpy "" LIBOMP_HAVE_IRC_PIC_LIBRARY)
endif()
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 24f4851169591..da7650ce65da7 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -79,7 +79,7 @@ set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
set(LLVM_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
include(CheckLibraryExists)
-include(LLVMCheckCompilerLinkerFlag)
+include(CheckCompilerFlag)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
@@ -114,7 +114,7 @@ filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} C
# 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)
+check_compiler_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")
@@ -143,7 +143,7 @@ endif()
# Check for -nostdlib++ first; if there's no C++ standard library yet,
# all check_cxx_compiler_flag commands will fail until we add -nostdlib++
# (or -nodefaultlibs).
-llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_compiler_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
endif()
|
@llvm/pr-subscribers-clang Author: None (h-vetinari) ChangesBroken out from #93429 Somewhat closing the loop opened by 7017e6c Full diff: https://github.com/llvm/llvm-project/pull/96171.diff 12 Files Affected:
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index 290bf2a42536d..018605c2fd4f2 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -107,7 +107,7 @@ endif()
if(CLANG_ORDER_FILE AND
(LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
- include(LLVMCheckLinkerFlag)
+ include(CheckLinkerFlag)
if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
@@ -118,7 +118,7 @@ if(CLANG_ORDER_FILE AND
endif()
# This is a test to ensure the actual order file works with the linker.
- llvm_check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
+ check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
# Passing an empty order file disables some linker layout optimizations.
# To work around this and enable workflows for re-linking when the order file
diff --git a/cmake/Modules/LLVMCheckCompilerLinkerFlag.cmake b/cmake/Modules/LLVMCheckCompilerLinkerFlag.cmake
deleted file mode 100644
index f61ec0585f9a4..0000000000000
--- a/cmake/Modules/LLVMCheckCompilerLinkerFlag.cmake
+++ /dev/null
@@ -1,35 +0,0 @@
-include(CMakePushCheckState)
-
-include(CheckCompilerFlag OPTIONAL)
-
-if(NOT COMMAND check_compiler_flag)
- include(CheckCCompilerFlag)
- include(CheckCXXCompilerFlag)
-endif()
-
-function(llvm_check_compiler_linker_flag lang flag out_var)
- # If testing a flag with check_c_compiler_flag, it gets added to the compile
- # command only, but not to the linker command in that test. If the flag
- # is vital for linking to succeed, the test would fail even if it would
- # have succeeded if it was included on both commands.
- #
- # Therefore, try adding the flag to CMAKE_REQUIRED_FLAGS, which gets
- # added to both compiling and linking commands in the tests.
-
- cmake_push_check_state()
- set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
- if(COMMAND check_compiler_flag)
- check_compiler_flag("${lang}" "" ${out_var})
- else()
- # Until the minimum CMAKE version is 3.19
- # cmake builtin compatible, except we assume lang is C or CXX
- if("${lang}" STREQUAL "C")
- check_c_compiler_flag("" ${out_var})
- elseif("${lang}" STREQUAL "CXX")
- check_cxx_compiler_flag("" ${out_var})
- else()
- message(FATAL_ERROR "\"${lang}\" is not C or CXX")
- endif()
- endif()
- cmake_pop_check_state()
-endfunction()
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 75e4d3677703a..e90e95438c069 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -5,7 +5,7 @@ include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckIncludeFiles)
include(CheckLibraryExists)
-include(LLVMCheckCompilerLinkerFlag)
+include(CheckCompilerFlag)
include(CheckSymbolExists)
include(TestBigEndian)
@@ -15,8 +15,8 @@ include(TestBigEndian)
# in tree version of runtimes, we'd be linking against the just-built
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
# built libunwind isn't installed yet). For those cases, it'd be good to
-# link with --uwnindlib=none. Check if that option works.
-llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
+# link with --unwindlib=none. Check if that option works.
+check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_NONE_FLAG)
check_library_exists(c fopen "" COMPILER_RT_HAS_LIBC)
if (COMPILER_RT_USE_BUILTINS_LIBRARY)
@@ -190,12 +190,12 @@ check_library_exists(c++ __cxa_throw "" COMPILER_RT_HAS_LIBCXX)
check_library_exists(stdc++ __cxa_throw "" COMPILER_RT_HAS_LIBSTDCXX)
# Linker flags.
-llvm_check_compiler_linker_flag(C "-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT)
-llvm_check_compiler_linker_flag(C "-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG)
+check_compiler_flag(C "-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT)
+check_compiler_flag(C "-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG)
if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
set(VERS_COMPAT_OPTION "-Wl,-z,gnu-version-script-compat")
- llvm_check_compiler_linker_flag(C "${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
+ check_compiler_flag(C "${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
endif()
set(DUMMY_VERS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/dummy.vers)
@@ -206,10 +206,10 @@ if(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
# -z gnu-version-script-compat.
string(APPEND VERS_OPTION " ${VERS_COMPAT_OPTION}")
endif()
-llvm_check_compiler_linker_flag(C "${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT)
+check_compiler_flag(C "${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT)
if(ANDROID)
- llvm_check_compiler_linker_flag(C "-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL)
+ check_compiler_flag(C "-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL)
check_library_exists(log __android_log_write "" COMPILER_RT_HAS_LIBLOG)
endif()
@@ -481,7 +481,7 @@ if(APPLE)
-lc++
-lc++abi)
- llvm_check_compiler_linker_flag(C "-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION)
+ check_compiler_flag(C "-fapplication-extension" COMPILER_RT_HAS_APP_EXTENSION)
if(COMPILER_RT_HAS_APP_EXTENSION)
list(APPEND DARWIN_COMMON_LINK_FLAGS "-fapplication-extension")
endif()
diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 7406fba482e69..a214c17dacdbb 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -1,7 +1,7 @@
include(CMakePushCheckState)
include(CheckLibraryExists)
include(CheckSymbolExists)
-include(LLVMCheckCompilerLinkerFlag)
+include(CheckCompilerFlag)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckCSourceCompiles)
@@ -12,8 +12,8 @@ include(CheckCSourceCompiles)
# LIBCXXABI_USE_LLVM_UNWINDER set, we'd be linking against the just-built
# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly
# built libunwind isn't installed yet). For those cases, it'd be good to
-# link with --uwnindlib=none. Check if that option works.
-llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
+# link with --unwindlib=none. Check if that option works.
+check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
if (NOT LIBCXX_USE_COMPILER_RT)
if(WIN32 AND NOT MINGW)
diff --git a/libunwind/cmake/config-ix.cmake b/libunwind/cmake/config-ix.cmake
index 126c872f0d489..77bdd5eb5aaf8 100644
--- a/libunwind/cmake/config-ix.cmake
+++ b/libunwind/cmake/config-ix.cmake
@@ -2,14 +2,14 @@ include(CMakePushCheckState)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
-include(LLVMCheckCompilerLinkerFlag)
+include(CheckCompilerFlag)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
# 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.
-llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
+check_compiler_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
if (HAIKU)
check_library_exists(root fopen "" LIBUNWIND_HAS_ROOT_LIB)
@@ -35,11 +35,11 @@ endif()
# required for the link to go through. We remove sanitizers from the
# configuration checks to avoid spurious link errors.
-llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_compiler_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
else()
- llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
+ check_compiler_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
endif()
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 03f4e1f190fd9..cac5470435d91 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -327,8 +327,8 @@ function(add_link_opts target_name)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
# Support for ld -z discard-unused=sections was only added in
# Solaris 11.4. GNU ld ignores it, but warns every time.
- include(LLVMCheckLinkerFlag)
- llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
+ include(CheckLinkerFlag)
+ check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,discard-unused=sections")
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c5..bdbd36174fc7a 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1061,8 +1061,8 @@ if (LLVM_USE_SPLIT_DWARF AND
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-gsplit-dwarf>)
- include(LLVMCheckLinkerFlag)
- llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
+ include(CheckLinkerFlag)
+ check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
@@ -1083,8 +1083,8 @@ endif()
# lld doesn't print colored diagnostics when invoked from Ninja
if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja")
- include(LLVMCheckLinkerFlag)
- llvm_check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
+ include(CheckLinkerFlag)
+ check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
endif()
diff --git a/llvm/cmake/modules/HandleLLVMStdlib.cmake b/llvm/cmake/modules/HandleLLVMStdlib.cmake
index 7afc10cff74ff..a7e138aa0789b 100644
--- a/llvm/cmake/modules/HandleLLVMStdlib.cmake
+++ b/llvm/cmake/modules/HandleLLVMStdlib.cmake
@@ -13,12 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
endfunction()
include(CheckCXXCompilerFlag)
- include(LLVMCheckLinkerFlag)
+ include(CheckLinkerFlag)
set(LLVM_LIBCXX_USED 0)
if(LLVM_ENABLE_LIBCXX)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
- llvm_check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+ check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
append("-stdlib=libc++"
CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
@@ -36,7 +36,7 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-static-libstdc++"
CXX_COMPILER_SUPPORTS_STATIC_STDLIB)
- llvm_check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
+ check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
if(CXX_COMPILER_SUPPORTS_STATIC_STDLIB AND
CXX_LINKER_SUPPORTS_STATIC_STDLIB)
append("-static-libstdc++"
diff --git a/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake b/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
deleted file mode 100644
index e09bbc66f2d26..0000000000000
--- a/llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-include(CheckLinkerFlag OPTIONAL)
-
-if (COMMAND check_linker_flag)
- macro(llvm_check_linker_flag)
- check_linker_flag(${ARGN})
- endmacro()
-else()
- # Until the minimum CMAKE version is 3.18
-
- include(CheckCXXCompilerFlag)
-
- # cmake builtin compatible, except we assume lang is C or CXX
- function(llvm_check_linker_flag lang flag out_var)
- cmake_policy(PUSH)
- cmake_policy(SET CMP0056 NEW)
- set(_CMAKE_EXE_LINKER_FLAGS_SAVE ${CMAKE_EXE_LINKER_FLAGS})
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
- if("${lang}" STREQUAL "C")
- check_c_compiler_flag("" ${out_var})
- elseif("${lang}" STREQUAL "CXX")
- check_cxx_compiler_flag("" ${out_var})
- else()
- message(FATAL_ERROR "\"${lang}\" is not C or CXX")
- endif()
- set(CMAKE_EXE_LINKER_FLAGS ${_CMAKE_EXE_LINKER_FLAGS_SAVE})
- cmake_policy(POP)
- endfunction()
-endif()
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index ead2aed414ffe..800a34ccb194a 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -294,9 +294,9 @@ endif()
if(OPENMP_STANDALONE_BUILD OR TARGET omp)
# Check LIBOMP_HAVE_VERSION_SCRIPT_FLAG
- include(LLVMCheckCompilerLinkerFlag)
+ include(CheckCompilerFlag)
if(NOT APPLE)
- 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)
+ check_compiler_flag(C "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/../openmp/runtime/src/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
endif()
endif()
diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake
index 337fe2e599648..ad389e76208ec 100644
--- a/openmp/runtime/cmake/config-ix.cmake
+++ b/openmp/runtime/cmake/config-ix.cmake
@@ -8,6 +8,7 @@
#//===----------------------------------------------------------------------===//
#
+include(CheckCompilerFlag)
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
@@ -17,7 +18,6 @@ include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(LibompCheckFortranFlag)
-include(LLVMCheckCompilerLinkerFlag)
# Check for versioned symbols
function(libomp_check_version_symbols retval)
@@ -128,13 +128,13 @@ check_symbol_exists(_aligned_malloc "malloc.h" LIBOMP_HAVE__ALIGNED_MALLOC)
# Check linker flags
if(WIN32)
- llvm_check_compiler_linker_flag(C /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG)
+ check_compiler_flag(C /SAFESEH LIBOMP_HAVE_SAFESEH_FLAG)
elseif(NOT APPLE)
- llvm_check_compiler_linker_flag(C -Wl,-x LIBOMP_HAVE_X_FLAG)
- llvm_check_compiler_linker_flag(C -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
- llvm_check_compiler_linker_flag(C "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
- llvm_check_compiler_linker_flag(C -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
- llvm_check_compiler_linker_flag(C -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
+ check_compiler_flag(C -Wl,-x LIBOMP_HAVE_X_FLAG)
+ check_compiler_flag(C -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
+ check_compiler_flag(C "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
+ check_compiler_flag(C -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
+ check_compiler_flag(C -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
endif()
# 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
check_cxx_compiler_flag(-Qoption,cpp,--extended_float_types LIBOMP_HAVE_EXTENDED_FLOAT_TYPES_FLAG)
check_cxx_compiler_flag(-falign-stack=maintain-16-byte LIBOMP_HAVE_FALIGN_STACK_FLAG)
check_cxx_compiler_flag("-opt-streaming-stores never" LIBOMP_HAVE_OPT_STREAMING_STORES_FLAG)
- llvm_check_compiler_linker_flag(C -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG)
- llvm_check_compiler_linker_flag(C -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)
+ check_compiler_flag(C -static-intel LIBOMP_HAVE_STATIC_INTEL_FLAG)
+ check_compiler_flag(C -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)
check_library_exists(irc_pic _intel_fast_memcpy "" LIBOMP_HAVE_IRC_PIC_LIBRARY)
endif()
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 24f4851169591..da7650ce65da7 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -79,7 +79,7 @@ set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
set(LLVM_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
include(CheckLibraryExists)
-include(LLVMCheckCompilerLinkerFlag)
+include(CheckCompilerFlag)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
@@ -114,7 +114,7 @@ filter_prefixed("${CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES}" ${LLVM_BINARY_DIR} C
# 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)
+check_compiler_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")
@@ -143,7 +143,7 @@ endif()
# Check for -nostdlib++ first; if there's no C++ standard library yet,
# all check_cxx_compiler_flag commands will fail until we add -nostdlib++
# (or -nodefaultlibs).
-llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_compiler_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
endif()
|
Here's a radical question, do we really want to use CMake's support for this? I remember a discussion recently about the increasingly large amount of time spent in the CMake configuration step, and most of that time is spent during these flag checks which pretty much all compile + link some file with no parallelism. I've also had issues working with these flags when trying to cross-compile things for the GPU, namely because the compilation flags insist on checking the linker so I need to do something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a radical question, do we really want to use CMake's support for this?
I think this is a fair question in the big picture, but the current state of the code is already using CMake for that (see below) - I'm just removing the fallbacks for old CMake versions.
IMO this PR should stay a trivial clean-up, and any other flag-check-refactorings should come on top.
if(COMMAND check_compiler_flag) | ||
check_compiler_flag("${lang}" "" ${out_var}) | ||
else() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see here...
if (COMMAND check_linker_flag) | ||
macro(llvm_check_linker_flag) | ||
check_linker_flag(${ARGN}) | ||
endmacro() | ||
else() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and here
The Bootstraping build seems to be failing with a real error: https://github.com/llvm/llvm-project/actions/runs/9596576098/job/26465655299?pr=96171 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I believe the CMake minimum version supports this, I don't see why we shouldn't submit this cleanup. Whether to change the flag detection logic can be a separate discussion IMO.
Yeah I think this is a great cleanup, I think we just need to fix the CI issues. |
The failing tests here previously were clearly unrelated (missing python module
CI hasn't finished yet, so there may be others things hiding still, but I don't consider it realistic (to be caused by the changes here). The code before/after this PR should work exactly as before, we're just stripping the fallbacks for old CMake. |
Failing bootstrap build still has:
which is clearly unrelated to this PR. |
@h-vetinari This one still looks like a real issue: https://buildkite.com/llvm-project/github-pull-requests/builds/74912#01903ca1-8089-4388-afdb-b65d400e6315 The rest looks good indeed. |
I think that was the last one. :) |
I'm sorry to be the bearer of bad news, but it looks like Android is failing with this patch: https://buildkite.com/llvm-project/libcxx-ci/builds/35981#01905269-56a0-4314-a350-0b99ece37e89 This is kinda weird, it fails due to the ABI list changing. I checked other recent executions on Android and it doesn't look spurious. @rprichard is responsible for the Android CI bot and may be able to help. |
Sorry, I didn't notice the ping until just now. The CMake feature testing seems broken, on Android at least. Here's a representative error from
It's trying to see if It seems that the Android support in the Dockerfile is broken after a refactor last year. I have some changes that get it working again. BuildKite is still successfully running Android tests as of today, so I think it's using an old image. |
I was waiting for your recent PRs to land, but the android failures seem to persist even after them. |
Yeah that's also what I noticed. My PRs were aimed at getting the Android Dockerfile buildable again, but once it was buildable, the feature testing failed. It seemed that after this PR, the CMake feature test for a flag My suspicion was that this PR broke CMake feature testing for any cross-compiled configurations. |
This check in libcxx/cmake/config-ix.cmake seems to break:
It appears that it isn't passing either It seems that the older function had been dealing with this:
It sounds like the right fix is to use |
This particular check was already using Not sure how the runtimes build influences the libcxx/libcxxabi builds. It feels like |
The previous If we just want to do a cleanup, then include(CMakePushCheckState)
include(CheckCompilerFlag)
function(llvm_check_compiler_linker_flag lang flag out_var)
# If testing a flag with check_compiler_flag, it gets added to the compile
# command only, but not to the linker command in that test. If the flag
# is vital for linking to succeed, the test would fail even if it would
# have succeeded if it was included on both commands.
#
# Therefore, try adding the flag to CMAKE_REQUIRED_FLAGS, which gets
# added to both compiling and linking commands in the tests.
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
check_compiler_flag("${lang}" "" ${out_var})
cmake_pop_check_state()
endfunction() Almost all the uses of There were a few flags that I wasn't familiar with, so maybe they could be
Ignoring those cases, the Android tests pass with this PR after switching |
I rebased the changes so I could review them, 640d2e6. The compiler-rt/cmake/config-ix.cmake file is still removing |
The github UI should show all changes to main? Not sure why a rebase would be necessary...?
That's because it is included twice (see first & last line below): llvm-project/compiler-rt/cmake/config-ix.cmake Lines 3 to 8 in 8dd5742
|
If you're interested in everything but the first commit, the GH UI can do that too (there's a dropdown in the upper lefthand corner): |
Sorry, you're right. (Not sure why I didn't notice that before.) The change looks good to me now. |
…inkerFlag.cmake now that CMake baseline has moved past 3.18; see https://cmake.org/cmake/help/latest/module/CheckLinkerFlag.html
…kCompilerLinkerFlag.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]>
This should be good now I think. Does someone want to approve/merge @ldionne @arichardson et al.? |
This patch broke the Solaris/amd64 and Solaris/sparcv9 buildbots. |
Follow-up to #96171 in an attempt to fix the Solaris bots.
Both bots are working again: thanks for the quick fix. |
…#96171) Broken out from llvm#93429 Somewhat closing the loop opened by 7017e6c. Co-authored-by: Ryan Prichard <[email protected]>
Follow-up to llvm#96171 in an attempt to fix the Solaris bots.
…#96171) Broken out from llvm#93429 Somewhat closing the loop opened by 7017e6c. Co-authored-by: Ryan Prichard <[email protected]>
Follow-up to llvm#96171 in an attempt to fix the Solaris bots.
Broken out from #93429
Somewhat closing the loop opened by 7017e6c