[llvm] [Windows] Fix Registry static data members not exported by extract_symbols.py in static builds with plugin support (PR #163391)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 17 08:31:23 PDT 2025
================
@@ -55,6 +55,25 @@
#include <set>
#include <system_error>
+#if defined(CLANG_PLUGIN_SUPPORT) && defined(_WIN32)
+#include "clang/Frontend/FrontendPluginRegistry.h"
+
+// Force plugin registry symbols into clang.exe on Windows so plugins can
+// register. These methods exist in libraries but aren't linked by default
+// because they're unreferenced. Taking their addresses forces the linker to
+// include them.
+namespace {
+void ForcePluginRegistrySymbols() {
+ using PluginRegistry = llvm::Registry<clang::PluginASTAction>;
+ // Use volatile to prevent the compiler from optimizing away these references
+ volatile auto add_node_ptr = &PluginRegistry::add_node;
+ volatile auto begin_ptr = &PluginRegistry::begin;
+ (void)add_node_ptr;
+ (void)begin_ptr;
+}
+} // anonymous namespace
+#endif
+
----------------
zond wrote:
Alright - with `/Zc:dllexportInlines-` this wasn't necessary - the symbols are now inlined into the plugin as well!
https://github.com/llvm/llvm-project/pull/163391
More information about the llvm-commits
mailing list