[llvm] 16e2e7f - gn build: Generate dynamic lists for ubsan.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 4 17:54:34 PST 2026


Author: Peter Collingbourne
Date: 2026-02-04T17:54:01-08:00
New Revision: 16e2e7f59134e63810228c9a0dc990bfd96f9a1f

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

LOG: gn build: Generate dynamic lists for ubsan.

Added: 
    llvm/utils/gn/secondary/compiler-rt/gen_dynamic_list.gni

Modified: 
    llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/secondary/compiler-rt/gen_dynamic_list.gni b/llvm/utils/gn/secondary/compiler-rt/gen_dynamic_list.gni
new file mode 100644
index 0000000000000..c134400108434
--- /dev/null
+++ b/llvm/utils/gn/secondary/compiler-rt/gen_dynamic_list.gni
@@ -0,0 +1,40 @@
+import("//compiler-rt/target.gni")
+
+template("gen_dynamic_list") {
+  if (current_os != "mac" && current_os != "win") {
+    lib_path = "$crt_current_out_dir/libclang_rt.${invoker.lib_name}$crt_current_target_suffix.a"
+    nm = "//llvm/tools/llvm-nm($host_toolchain)"
+    action(target_name) {
+      script = "//compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py"
+      deps = [
+        invoker.lib,
+        nm,
+      ]
+      outputs = [ "$lib_path.syms" ]
+      args = [ rebase_path(lib_path, root_build_dir) ]
+      args += [
+        "--nm-executable",
+        rebase_path(get_label_info(nm, "root_out_dir") + "/bin/llvm-nm",
+                    root_build_dir),
+        "-o",
+        rebase_path("$lib_path.syms", root_build_dir),
+      ]
+      if (defined(invoker.extra)) {
+        sources = [ invoker.extra ]
+        args += [
+          "--extra",
+          rebase_path(invoker.extra, root_build_dir),
+        ]
+      }
+    }
+  } else {
+    source_set(target_name) {
+    }
+    not_needed(invoker,
+               [
+                 "extra",
+                 "lib_name",
+                 "lib",
+               ])
+  }
+}

diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
index c331193ca94c9..803ba2b34eeb0 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/ubsan/BUILD.gn
@@ -1,3 +1,4 @@
+import("//compiler-rt/gen_dynamic_list.gni")
 import("//compiler-rt/gen_version_script.gni")
 import("//compiler-rt/target.gni")
 
@@ -5,9 +6,13 @@ group("ubsan") {
   deps = [
     ":ubsan_shared",
     ":ubsan_static",
+    ":ubsan_static_dynamic_list",
   ]
   if (current_os != "mac") {
-    deps += [ ":ubsan_static_cxx" ]
+    deps += [
+      ":ubsan_static_cxx",
+      ":ubsan_static_cxx_dynamic_list",
+    ]
   }
 }
 
@@ -108,6 +113,12 @@ static_library("ubsan_static") {
   }
 }
 
+gen_dynamic_list("ubsan_static_dynamic_list") {
+  extra = "ubsan.syms.extra"
+  lib = ":ubsan_static"
+  lib_name = "ubsan_standalone"
+}
+
 if (current_os != "mac") {
   static_library("ubsan_static_cxx") {
     output_dir = crt_current_out_dir
@@ -120,6 +131,12 @@ if (current_os != "mac") {
     configs += [ "//llvm/utils/gn/build:crt_code" ]
     deps = [ ":cxx_sources" ]
   }
+
+  gen_dynamic_list("ubsan_static_cxx_dynamic_list") {
+    extra = "ubsan.syms.extra"
+    lib = ":ubsan_static_cxx"
+    lib_name = "ubsan_standalone_cxx"
+  }
 }
 
 shared_library("ubsan_shared") {


        


More information about the llvm-commits mailing list