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

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 14:45:17 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL282024: [CMake] Explicitly add --target option to compiler flags (authored by cbieneman).

Changed prior to commit:
  https://reviews.llvm.org/D24156?vs=70068&id=71989#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24156

Files:
  compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake

Index: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
===================================================================
--- compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake
@@ -227,6 +227,18 @@
     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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24156.71989.patch
Type: text/x-patch
Size: 1226 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160920/5dc8eeb1/attachment.bin>


More information about the llvm-commits mailing list