Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions clang/tools/driver/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

using namespace clang;
using namespace clang::driver;
using namespace llvm::opt;
Expand Down
5 changes: 5 additions & 0 deletions llvm/utils/extract_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -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@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@...
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
Expand Down