[compiler-rt] 853b5cb - [compiler-rt][CMAKE] Only add cmake link flags in standalone build
Jinsong Ji via llvm-commits
llvm-commits at lists.llvm.org
Fri May 15 11:27:09 PDT 2020
Author: Jinsong Ji
Date: 2020-05-15T18:25:39Z
New Revision: 853b5cbadc22476a73e31f07884a1bdb352b6260
URL: https://github.com/llvm/llvm-project/commit/853b5cbadc22476a73e31f07884a1bdb352b6260
DIFF: https://github.com/llvm/llvm-project/commit/853b5cbadc22476a73e31f07884a1bdb352b6260.diff
LOG: [compiler-rt][CMAKE] Only add cmake link flags in standalone build
Only add CMAKE_EXE_LINKER_FLAGS when in a standalone bulid.
Or else CMAKE_EXE_LINKER_FLAGS contains flags for build compiler of Clang/llvm.
This might not be the same as what the COMPILER_RT_TEST_COMPILER supports.
eg: the build compiler use lld linker and we use it to build clang with
default ld linker then to be tested clang will complain about lld
options like --color-diagnostics.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D78373
Added:
Modified:
compiler-rt/cmake/Modules/AddCompilerRT.cmake
Removed:
################################################################################
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 83a972d443b2..50611d6d608e 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -482,7 +482,13 @@ function(add_compiler_rt_test test_suite test_name arch)
# trump. With MSVC we can't do that because CMake is set up to run link.exe
# when linking, not the compiler. Here, we hack it to use the compiler
# because we want to use -fsanitize flags.
- if(NOT MSVC)
+
+ # Only add CMAKE_EXE_LINKER_FLAGS when in a standalone bulid.
+ # Or else CMAKE_EXE_LINKER_FLAGS contains flags for build compiler of Clang/llvm.
+ # This might not be the same as what the COMPILER_RT_TEST_COMPILER supports.
+ # eg: the build compiler use lld linker and we build clang with default ld linker
+ # then to be tested clang will complain about lld options like --color-diagnostics.
+ if(NOT MSVC AND COMPILER_RT_STANDALONE_BUILD)
set(TEST_LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TEST_LINK_FLAGS}")
separate_arguments(TEST_LINK_FLAGS)
endif()
More information about the llvm-commits
mailing list