Skip to content

[Windows] Registry static data members not exported by extract_symbols.py, breaking plugin support in static builds #163367

@zond

Description

@zond

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_LIBS is not explicitly set to ON)
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions