[PATCH] D22387: [compiler-rt] Update compiler-rt for cross-compilation with multiple architectures

Francis Ricci via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 15:39:06 PDT 2016


fjricci created this revision.
fjricci added reviewers: compnerd, beanz, tberghammer, srhines, danalbert.
fjricci added a subscriber: llvm-commits.
Herald added subscribers: dschuff, danalbert, jfb, tberghammer.

This allows for building compiler-rt to target multiple android
architectures, by using a set of -DTARGET_<arch>_CFLAGS cmake arguments.

https://reviews.llvm.org/D22387

Files:
  cmake/Modules/CompilerRTUtils.cmake
  lib/builtins/CMakeLists.txt

Index: lib/builtins/CMakeLists.txt
===================================================================
--- lib/builtins/CMakeLists.txt
+++ lib/builtins/CMakeLists.txt
@@ -408,11 +408,13 @@
         endif ()
       endforeach ()
 
+      string(TOUPPER ${arch} arch_upper)
+      set(TARGET_CFLAGS "${TARGET_${arch_upper}_CFLAGS}")
       add_compiler_rt_runtime(clang_rt.builtins
                               STATIC
                               ARCHS ${arch}
                               SOURCES ${${arch}_SOURCES}
-                              CFLAGS ${maybe_stdc99}
+                              CFLAGS ${maybe_stdc99} ${TARGET_CFLAGS}
                               PARENT_TARGET builtins)
     endif ()
   endforeach ()
Index: cmake/Modules/CompilerRTUtils.cmake
===================================================================
--- cmake/Modules/CompilerRTUtils.cmake
+++ cmake/Modules/CompilerRTUtils.cmake
@@ -134,35 +134,15 @@
 endmacro()
 
 macro(detect_target_arch)
-  check_symbol_exists(__arm__ "" __ARM)
-  check_symbol_exists(__aarch64__ "" __AARCH64)
-  check_symbol_exists(__x86_64__ "" __X86_64)
-  check_symbol_exists(__i686__ "" __I686)
-  check_symbol_exists(__i386__ "" __I386)
-  check_symbol_exists(__mips__ "" __MIPS)
-  check_symbol_exists(__mips64__ "" __MIPS64)
-  check_symbol_exists(__s390x__ "" __S390X)
-  check_symbol_exists(__wasm32__ "" __WEBASSEMBLY32)
-  check_symbol_exists(__wasm64__ "" __WEBASSEMBLY64)
-  if(__ARM)
-    add_default_target_arch(arm)
-  elseif(__AARCH64)
-    add_default_target_arch(aarch64)
-  elseif(__X86_64)
-    add_default_target_arch(x86_64)
-  elseif(__I686)
-    add_default_target_arch(i686)
-  elseif(__I386)
-    add_default_target_arch(i386)
-  elseif(__MIPS64) # must be checked before __MIPS
-    add_default_target_arch(mips64)
-  elseif(__MIPS)
-    add_default_target_arch(mips)
-  elseif(__S390X)
-    add_default_target_arch(s390x)
-  elseif(__WEBASSEMBLY32)
-    add_default_target_arch(wasm32)
-  elseif(__WEBASSEMBLY64)
-    add_default_target_arch(wasm64)
-  endif()
+  set(SAVED_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+  foreach(arch arm;aarch64;x86_64;i686;mips;mips64;s390x;wasm32;wasm64)
+    string(TOUPPER ${arch} arch_upper)
+    set(TARGET_CFLAGS "${TARGET_${arch_upper}_CFLAGS}")
+    set(CMAKE_REQUIRED_FLAGS "${SAVED_CMAKE_REQUIRED_FLAGS} ${TARGET_CFLAGS}")
+    check_symbol_exists(__${arch}__ "" __${arch_upper})
+    if(__${arch_upper})
+      add_default_target_arch("${arch}")
+    endif()
+  endforeach()
+  set(CMAKE_REQUIRED_FLAGS "${SAVED_CMAKE_REQUIRED_FLAGS}")
 endmacro()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22387.64059.patch
Type: text/x-patch
Size: 2594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160714/14124858/attachment.bin>


More information about the llvm-commits mailing list