[llvm] r367449 - gn build: Make builtin library build on macOS

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 31 10:12:33 PDT 2019


Author: nico
Date: Wed Jul 31 10:12:33 2019
New Revision: 367449

URL: http://llvm.org/viewvc/llvm-project?rev=367449&view=rev
Log:
gn build: Make builtin library build on macOS

For now, it only builds the x86_64 slice.

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

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

Modified: llvm/trunk/utils/gn/build/toolchain/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/toolchain/BUILD.gn?rev=367449&r1=367448&r2=367449&view=diff
==============================================================================
--- llvm/trunk/utils/gn/build/toolchain/BUILD.gn (original)
+++ llvm/trunk/utils/gn/build/toolchain/BUILD.gn Wed Jul 31 10:12:33 2019
@@ -166,6 +166,8 @@ unix_toolchain("unix") {
   }
 }
 
+# This template defines a toolchain that uses just-built clang and lld
+# as compiler and linker.
 template("stage2_unix_toolchain") {
   unix_toolchain(target_name) {
     forward_variables_from(invoker, "*")

Modified: llvm/trunk/utils/gn/secondary/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/BUILD.gn?rev=367449&r1=367448&r2=367449&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/BUILD.gn Wed Jul 31 10:12:33 2019
@@ -10,9 +10,11 @@ group("default") {
     "//lld/test",
     "//llvm/test",
   ]
+  if (current_os == "linux" || current_os == "mac") {
+    deps += [ "//compiler-rt" ]
+  }
   if (current_os == "linux") {
     deps += [
-      "//compiler-rt",
       "//libcxx",
       "//libcxxabi",
       "//libunwind",

Modified: llvm/trunk/utils/gn/secondary/compiler-rt/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/compiler-rt/BUILD.gn?rev=367449&r1=367448&r2=367449&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/compiler-rt/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/compiler-rt/BUILD.gn Wed Jul 31 10:12:33 2019
@@ -1,4 +1,7 @@
 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)",
   ]

Modified: llvm/trunk/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn?rev=367449&r1=367448&r2=367449&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn Wed Jul 31 10:12:33 2019
@@ -11,7 +11,11 @@ declare_args() {
 
 static_library("builtins") {
   output_dir = crt_current_out_dir
-  output_name = "clang_rt.builtins$crt_current_target_suffix"
+  if (current_os == "mac") {
+    output_name = "clang_rt.osx"
+  } else {
+    output_name = "clang_rt.builtins$crt_current_target_suffix"
+  }
   complete_static_lib = true
   cflags = [
     "-fPIC",

Modified: llvm/trunk/utils/gn/secondary/compiler-rt/target.gni
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/compiler-rt/target.gni?rev=367449&r1=367448&r2=367449&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/compiler-rt/target.gni (original)
+++ llvm/trunk/utils/gn/secondary/compiler-rt/target.gni Wed Jul 31 10:12:33 2019
@@ -24,6 +24,8 @@ if (clang_enable_per_target_runtime_dir)
   if (current_os == "android") {
     crt_current_target_suffix += "-android"
   }
+} else if (current_os == "mac") {
+  crt_current_out_dir = "$clang_resource_dir/lib/darwin"
 } else {
   assert(false, "unimplemented current_os " + current_os)
 }




More information about the llvm-commits mailing list