[llvm] 83d7605 - [gn build] Port rest of 07af0e2d3e84

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 18 04:37:09 PST 2022


Author: Nico Weber
Date: 2022-12-18T07:36:54-05:00
New Revision: 83d7605c22af883c280e83b4bf82c83c49abb94b

URL: https://github.com/llvm/llvm-project/commit/83d7605c22af883c280e83b4bf82c83c49abb94b
DIFF: https://github.com/llvm/llvm-project/commit/83d7605c22af883c280e83b4bf82c83c49abb94b.diff

LOG: [gn build] Port rest of 07af0e2d3e84

Test now passes, at least on macOS.

Added: 
    

Modified: 
    llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn
index 19861fac7362..a94695ef57db 100644
--- a/llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/unittests/Analysis/BUILD.gn
@@ -1,5 +1,31 @@
 import("//third-party/unittest/unittest.gni")
 
+# Keyed off LLVM_ENABLE_PLUGINS in the CMake build, which is usually false
+# on Windows and true elsewhere.
+if (host_os != "win") {
+  foreach(plugin, [ "InlineAdvisorPlugin" ]) {
+    loadable_module(plugin) {
+      # Put plugin next to the unit test executable.
+      output_dir = target_out_dir
+
+      sources = [ "$plugin.cpp" ]
+
+      deps = [
+        # TestPlugin doesn't want to link in any LLVM code, it just needs its
+        # headers.
+        "//llvm/include/llvm/IR:public_tablegen",
+      ]
+
+      if (host_os != "mac" && host_os != "win") {
+        # The GN build currently doesn't globally pass -fPIC, but that's
+        # needed for building .so files on ELF.  Just pass it manually
+        # for loadable_modules for now.
+        cflags = [ "-fPIC" ]
+      }
+    }
+  }
+}
+
 unittest("AnalysisTests") {
   deps = [
     "//llvm/lib/Analysis",
@@ -52,4 +78,11 @@ unittest("AnalysisTests") {
     "VectorFunctionABITest.cpp",
     "VectorUtilsTest.cpp",
   ]
+
+  # If plugins are disabled, this test will disable itself at runtime.
+  # Otherwise, reconfiguring with plugins disabled will leave behind a stale
+  # executable.
+  if (host_os != "win") {
+    deps += [ ":InlineAdvisorPlugin" ]
+  }
 }


        


More information about the llvm-commits mailing list