[PATCH] D104466: NOT FOR REVIEW: proof-of-concept for building lib/linux/libclang_rt.profile-x86_64.a on a mac in the gn build

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 08:00:29 PDT 2021


thakis created this revision.
thakis requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Seems to work!

Hardcodes the path to the linux sysroot, so not landable as-is.


https://reviews.llvm.org/D104466

Files:
  llvm/utils/gn/build/BUILD.gn
  llvm/utils/gn/build/toolchain/BUILD.gn
  llvm/utils/gn/secondary/compiler-rt/BUILD.gn


Index: llvm/utils/gn/secondary/compiler-rt/BUILD.gn
===================================================================
--- llvm/utils/gn/secondary/compiler-rt/BUILD.gn
+++ llvm/utils/gn/secondary/compiler-rt/BUILD.gn
@@ -10,6 +10,9 @@
 } else {
   supported_toolchains = [ "//llvm/utils/gn/build/toolchain:stage2_unix" ]
 }
+if (current_os == "mac") {
+  supported_toolchains += [ "//llvm/utils/gn/build/toolchain:stage2_unix_linux" ]
+}
 if (android_ndk_path != "") {
   supported_toolchains += [
     "//llvm/utils/gn/build/toolchain:stage2_android_aarch64",
Index: llvm/utils/gn/build/toolchain/BUILD.gn
===================================================================
--- llvm/utils/gn/build/toolchain/BUILD.gn
+++ llvm/utils/gn/build/toolchain/BUILD.gn
@@ -193,7 +193,7 @@
       "//:clang($host_toolchain)",
       "//:lld($host_toolchain)",
     ]
-    if (current_os != "ios" && current_os != "mac") {
+    if (toolchain_args.current_os != "ios" && toolchain_args.current_os != "mac") {
       ar = "bin/llvm-ar"
       deps += [ "//:llvm-ar($host_toolchain)" ]
     }
@@ -207,6 +207,14 @@
   }
 }
 
+stage2_unix_toolchain("stage2_unix_linux") {
+  toolchain_args = {
+    current_os = "linux"
+    current_cpu = host_cpu
+    sysroot = "//sysroot-linux"
+  }
+}
+
 if (android_ndk_path != "") {
   stage2_unix_toolchain("stage2_android_aarch64") {
     toolchain_args = {
Index: llvm/utils/gn/build/BUILD.gn
===================================================================
--- llvm/utils/gn/build/BUILD.gn
+++ llvm/utils/gn/build/BUILD.gn
@@ -137,6 +137,14 @@
     ldflags += [ "/STACK:10000000" ]
   }
 
+  if (host_os != current_os && !(host_os == "mac" && current_os == "ios")) {
+    if (current_os == "linux" && current_cpu == "x64") {
+      cflags += [ "--target=x86_64-linux-gnu" ]
+    } else {
+      assert(false, "unimplemented cross config $host_os => $current_os")
+    }
+  }
+
   # Warning setup.
   if (host_os == "win" && !is_clang) {
     cflags += [


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104466.352733.patch
Type: text/x-patch
Size: 1986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210617/21b03a24/attachment.bin>


More information about the llvm-commits mailing list