[llvm] [gn] Add clang_static_plugin_sources to link out-of-tree plugins into clang (PR #226381)
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 00:00:36 PDT 2026
https://github.com/nico created https://github.com/llvm/llvm-project/pull/226381
This is useful for testing and profiling e.g. Chromium's clang plugins without having to export symbols from the clang binary.
# args.gn
clang_static_plugin_sources = [
"/path/to/chromium/src/tools/clang/plugins/FindBadConstructsAction.cpp",
...
]
clang_static_plugin_include_dirs = [ "/path/to/chromium/src" ]
...or put the above in a gni file and put just `import("plugins.gni")` in args.gn
No behavior change if the list is empty (the default).
>From c115ca959ab8bb22418391405a8d1bddc148677c Mon Sep 17 00:00:00 2001
From: Nico Weber <thakis at chromium.org>
Date: Sun, 20 Sep 2026 15:09:03 -0400
Subject: [PATCH] [gn] Add clang_static_plugin_sources to link out-of-tree
plugins into clang
This is useful for testing and profiling e.g. Chromium's clang plugins
without having to export symbols from the clang binary.
# args.gn
clang_static_plugin_sources = [
"/path/to/chromium/src/tools/clang/plugins/FindBadConstructsAction.cpp",
...
]
clang_static_plugin_include_dirs = [ "/path/to/chromium/src" ]
...or put the above in a gni file and put just `import("plugins.gni")`
in args.gn
No behavior change if the list is empty (the default).
---
.../utils/gn/secondary/clang/tools/driver/BUILD.gn | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn b/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
index cd3c64256a3e6..76c6cf4f05624 100644
--- a/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/tools/driver/BUILD.gn
@@ -3,6 +3,16 @@ import("//llvm/utils/gn/build/symlink_or_copy.gni")
import("//llvm/utils/gn/build/write_cmake_config.gni")
import("//llvm/version.gni")
+declare_args() {
+ # Additional source files to compile into the clang binary.
+ # This is for adding statically linked out-of-tree clang plugins.
+ # Use absolute paths ("/path/to/Plugin.cpp").
+ clang_static_plugin_sources = []
+
+ # Include directories for clang_static_plugin_sources.
+ clang_static_plugin_include_dirs = []
+}
+
symlinks = [
# target_name, symlink_target pairs: GN doesn't support '+' in rule names.
[
@@ -99,5 +109,9 @@ driver_executable("clang") {
"cc1gen_reproducer_main.cpp",
"driver.cpp",
]
+ if (clang_static_plugin_sources != []) {
+ sources += clang_static_plugin_sources
+ include_dirs = clang_static_plugin_include_dirs
+ }
needs_posix_utility_signal_handling = true
}
More information about the llvm-commits
mailing list