[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
Tue Oct 21 03:01:40 PDT 2025


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

>From 9b9319c1d59368f272ea79c7aff0a870be602fbe 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 | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/llvm/utils/extract_symbols.py b/llvm/utils/extract_symbols.py
index 388723421d660..0cbfd2e2910e1 100755
--- a/llvm/utils/extract_symbols.py
+++ b/llvm/utils/extract_symbols.py
@@ -105,6 +105,14 @@ 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