[llvm] e302933 - [gn build] Kind of port c7b3a91017d2 (libclang version script)

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 19:12:57 PDT 2021


Author: Nico Weber
Date: 2021-07-26T22:12:06-04:00
New Revision: e30293352c98e6985480d6d77b60675becbdc549

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

LOG: [gn build] Kind of port c7b3a91017d2 (libclang version script)

libclang is only built as static library in the GN build at the
moment, which means we now generate a .exports file form a version
script and then link.exe and ld64 inputs from the .exports file
but don't use the version script, but hey.

Added: 
    

Modified: 
    llvm/utils/gn/build/symbol_exports.gni
    llvm/utils/gn/secondary/clang/test/BUILD.gn
    llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/build/symbol_exports.gni b/llvm/utils/gn/build/symbol_exports.gni
index ed0e7df560e0b..d81d9ea22ccc8 100644
--- a/llvm/utils/gn/build/symbol_exports.gni
+++ b/llvm/utils/gn/build/symbol_exports.gni
@@ -44,6 +44,7 @@ template("symbol_exports") {
   }
 
   action(target_name) {
+    forward_variables_from(invoker, [ "deps" ])
     script = "//llvm/utils/gn/build/symbol_exports.py"
     inputs = [ invoker.exports_file ]
     outputs = [ linker_file ]

diff  --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index 85ba3cc76793d..f819b9552db7d 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -105,12 +105,15 @@ write_lit_config("lit_site_cfg") {
 
   if (host_os == "win") {
     extra_values += [
+      # See comment for Windows solink in llvm/utils/gn/build/toolchain/BUILD.gn
+      "CMAKE_LIBRARY_OUTPUT_DIRECTORY=" + rebase_path("$root_out_dir/bin", dir),
       "LLVM_ENABLE_PLUGINS=0",
       "LLVM_LIT_ERRC_MESSAGES=no such file or directory;is a directory;" +
           "invalid argument;permission denied",
     ]
   } else {
     extra_values += [
+      "CMAKE_LIBRARY_OUTPUT_DIRECTORY=" + rebase_path("$root_out_dir/lib", dir),
       "LLVM_ENABLE_PLUGINS=0",  # FIXME: Analysis/plugins need global -fPIC
       "LLVM_LIT_ERRC_MESSAGES=",
     ]

diff  --git a/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
index e72af8fbc7a48..556c8783ba306 100644
--- a/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/tools/libclang/BUILD.gn
@@ -14,10 +14,21 @@ if (host_os != "win" && host_os != "mac") {
   # ELF targets need -fPIC to build shared libs but they aren't on by default.
   # For now, make libclang a static lib there.
   libclang_target_type = "static_library"
-}
+} else {
+  action("linker_script_to_exports") {
+    script = "linker-script-to-export-list.py"
+    inputs = [ "libclang.map" ]
+    outputs = [ "$target_gen_dir/libclang.exports" ]
+    args = [
+      rebase_path(inputs[0], root_build_dir),
+      rebase_path(outputs[0], root_build_dir),
+    ]
+  }
 
-symbol_exports("exports") {
-  exports_file = "libclang.exports"
+  symbol_exports("exports") {
+    deps = [ ":linker_script_to_exports" ]
+    exports_file = "$target_gen_dir/libclang.exports"
+  }
 }
 
 target(libclang_target_type, "libclang") {


        


More information about the llvm-commits mailing list