if(CLANG_ORDER_FILE AND
(LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
- include(CheckLinkerFlag)
+ include(LLVMCheckLinkerFlag)
if (LLVM_LINKER_IS_LD64)
set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
endif()
# This is a test to ensure the actual order file works with the linker.
- check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
+ llvm_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
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
# Support for ld -z discard-unused=sections was only added in
# Solaris 11.4.
- include(CheckLinkerFlag)
- check_linker_flag("-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
+ include(LLVMCheckLinkerFlag)
+ llvm_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")
+++ /dev/null
-include(CheckCXXCompilerFlag)
-
-function(check_linker_flag flag out_var)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
- check_cxx_compiler_flag("" ${out_var})
-endfunction()
# lld doesn't print colored diagnostics when invoked from Ninja
if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
- include(CheckLinkerFlag)
- check_linker_flag("-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
+ include(LLVMCheckLinkerFlag)
+ llvm_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()
endfunction()
include(CheckCXXCompilerFlag)
- include(CheckLinkerFlag)
+ include(LLVMCheckLinkerFlag)
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)
- check_linker_flag("-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+ llvm_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
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
check_cxx_compiler_flag("-static-libstdc++"
CXX_COMPILER_SUPPORTS_STATIC_STDLIB)
- check_linker_flag("-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
+ llvm_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++"
--- /dev/null
+include(CheckLinkerFlag OPTIONAL)
+
+if (COMMAND check_linker_flag)
+ macro(llvm_check_linker_flag)
+ check_linker_flag(${ARGN})
+ endmacro()
+else()
+ include(CheckCXXCompilerFlag)
+
+ # cmake builtin compatible, except we assume lang is CXX
+ function(llvm_check_linker_flag lang flag out_var)
+ cmake_push_check_state()
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
+ check_cxx_compiler_flag("" ${out_var})
+ cmake_pop_check_state()
+ endfunction()
+endif()