[PATCH] D146266: gn build: Fix Android build.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 16:40:21 PDT 2023


pcc created this revision.
pcc added reviewers: aeubanks, thakis.
Herald added subscribers: Enna1, danielkiss, pengfei.
Herald added a project: All.
pcc requested review of this revision.
Herald added a project: LLVM.

Remove --unwindlib=none flag that was added by D143598 <https://reviews.llvm.org/D143598>. This
flag is required for linking binaries. Without this flag, linking
e.g. llvm-symbolizer will fail.

D143598 <https://reviews.llvm.org/D143598> set the arch subdirectory to i686 for Android. However, the arch
subdirectory on Android is i386, and has been for a long time.

$ find android-ndk-r* -name i386
android-ndk-r18b/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/7.0.2/lib/linux/i386
android-ndk-r19/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/8.0.2/lib/linux/i386
android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/8.0.7/lib/linux/i386
android-ndk-r21-beta1/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/lib/linux/i386
android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/9.0.8/lib/linux/i386
android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/11.0.5/lib/linux/i386
android-ndk-r23-beta5/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.5/lib/linux/i386
android-ndk-r24/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.1/lib/linux/i386
android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.7/lib/linux/i386

Using the wrong name prevents Clang from being able to find libunwind.a on
x86. Fix the code to use i386 as the arch subdirectory, consistent with
the NDK. This fixes linking on x86 after removing the --unwindlib=none
flag.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146266

Files:
  llvm/utils/gn/build/toolchain/target_flags.gni
  llvm/utils/gn/secondary/compiler-rt/target.gni
  llvm/utils/gn/secondary/libunwind/src/BUILD.gn


Index: llvm/utils/gn/secondary/libunwind/src/BUILD.gn
===================================================================
--- llvm/utils/gn/secondary/libunwind/src/BUILD.gn
+++ llvm/utils/gn/secondary/libunwind/src/BUILD.gn
@@ -58,7 +58,7 @@
   } else if (current_cpu == "x64") {
     unwind_output_dir = "$crt_current_out_dir/x86_64"
   } else if (current_cpu == "x86") {
-    unwind_output_dir = "$crt_current_out_dir/i686"
+    unwind_output_dir = "$crt_current_out_dir/i386"
   }
 } else {
   unwind_output_dir = runtimes_dir
Index: llvm/utils/gn/secondary/compiler-rt/target.gni
===================================================================
--- llvm/utils/gn/secondary/compiler-rt/target.gni
+++ llvm/utils/gn/secondary/compiler-rt/target.gni
@@ -2,11 +2,7 @@
 import("//clang/runtimes.gni")
 
 if (current_cpu == "x86") {
-  if (current_os == "android") {
-    crt_current_target_arch = "i686"
-  } else {
-    crt_current_target_arch = "i386"
-  }
+  crt_current_target_arch = "i386"
 } else if (current_cpu == "x64") {
   crt_current_target_arch = "x86_64"
 } else if (current_cpu == "arm") {
Index: llvm/utils/gn/build/toolchain/target_flags.gni
===================================================================
--- llvm/utils/gn/build/toolchain/target_flags.gni
+++ llvm/utils/gn/build/toolchain/target_flags.gni
@@ -15,10 +15,7 @@
     "--sysroot=$android_ndk_path/toolchains/llvm/prebuilt/linux-x86_64/sysroot",
     "--gcc-toolchain=$android_ndk_path/toolchains/llvm/prebuilt/linux-x86_64",
   ]
-  target_ldflags += [
-    "-static-libstdc++",
-    "--unwindlib=none",
-  ]
+  target_ldflags += [ "-static-libstdc++" ]
   if (current_cpu == "arm") {
     target_flags += [ "-march=armv7-a" ]
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146266.505954.patch
Type: text/x-patch
Size: 1719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230316/69cdd747/attachment.bin>


More information about the llvm-commits mailing list