summaryrefslogtreecommitdiff
path: root/cmake/Modules/CompilerRTUtils.cmake
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-09-20 21:36:30 +0000
committerChris Bieneman <beanz@apple.com>2016-09-20 21:36:30 +0000
commit689eed357618ee8e7d8407a9eba32e5c5a0a9cf9 (patch)
tree661bf106c521bb96dd7cf8c74f7cdc548e878a33 /cmake/Modules/CompilerRTUtils.cmake
parent265ea62bee1e61d0ff45b390129b715d8ebb24c3 (diff)
[CMake] Explicitly add --target option to compiler flags
Summary: Much of the non-Darwin build system assumes that COMPILER_RT_DEFAULT_TARGET_TRIPLE is the default target triple for the compiler being used. With clang as your compiler this isn't necessarily true. To ensure that the rest of the build system behaves as expected this patch adds "--target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE}" to the compiler flags for C, CXX and ASM sources. Reviewers: compnerd, rengolin, fjricci Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24156 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282024 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules/CompilerRTUtils.cmake')
-rw-r--r--cmake/Modules/CompilerRTUtils.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
index ba2a7bcfc..e57a93e78 100644
--- a/cmake/Modules/CompilerRTUtils.cmake
+++ b/cmake/Modules/CompilerRTUtils.cmake
@@ -227,6 +227,18 @@ macro(construct_compiler_rt_default_triple)
set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${COMPILER_RT_TEST_TARGET_TRIPLE})
endif()
+ if(NOT APPLE)
+ # Much of the non-darwin compiler-rt build assumes that
+ # COMPILER_RT_DEFAULT_TARGET_TRIPLE is the default target of the compiler
+ # being used. That isn't always a safe assumption, but adding this here
+ # makes it all work.
+ # This doesn't prevent needing to set CMAKE_<LANG>_COMPILER_TARGET in some
+ # situations, so YMMV.
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE}")
+ set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} --target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE}")
+ endif()
+
string(REPLACE "-" ";" TARGET_TRIPLE_LIST ${COMPILER_RT_DEFAULT_TARGET_TRIPLE})
list(GET TARGET_TRIPLE_LIST 0 COMPILER_RT_DEFAULT_TARGET_ARCH)
list(GET TARGET_TRIPLE_LIST 1 COMPILER_RT_DEFAULT_TARGET_OS)