[llvm] 7c86c70 - gn build: Add support for cross-compiling the builtins and profile runtimes for Android aarch64 and arm.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 15:47:27 PDT 2019


Author: Peter Collingbourne
Date: 2019-10-31T15:47:20-07:00
New Revision: 7c86c70f268a91091b71f33e762ce704d54237e1

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

LOG: gn build: Add support for cross-compiling the builtins and profile runtimes for Android aarch64 and arm.

Differential Revision: https://reviews.llvm.org/D69681

Added: 
    

Modified: 
    llvm/utils/gn/build/toolchain/BUILD.gn
    llvm/utils/gn/build/toolchain/target_flags.gni
    llvm/utils/gn/secondary/compiler-rt/BUILD.gn
    llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
    llvm/utils/gn/secondary/compiler-rt/target.gni
    llvm/utils/gn/secondary/llvm/triples.gni

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn
index c36579f28e43..b8e46034ccab 100644
--- a/llvm/utils/gn/build/toolchain/BUILD.gn
+++ b/llvm/utils/gn/build/toolchain/BUILD.gn
@@ -207,6 +207,15 @@ if (android_ndk_path != "") {
       use_lld = true
     }
   }
+
+  stage2_unix_toolchain("stage2_android_arm") {
+    toolchain_args = {
+      current_os = "android"
+      current_cpu = "arm"
+      is_clang = true
+      use_lld = true
+    }
+  }
 }
 
 toolchain("win") {

diff  --git a/llvm/utils/gn/build/toolchain/target_flags.gni b/llvm/utils/gn/build/toolchain/target_flags.gni
index e1c045f625c6..02dfeda9d62f 100644
--- a/llvm/utils/gn/build/toolchain/target_flags.gni
+++ b/llvm/utils/gn/build/toolchain/target_flags.gni
@@ -11,6 +11,9 @@ if (current_os == "android") {
     "-B$android_ndk_path/toolchains/llvm/prebuilt/linux-x86_64",
   ]
   target_ldflags += [ "-static-libstdc++" ]
+  if (current_cpu == "arm") {
+    target_flags += [ "-march=armv7-a" ]
+  }
 }
 
 if (current_cpu == "x86") {

diff  --git a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
index 1da710d5ac9b..7a1961678b05 100644
--- a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
@@ -1,8 +1,19 @@
-group("compiler-rt") {
-  # In the GN build, compiler-rt is always built by just-built clang and lld.
-  # FIXME: For macOS and iOS builds, depend on lib in all needed target arch
-  # toolchains and then lipo them together for the final output.
-  deps = [
-    "//compiler-rt/lib(//llvm/utils/gn/build/toolchain:stage2_unix)",
+import("//llvm/utils/gn/build/toolchain/compiler.gni")
+
+# In the GN build, compiler-rt is always built by just-built clang and lld.
+# FIXME: For macOS and iOS builds, depend on lib in all needed target arch
+# toolchains and then lipo them together for the final output.
+supported_toolchains = [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
+if (android_ndk_path != "") {
+  supported_toolchains += [
+    "//llvm/utils/gn/build/toolchain:stage2_android_aarch64",
+    "//llvm/utils/gn/build/toolchain:stage2_android_arm",
   ]
 }
+
+group("compiler-rt") {
+  deps = []
+  foreach(toolchain, supported_toolchains) {
+    deps += [ "//compiler-rt/lib($toolchain)" ]
+  }
+}

diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
index c052603dab94..1614f07facfd 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
@@ -306,12 +306,30 @@ static_library("builtins") {
         "comparesf2.c",
         "divmodsi4.c",
         "divsi3.c",
+        "fp_mode.c",
         "modsi3.c",
         "udivmodsi4.c",
         "udivsi3.c",
         "umodsi3.c",
       ]
       sources += [
+        "arm/aeabi_cdcmp.S",
+        "arm/aeabi_cdcmpeq_check_nan.c",
+        "arm/aeabi_cfcmp.S",
+        "arm/aeabi_cfcmpeq_check_nan.c",
+        "arm/aeabi_dcmp.S",
+        "arm/aeabi_div0.c",
+        "arm/aeabi_drsub.c",
+        "arm/aeabi_fcmp.S",
+        "arm/aeabi_frsub.c",
+        "arm/aeabi_idivmod.S",
+        "arm/aeabi_ldivmod.S",
+        "arm/aeabi_memcmp.S",
+        "arm/aeabi_memcpy.S",
+        "arm/aeabi_memmove.S",
+        "arm/aeabi_memset.S",
+        "arm/aeabi_uidivmod.S",
+        "arm/aeabi_uldivmod.S",
         "arm/bswapdi2.S",
         "arm/bswapsi2.S",
         "arm/clzdi2.S",
@@ -321,6 +339,10 @@ static_library("builtins") {
         "arm/divsi3.S",
         "arm/fp_mode.c",
         "arm/modsi3.S",
+        "arm/switch16.S",
+        "arm/switch32.S",
+        "arm/switch8.S",
+        "arm/switchu8.S",
         "arm/sync_fetch_and_add_4.S",
         "arm/sync_fetch_and_add_8.S",
         "arm/sync_fetch_and_and_4.S",
@@ -341,10 +363,52 @@ static_library("builtins") {
         "arm/sync_fetch_and_umin_8.S",
         "arm/sync_fetch_and_xor_4.S",
         "arm/sync_fetch_and_xor_8.S",
+        "arm/sync_synchronize.S",
         "arm/udivmodsi4.S",
         "arm/udivsi3.S",
         "arm/umodsi3.S",
       ]
+
+      if (current_os == "android") {
+        sources += [
+          "arm/adddf3vfp.S",
+          "arm/addsf3vfp.S",
+          "arm/divdf3vfp.S",
+          "arm/divsf3vfp.S",
+          "arm/eqdf2vfp.S",
+          "arm/eqsf2vfp.S",
+          "arm/extendsfdf2vfp.S",
+          "arm/fixdfsivfp.S",
+          "arm/fixsfsivfp.S",
+          "arm/fixunsdfsivfp.S",
+          "arm/fixunssfsivfp.S",
+          "arm/floatsidfvfp.S",
+          "arm/floatsisfvfp.S",
+          "arm/floatunssidfvfp.S",
+          "arm/floatunssisfvfp.S",
+          "arm/gedf2vfp.S",
+          "arm/gesf2vfp.S",
+          "arm/gtdf2vfp.S",
+          "arm/gtsf2vfp.S",
+          "arm/ledf2vfp.S",
+          "arm/lesf2vfp.S",
+          "arm/ltdf2vfp.S",
+          "arm/ltsf2vfp.S",
+          "arm/muldf3vfp.S",
+          "arm/mulsf3vfp.S",
+          "arm/nedf2vfp.S",
+          "arm/negdf2vfp.S",
+          "arm/negsf2vfp.S",
+          "arm/nesf2vfp.S",
+          "arm/restore_vfp_d8_d15_regs.S",
+          "arm/save_vfp_d8_d15_regs.S",
+          "arm/subdf3vfp.S",
+          "arm/subsf3vfp.S",
+          "arm/truncdfsf2vfp.S",
+          "arm/unorddf2vfp.S",
+          "arm/unordsf2vfp.S",
+        ]
+      }
     } else {
       sources += [
         "arm/aeabi_idivmod.S",
@@ -450,73 +514,5 @@ source_set("_unused") {
     "arm/comparesf2.S",
     "arm/divsi3.S",
     "arm/udivsi3.S",
-
-    # EABI
-    "arm/aeabi_cdcmp.S",
-    "arm/aeabi_cdcmpeq_check_nan.c",
-    "arm/aeabi_cfcmp.S",
-    "arm/aeabi_cfcmpeq_check_nan.c",
-    "arm/aeabi_dcmp.S",
-    "arm/aeabi_div0.c",
-    "arm/aeabi_drsub.c",
-    "arm/aeabi_fcmp.S",
-    "arm/aeabi_frsub.c",
-    "arm/aeabi_idivmod.S",
-    "arm/aeabi_ldivmod.S",
-    "arm/aeabi_memcmp.S",
-    "arm/aeabi_memcpy.S",
-    "arm/aeabi_memmove.S",
-    "arm/aeabi_memset.S",
-    "arm/aeabi_uidivmod.S",
-    "arm/aeabi_uldivmod.S",
-
-    # Thumb1 JT
-    "arm/switch16.S",
-    "arm/switch32.S",
-    "arm/switch8.S",
-    "arm/switchu8.S",
-
-    # Thumb1 SjLj
-    "arm/restore_vfp_d8_d15_regs.S",
-    "arm/save_vfp_d8_d15_regs.S",
-
-    # Thumb1 VFPv2
-    "arm/adddf3vfp.S",
-    "arm/addsf3vfp.S",
-    "arm/divdf3vfp.S",
-    "arm/divsf3vfp.S",
-    "arm/eqdf2vfp.S",
-    "arm/eqsf2vfp.S",
-    "arm/extendsfdf2vfp.S",
-    "arm/fixdfsivfp.S",
-    "arm/fixsfsivfp.S",
-    "arm/fixunsdfsivfp.S",
-    "arm/fixunssfsivfp.S",
-    "arm/floatsidfvfp.S",
-    "arm/floatsisfvfp.S",
-    "arm/floatunssidfvfp.S",
-    "arm/floatunssisfvfp.S",
-    "arm/gedf2vfp.S",
-    "arm/gesf2vfp.S",
-    "arm/gtdf2vfp.S",
-    "arm/gtsf2vfp.S",
-    "arm/ledf2vfp.S",
-    "arm/lesf2vfp.S",
-    "arm/ltdf2vfp.S",
-    "arm/ltsf2vfp.S",
-    "arm/muldf3vfp.S",
-    "arm/mulsf3vfp.S",
-    "arm/nedf2vfp.S",
-    "arm/negdf2vfp.S",
-    "arm/negsf2vfp.S",
-    "arm/nesf2vfp.S",
-    "arm/subdf3vfp.S",
-    "arm/subsf3vfp.S",
-    "arm/truncdfsf2vfp.S",
-    "arm/unorddf2vfp.S",
-    "arm/unordsf2vfp.S",
-
-    # Thumb1 icache
-    "arm/sync_synchronize.S",
   ]
 }

diff  --git a/llvm/utils/gn/secondary/compiler-rt/target.gni b/llvm/utils/gn/secondary/compiler-rt/target.gni
index c739acc656f8..1f2372e8f1d6 100644
--- a/llvm/utils/gn/secondary/compiler-rt/target.gni
+++ b/llvm/utils/gn/secondary/compiler-rt/target.gni
@@ -5,6 +5,8 @@ if (current_cpu == "x86") {
   crt_current_target_arch = "i386"
 } else if (current_cpu == "x64") {
   crt_current_target_arch = "x86_64"
+} else if (current_cpu == "arm") {
+  crt_current_target_arch = "arm"
 } else if (current_cpu == "arm64") {
   crt_current_target_arch = "aarch64"
 } else if (current_cpu == "ppc64") {

diff  --git a/llvm/utils/gn/secondary/llvm/triples.gni b/llvm/utils/gn/secondary/llvm/triples.gni
index 558731295cee..9c9ba1326395 100644
--- a/llvm/utils/gn/secondary/llvm/triples.gni
+++ b/llvm/utils/gn/secondary/llvm/triples.gni
@@ -12,6 +12,10 @@ if (current_cpu == "x86") {
   } else if (current_os == "win") {
     llvm_current_triple = "x86_64-pc-windows-msvc"
   }
+} else if (current_cpu == "arm") {
+  if (current_os == "android") {
+    llvm_current_triple = "arm-linux-androideabi"
+  }
 } else if (current_cpu == "arm64") {
   if (current_os == "android") {
     llvm_current_triple = "aarch64-linux-android21"


        


More information about the llvm-commits mailing list