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

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 17:41:51 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG19784825379e: gn build: Fix Android build. (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D146266?vs=506729&id=546280#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146266/new/

https://reviews.llvm.org/D146266

Files:
  llvm/utils/gn/build/BUILD.gn
  llvm/utils/gn/build/BUILDCONFIG.gn
  llvm/utils/gn/build/libs/implicit/BUILD.gn
  llvm/utils/gn/build/toolchain/target_flags.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
@@ -57,7 +57,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/build/toolchain/target_flags.gni
===================================================================
--- llvm/utils/gn/build/toolchain/target_flags.gni
+++ llvm/utils/gn/build/toolchain/target_flags.gni
@@ -17,10 +17,7 @@
     "--gcc-toolchain=$android_ndk_path/toolchains/llvm/prebuilt/linux-x86_64",
     "-fno-emulated-tls",
   ]
-  target_ldflags += [
-    "-static-libstdc++",
-    "--unwindlib=none",
-  ]
+  target_ldflags += [ "-static-libstdc++" ]
   if (current_cpu == "arm") {
     target_flags += [ "-march=armv7-a" ]
   }
Index: llvm/utils/gn/build/libs/implicit/BUILD.gn
===================================================================
--- /dev/null
+++ llvm/utils/gn/build/libs/implicit/BUILD.gn
@@ -0,0 +1,10 @@
+# This target represents the library dependencies that are implicitly linked by
+# the compiler.
+if (current_os == "android") {
+  group("implicit") {
+    deps = [
+      "//compiler-rt/lib/builtins",
+      "//libunwind/src:unwind_static",
+    ]
+  }
+}
Index: llvm/utils/gn/build/BUILDCONFIG.gn
===================================================================
--- llvm/utils/gn/build/BUILDCONFIG.gn
+++ llvm/utils/gn/build/BUILDCONFIG.gn
@@ -49,3 +49,22 @@
 }
 
 set_default_toolchain(host_toolchain)
+
+if (current_os == "android") {
+  foreach(target_type,
+          [
+            "executable",
+            "loadable_module",
+            "shared_library",
+          ]) {
+    template(target_type) {
+      target(target_type, target_name) {
+        forward_variables_from(invoker, "*")
+        if (!defined(deps)) {
+          deps = []
+        }
+        deps += [ "//llvm/utils/gn/build/libs/implicit" ]
+      }
+    }
+  }
+}
Index: llvm/utils/gn/build/BUILD.gn
===================================================================
--- llvm/utils/gn/build/BUILD.gn
+++ llvm/utils/gn/build/BUILD.gn
@@ -448,7 +448,7 @@
   # -Wl,-z,defs doesn't work with sanitizers.
   # https://clang.llvm.org/docs/AddressSanitizer.html
   if (current_os != "ios" && current_os != "mac" && current_os != "win" &&
-      current_os != "android" && !(use_asan || use_tsan || use_ubsan)) {
+      !(use_asan || use_tsan || use_ubsan)) {
     ldflags = [ "-Wl,-z,defs" ]
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146266.546280.patch
Type: text/x-patch
Size: 2762 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230802/2f921cb8/attachment.bin>


More information about the llvm-commits mailing list