[llvm] [Windows] Fix plugin registry symbols not exported/linked with CLANG_LINK_CLANG_DYLIB (PR #163391)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 17 08:22:48 PDT 2025


https://github.com/zond updated https://github.com/llvm/llvm-project/pull/163391

>From 8e85cf5c955fd9c9d1f38fff7dd73357f11ccc1f Mon Sep 17 00:00:00 2001
From: Martin Bruse <zondolfin at gmail.com>
Date: Tue, 14 Oct 2025 13:23:00 +0000
Subject: [PATCH] [Windows] Fix plugin registry symbols not exported in static
 builds with plugin support.

When building LLVM statically (without BUILD_SHARED_LIBS) on Windows with
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON, external plugins cannot register through
llvm::Registry<clang::PluginASTAction> because:

Static data members (Head, Tail) are filtered out during symbol export by
extract_symbols.py because they don't match the function signature patterns
that the script looks for.

This patch fixes the issue by adding pattern matching to extract_symbols.py
to recognize and export Registry static data members.

Note: When LLVM is built with /Zc:dllexportInlines-, inlined functions
aren't exported as symbols, and the plugin must also compile with
/Zc:dllexportInlines- to inline them instead of referencing non-exported
symbols.

Fixes #163367
---
 llvm/utils/extract_symbols.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/utils/extract_symbols.py b/llvm/utils/extract_symbols.py
index 388723421d660..72f992f560c7f 100755
--- a/llvm/utils/extract_symbols.py
+++ b/llvm/utils/extract_symbols.py
@@ -105,6 +105,11 @@ def should_keep_microsoft_symbol(symbol, calling_convention_decoration):
     # Skip X86GenMnemonicTables functions, they are not exposed from llvm/include/.
     elif re.match(r"\?is[A-Z0-9]*@X86 at llvm", symbol):
         return None
+    # Keep Registry<T>::Head and Registry<T>::Tail static members for plugin support.
+    # Pattern matches: ?Head@?$Registry@<template_args>@llvm@@ or ?Tail@?$Registry at ...
+    elif ("?$Registry@" in symbol and "@llvm@@" in symbol and
+          (symbol.startswith("?Head@") or symbol.startswith("?Tail@"))):
+        return symbol
     # Keep mangled llvm:: and clang:: function symbols. How we detect these is a
     # bit of a mess and imprecise, but that avoids having to completely demangle
     # the symbol name. The outermost namespace is at the end of the identifier



More information about the llvm-commits mailing list