[compiler-rt] 9b7e24c - [compiler-rt][Android] Stop using detect_target_arch

Ryan Prichard via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 16:54:06 PDT 2020


Author: Ryan Prichard
Date: 2020-07-13T16:53:07-07:00
New Revision: 9b7e24c2a5b32e25b773bc8b4ca84dbda995d959

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

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

For Android only, compiler-rt used detect_target_arch to select the
architecture to target. detect_target_arch was added in Sept 2014
(SVN r218605). At that time, compiler-rt selected the default arch
using ${LLVM_NATIVE_ARCH}, which seems to have been the host
architecture and therefore not suitable for cross-compilation.

The compiler-rt build system was refactored in Sept 2015 (SVN r247094
and SVN r247099) to use COMPILER_RT_DEFAULT_TARGET_TRIPLE to control
the target arch rather than LLVM_NATIVE_ARCH. This approach is simpler
and also works for Android cross-compilation, so remove the
detect_target_arch function.

Android targets i686, but compiler-rt seems to identify 32-bit x86 as
"i386". For Android, we were previously calling add_default_target_arch
with i386, and calling add_default_target_arch with i686 does not build
anything. i686 is not listed in builtin-config-ix.cmake,
ALL_BUILTIN_SUPPORTED_ARCH.

Differential Revision: 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 99b9f0e4af44..107a475d6a0e 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -151,61 +151,6 @@ 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 964dd598f102..6b704f7dc9bc 100644
--- a/compiler-rt/cmake/base-config-ix.cmake
+++ b/compiler-rt/cmake/base-config-ix.cmake
@@ -163,8 +163,11 @@ macro(test_targets)
 
   # Generate the COMPILER_RT_SUPPORTED_ARCH list.
   if(ANDROID)
-    # Examine compiler output to determine target architecture.
-    detect_target_arch()
+    if(${COMPILER_RT_DEFAULT_TARGET_ARCH} STREQUAL "i686")
+      add_default_target_arch(i386)
+    else()
+      add_default_target_arch(${COMPILER_RT_DEFAULT_TARGET_ARCH})
+    endif()
     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