[PATCH] D24156: [CMake] Explicitly add --target option to compiler flags

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 14:20:10 PDT 2016


beanz created this revision.
beanz added reviewers: compnerd, rengolin, fjricci.
beanz added a subscriber: llvm-commits.

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.

https://reviews.llvm.org/D24156

Files:
  cmake/Modules/CompilerRTUtils.cmake

Index: cmake/Modules/CompilerRTUtils.cmake
===================================================================
--- cmake/Modules/CompilerRTUtils.cmake
+++ cmake/Modules/CompilerRTUtils.cmake
@@ -222,6 +222,16 @@
     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.
+    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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24156.70068.patch
Type: text/x-patch
Size: 1064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160901/769651e3/attachment.bin>


More information about the llvm-commits mailing list