mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-01 01:31:26 +00:00
[CMake][llvm] avoid conflict w/ (and use when available) new builtin check_linker_flag
Match the API for the new check_linker_flag and use it directly when available, leaving the old code as a fallback. Differential Revision: https://reviews.llvm.org/D100901
This commit is contained in:
parent
412437aec0
commit
06d06f2f64
@ -93,7 +93,7 @@ endif()
|
||||
|
||||
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}")
|
||||
@ -104,7 +104,7 @@ if(CLANG_ORDER_FILE AND
|
||||
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
|
||||
|
@ -236,8 +236,8 @@ function(add_link_opts target_name)
|
||||
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")
|
||||
|
@ -1,6 +0,0 @@
|
||||
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()
|
@ -888,8 +888,8 @@ endif()
|
||||
|
||||
# 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()
|
||||
|
@ -13,12 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
|
||||
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
|
||||
@ -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)
|
||||
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++"
|
||||
|
17
llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
Normal file
17
llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
Normal file
@ -0,0 +1,17 @@
|
||||
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()
|
Loading…
Reference in New Issue
Block a user