diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn --- a/llvm/utils/gn/build/toolchain/BUILD.gn +++ b/llvm/utils/gn/build/toolchain/BUILD.gn @@ -207,6 +207,15 @@ 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 --- a/llvm/utils/gn/build/toolchain/target_flags.gni +++ b/llvm/utils/gn/build/toolchain/target_flags.gni @@ -11,6 +11,9 @@ "-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 --- 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 --- 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 @@ "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 @@ "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 @@ "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 @@ "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 --- a/llvm/utils/gn/secondary/compiler-rt/target.gni +++ b/llvm/utils/gn/secondary/compiler-rt/target.gni @@ -5,6 +5,8 @@ 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 --- a/llvm/utils/gn/secondary/llvm/triples.gni +++ b/llvm/utils/gn/secondary/llvm/triples.gni @@ -12,6 +12,10 @@ } 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"