[compiler-rt] bef00b2 - Revert "[compiler-rt][Android] Stop using detect_target_arch"

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 15:05:48 PDT 2020


Author: Arthur Eubanks
Date: 2020-07-14T15:05:26-07:00
New Revision: bef00b244c3140558c574cc106771b0f2452ef84

URL: https://github.com/llvm/llvm-project/commit/bef00b244c3140558c574cc106771b0f2452ef84
DIFF: https://github.com/llvm/llvm-project/commit/bef00b244c3140558c574cc106771b0f2452ef84.diff

LOG: Revert "[compiler-rt][Android] Stop using detect_target_arch"

This reverts commit 9b7e24c2a5b32e25b773bc8b4ca84dbda995d959.

See comments in https://reviews.llvm.org/D82148.

Added: 
    

Modified: 
    compiler-rt/cmake/Modules/CompilerRTUtils.cmake
    compiler-rt/cmake/base-config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index 107a475d6a0e..99b9f0e4af44 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -151,6 +151,61 @@ macro(test_target_arch arch def)
   endif()
 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(__i386__ "" __I386)
+  check_symbol_exists(__mips__ "" __MIPS)
+  check_symbol_exists(__mips64__ "" __MIPS64)
+  check_symbol_exists(__powerpc64__ "" __PPC64)
+  check_symbol_exists(__powerpc64le__ "" __PPC64LE)
+  check_symbol_exists(__riscv "" __RISCV)
+  check_symbol_exists(__s390x__ "" __S390X)
+  check_symbol_exists(__sparc "" __SPARC)
+  check_symbol_exists(__sparcv9 "" __SPARCV9)
+  check_symbol_exists(__wasm32__ "" __WEBASSEMBLY32)
+  check_symbol_exists(__wasm64__ "" __WEBASSEMBLY64)
+  check_symbol_exists(__ve__ "" __VE)
+  if(__ARM)
+    add_default_target_arch(arm)
+  elseif(__AARCH64)
+    add_default_target_arch(aarch64)
+  elseif(__X86_64)
+    add_default_target_arch(x86_64)
+  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(__PPC64)
+    add_default_target_arch(powerpc64)
+  elseif(__PPC64LE)
+    add_default_target_arch(powerpc64le)
+  elseif(__RISCV)
+    if(CMAKE_SIZEOF_VOID_P EQUAL "4")
+      add_default_target_arch(riscv32)
+    elseif(CMAKE_SIZEOF_VOID_P EQUAL "8")
+      add_default_target_arch(riscv64)
+    else()
+      message(FATAL_ERROR "Unsupport XLEN for RISC-V")
+    endif()
+  elseif(__S390X)
+    add_default_target_arch(s390x)
+  elseif(__SPARCV9)
+    add_default_target_arch(sparcv9)
+  elseif(__SPARC)
+    add_default_target_arch(sparc)
+  elseif(__WEBASSEMBLY32)
+    add_default_target_arch(wasm32)
+  elseif(__WEBASSEMBLY64)
+    add_default_target_arch(wasm64)
+  elseif(__VE)
+    add_default_target_arch(ve)
+  endif()
+endmacro()
+
 macro(load_llvm_config)
   if (NOT LLVM_CONFIG_PATH)
     find_program(LLVM_CONFIG_PATH "llvm-config"

diff  --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake
index 6b704f7dc9bc..964dd598f102 100644
--- a/compiler-rt/cmake/base-config-ix.cmake
+++ b/compiler-rt/cmake/base-config-ix.cmake
@@ -163,11 +163,8 @@ macro(test_targets)
 
   # Generate the COMPILER_RT_SUPPORTED_ARCH list.
   if(ANDROID)
-    if(${COMPILER_RT_DEFAULT_TARGET_ARCH} STREQUAL "i686")
-      add_default_target_arch(i386)
-    else()
-      add_default_target_arch(${COMPILER_RT_DEFAULT_TARGET_ARCH})
-    endif()
+    # Examine compiler output to determine target architecture.
+    detect_target_arch()
     set(COMPILER_RT_OS_SUFFIX "-android")
   elseif(NOT APPLE) # Supported archs for Apple platforms are generated later
     if(COMPILER_RT_DEFAULT_TARGET_ONLY)


        


More information about the llvm-commits mailing list