diff options
author | Bob Haarman <llvm@inglorion.net> | 2017-03-21 18:25:35 +0000 |
---|---|---|
committer | Bob Haarman <llvm@inglorion.net> | 2017-03-21 18:25:35 +0000 |
commit | ba802a4235ecdadc45278718b861d54efc07c626 (patch) | |
tree | b4e3558f473573230b94d276b4f2db467bbf0205 /cmake | |
parent | 7ea40255820c1b7fbc45e05e99351c9c667e6624 (diff) |
[compiler-rt] respect CMAKE_EXE_LINKER_FLAGS in compiler and library tests
Summary: check_cxx_compiler_flag and check_library_exists could fail because they ignored CMAKE_EXE_LINKER_FLAGS and therefore would always fail to produce executables. Cmake policy CMP0056 fixes this, but was explicitly set to OLD in our CMakeLists because it caused problems with test_target_arch. This change sets the policy to NEW to fix the problem with the compiler and library tests, and temporarily clears CMAKE_EXE_LINKER_FLAGS inside test_target_arch to emulate the old behavior there. This allows, for example, LTO builds that require lld to succeed.
Reviewers: davidxl, beanz
Reviewed By: beanz
Subscribers: fjricci, dberris, mgorny, mehdi_amini, tejohnson, rnk, llvm-commits
Differential Revision: https://reviews.llvm.org/D31098
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298413 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Modules/CompilerRTDarwinUtils.cmake | 4 | ||||
-rw-r--r-- | cmake/Modules/CompilerRTUtils.cmake | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/cmake/Modules/CompilerRTDarwinUtils.cmake b/cmake/Modules/CompilerRTDarwinUtils.cmake index 3c89381f9..baea4a067 100644 --- a/cmake/Modules/CompilerRTDarwinUtils.cmake +++ b/cmake/Modules/CompilerRTDarwinUtils.cmake @@ -85,10 +85,12 @@ function(darwin_test_archs os valid_archs) if(TEST_COMPILE_ONLY) try_compile_only(CAN_TARGET_${os}_${arch} -v -arch ${arch} ${DARWIN_${os}_CFLAGS}) else() + set(SAVED_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${arch_linker_flags}") try_compile(CAN_TARGET_${os}_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_C} COMPILE_DEFINITIONS "-v -arch ${arch}" ${DARWIN_${os}_CFLAGS} - CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${arch_linker_flags}" OUTPUT_VARIABLE TEST_OUTPUT) + set(CMAKE_EXE_LINKER_FLAGS ${SAVED_CMAKE_EXE_LINKER_FLAGS}) endif() if(${CAN_TARGET_${os}_${arch}}) list(APPEND working_archs ${arch}) diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake index ed946d88f..3b3a0c153 100644 --- a/cmake/Modules/CompilerRTUtils.cmake +++ b/cmake/Modules/CompilerRTUtils.cmake @@ -138,15 +138,16 @@ macro(test_target_arch arch def) elseif(TEST_COMPILE_ONLY) try_compile_only(CAN_TARGET_${arch} ${TARGET_${arch}_CFLAGS}) else() - set(argstring "${CMAKE_EXE_LINKER_FLAGS} ${argstring}") set(FLAG_NO_EXCEPTIONS "") if(COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG) set(FLAG_NO_EXCEPTIONS " -fno-exceptions ") endif() + set(SAVED_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${argstring}") try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE} COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS} ${FLAG_NO_EXCEPTIONS}" - OUTPUT_VARIABLE TARGET_${arch}_OUTPUT - CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${argstring}") + OUTPUT_VARIABLE TARGET_${arch}_OUTPUT) + set(CMAKE_EXE_LINKER_FLAGS ${SAVED_CMAKE_EXE_LINKER_FLAGS}) endif() endif() if(${CAN_TARGET_${arch}}) |