[llvm] r350234 - [gn build] Add build files for bugpoint-passes and LLVMHello plugins

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 2 09:38:22 PST 2019


Author: nico
Date: Wed Jan  2 09:38:22 2019
New Revision: 350234

URL: http://llvm.org/viewvc/llvm-project?rev=350234&view=rev
Log:
[gn build] Add build files for bugpoint-passes and LLVMHello plugins

These two plugins are loaded into a host process that contains all LLVM
symbols, so they don't link against anything. This required minor readjustments
to the tablegen() setup of IR.

Needed for check-llvm.

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

Added:
    llvm/trunk/utils/gn/secondary/llvm/lib/Transforms/Hello/
    llvm/trunk/utils/gn/secondary/llvm/lib/Transforms/Hello/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/tools/bugpoint-passes/
    llvm/trunk/utils/gn/secondary/llvm/tools/bugpoint-passes/BUILD.gn
Modified:
    llvm/trunk/utils/gn/secondary/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/include/llvm/IR/BUILD.gn
    llvm/trunk/utils/gn/secondary/llvm/lib/IR/BUILD.gn

Modified: llvm/trunk/utils/gn/secondary/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/BUILD.gn?rev=350234&r1=350233&r2=350234&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/BUILD.gn Wed Jan  2 09:38:22 2019
@@ -48,6 +48,15 @@ group("default") {
       "//clang/tools/clang-func-mapping",
     ]
   }
+  if (host_os != "win") {
+    # loadable_modules don't work on Windows.
+    # FIXME: In the CMake build, ENABLE_SHARED makes them work somehow
+    # (but they're off by default there too).
+    deps += [
+      "//llvm/lib/Transforms/Hello",
+      "//llvm/tools/bugpoint-passes",
+    ]
+  }
   testonly = true
 }
 

Modified: llvm/trunk/utils/gn/secondary/llvm/include/llvm/IR/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/include/llvm/IR/BUILD.gn?rev=350234&r1=350233&r2=350234&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/include/llvm/IR/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/llvm/include/llvm/IR/BUILD.gn Wed Jan  2 09:38:22 2019
@@ -1,7 +1,7 @@
 import("//llvm/utils/TableGen/tablegen.gni")
 
 tablegen("IntrinsicEnums") {
-  visibility = [ "//llvm/lib/IR" ]
+  visibility = [ ":public_tablegen" ]
   args = [ "-gen-intrinsic-enums" ]
   td_file = "Intrinsics.td"
 }
@@ -13,6 +13,20 @@ tablegen("IntrinsicImpl") {
 }
 
 tablegen("Attributes") {
-  visibility = [ "//llvm/lib/IR" ]
+  visibility = [ ":public_tablegen" ]
   args = [ "-gen-attrs" ]
 }
+
+# Groups all tablegen() calls that create .inc files that are included in
+# IR's public headers.  //llvm/lib/Target has this as a public_dep, so targets
+# dependign on //llvm/lib/IR don't need to depend on this.  This exists
+# solely for targets that use IR's public headers but don't link against IR.
+group("public_tablegen") {
+  public_deps = [
+    # IR's public headers include Attributes.inc.
+    ":Attributes",
+
+    # IR's public headers include IntrinsicEnums.inc.
+    ":IntrinsicEnums",
+  ]
+}

Modified: llvm/trunk/utils/gn/secondary/llvm/lib/IR/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/lib/IR/BUILD.gn?rev=350234&r1=350233&r2=350234&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/lib/IR/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/llvm/lib/IR/BUILD.gn Wed Jan  2 09:38:22 2019
@@ -10,12 +10,7 @@ static_library("IR") {
   public_deps = [
     # Must be public_dep because IR's public headers include llvm-config.h.
     "//llvm/include/llvm/Config:llvm-config",
-
-    # Must be public_dep because IR's public headers include Attributes.inc.
-    "//llvm/include/llvm/IR:Attributes",
-
-    # Must be public_dep because IR's public headers include IntrinsicEnums.inc.
-    "//llvm/include/llvm/IR:IntrinsicEnums",
+    "//llvm/include/llvm/IR:public_tablegen",
   ]
   deps = [
     ":AttributesCompatFunc",

Added: llvm/trunk/utils/gn/secondary/llvm/lib/Transforms/Hello/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/lib/Transforms/Hello/BUILD.gn?rev=350234&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/lib/Transforms/Hello/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/lib/Transforms/Hello/BUILD.gn Wed Jan  2 09:38:22 2019
@@ -0,0 +1,22 @@
+assert(host_os != "win", "loadable modules not supported on win")
+
+loadable_module("Hello") {
+  output_name = "LLVMHello"
+  deps = [
+    # LLVMHello doesn't want to link in any LLVM code, it just
+    # needs its headers.
+    "//llvm/include/llvm/IR:public_tablegen",
+  ]
+  sources = [
+    "Hello.cpp",
+  ]
+
+  if (host_os == "linux") {
+    # The GN build currently doesn't globally pass -fPIC, but that's
+    # needed for building .so files on Linux.  Just pass it manually
+    # for loadable_modules for now.
+    cflags = [ "-fPIC" ]
+  }
+
+  # FIXME: Use Hello.exports to remove all exports.
+}

Added: llvm/trunk/utils/gn/secondary/llvm/tools/bugpoint-passes/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/tools/bugpoint-passes/BUILD.gn?rev=350234&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/tools/bugpoint-passes/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/tools/bugpoint-passes/BUILD.gn Wed Jan  2 09:38:22 2019
@@ -0,0 +1,22 @@
+assert(host_os != "win", "loadable modules not supported on win")
+
+loadable_module("bugpoint-passes") {
+  output_name = "BugpointPasses"
+  deps = [
+    # BugpointPasses doesn't want to link in any LLVM code, it just
+    # needs its headers.
+    "//llvm/include/llvm/IR:public_tablegen",
+  ]
+  sources = [
+    "TestPasses.cpp",
+  ]
+
+  if (host_os == "linux") {
+    # The GN build currently doesn't globally pass -fPIC, but that's
+    # needed for building .so files on Linux.  Just pass it manually
+    # for loadable_modules for now.
+    cflags = [ "-fPIC" ]
+  }
+
+  # FIXME: Use bugpoint.exports to remove all exports.
+}




More information about the llvm-commits mailing list