- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
Description
Description
When building LLVM statically (the default configuration) on Windows with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON, external plugins cannot register themselves through llvm::Registry<clang::PluginASTAction>.
Root Cause
The extract_symbols.py script, which is used to determine which symbols to export from the statically-linked executable, filters out the Registry static data members (Head and Tail) because they don't match the function signature patterns that the script looks for.
These static data members are essential for the plugin registry to work - they form the linked list that stores registered plugins.
Affected Configuration
- Build type: Static LLVM builds (the default when BUILD_SHARED_LIBSis not explicitly set toON)
- Plugin support flag: LLVM_EXPORT_SYMBOLS_FOR_PLUGINS=ON
- Platform: Windows
- Affected versions: LLVM 19 (maybe?), 20, 21, and main branch
Impact
External plugins (like Firefox's clang-plugin) cannot register through the standard llvm::Registry mechanism, breaking plugin functionality.
Solution
Modify extract_symbols.py to recognize and export Registry static data members by adding pattern matching for mangled symbols like:
- ?Head@?$Registry@<template_args>@llvm@@
- ?Tail@?$Registry@<template_args>@llvm@@
Note: When both LLVM and the plugins are built with /Zc:dllexportInlines-, the static methods (add_node(), begin()) are inlined by the plugin at call sites, so only the data symbols need to be exported.
Reproduction
This issue was discovered while enabling Clang 20 support for Firefox's clang-plugin on Windows. The plugin builds successfully but cannot register itself because the Registry symbols are not exported from clang.exe.
Related
- Initial investigation started in Mozilla Bug 1941482
- Patch proposed in PR [Windows] Fix Registry static data members not exported by extract_symbols.py in static builds with plugin support #163391