Skip to content

Commit b735c66

Browse files
authored
Reland 'Update llvm::Registry to work for LLVM shared library builds on windows' (#109024) (#112640)
Fix missing extern templates for llvm::Registry use in other projects of llvm Windows doesn't implicitly import and merge exported symbols across shared libraries like Linux does so we need to explicitly export/import each instantiation of llvm::Registry. Updated LLVM_INSTANTIATE_REGISTRY to just be a full explicit template instantiation. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and LLVM plugins on window.
1 parent 5ee9c2c commit b735c66

File tree

15 files changed

+100
-30
lines changed

15 files changed

+100
-30
lines changed

clang-tools-extra/clang-doc/Generators.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,8 @@ std::string getTagType(TagTypeKind AS);
5555
} // namespace doc
5656
} // namespace clang
5757

58+
namespace llvm {
59+
extern template class Registry<clang::doc::Generator>;
60+
} // namespace llvm
61+
5862
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H

clang-tools-extra/clang-tidy/ClangTidyModuleRegistry.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ using ClangTidyModuleRegistry = llvm::Registry<ClangTidyModule>;
1818

1919
} // namespace clang::tidy
2020

21+
namespace llvm {
22+
extern template class Registry<clang::tidy::ClangTidyModule>;
23+
} // namespace llvm
24+
2125
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULEREGISTRY_H

clang-tools-extra/clangd/URI.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,8 @@ typedef llvm::Registry<URIScheme> URISchemeRegistry;
133133
} // namespace clangd
134134
} // namespace clang
135135

136+
namespace llvm {
137+
extern template class Registry<clang::clangd::URIScheme>;
138+
} // namespace llvm
139+
136140
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_URI_H

clang-tools-extra/clangd/refactor/Tweak.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,8 @@ prepareTweak(StringRef ID, const Tweak::Selection &S,
147147
} // namespace clangd
148148
} // namespace clang
149149

150+
namespace llvm {
151+
extern template class Registry<clang::clangd::Tweak>;
152+
} // namespace llvm
153+
150154
#endif

clang-tools-extra/include-cleaner/include/clang-include-cleaner/IncludeSpeller.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@ using IncludeSpellingStrategy = llvm::Registry<IncludeSpeller>;
4646
std::string spellHeader(const IncludeSpeller::Input &Input);
4747
} // namespace clang::include_cleaner
4848

49+
namespace llvm {
50+
extern template class Registry<clang::include_cleaner::IncludeSpeller>;
51+
} // namespace llvm
52+
4953
#endif

clang/include/clang/Basic/ParsedAttrInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "clang/Basic/AttrSubjectMatchRules.h"
1919
#include "clang/Basic/AttributeCommonInfo.h"
20+
#include "clang/Support/Compiler.h"
2021
#include "llvm/ADT/ArrayRef.h"
2122
#include "llvm/Support/Registry.h"
2223
#include <climits>
@@ -175,4 +176,8 @@ const std::list<std::unique_ptr<ParsedAttrInfo>> &getAttributePluginInstances();
175176

176177
} // namespace clang
177178

179+
namespace llvm {
180+
extern template class CLANG_TEMPLATE_ABI Registry<clang::ParsedAttrInfo>;
181+
} // namespace llvm
182+
178183
#endif // LLVM_CLANG_BASIC_PARSEDATTRINFO_H

clang/include/clang/Frontend/FrontendPluginRegistry.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define LLVM_CLANG_FRONTEND_FRONTENDPLUGINREGISTRY_H
1515

1616
#include "clang/Frontend/FrontendAction.h"
17+
#include "clang/Support/Compiler.h"
1718
#include "llvm/Support/Registry.h"
1819

1920
namespace clang {
@@ -23,4 +24,8 @@ using FrontendPluginRegistry = llvm::Registry<PluginASTAction>;
2324

2425
} // namespace clang
2526

27+
namespace llvm {
28+
extern template class CLANG_TEMPLATE_ABI Registry<clang::PluginASTAction>;
29+
} // namespace llvm
30+
2631
#endif // LLVM_CLANG_FRONTEND_FRONTENDPLUGINREGISTRY_H

clang/include/clang/Lex/Preprocessor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "clang/Lex/PPEmbedParameters.h"
3333
#include "clang/Lex/Token.h"
3434
#include "clang/Lex/TokenLexer.h"
35+
#include "clang/Support/Compiler.h"
3536
#include "llvm/ADT/APSInt.h"
3637
#include "llvm/ADT/ArrayRef.h"
3738
#include "llvm/ADT/DenseMap.h"
@@ -3060,4 +3061,8 @@ using PragmaHandlerRegistry = llvm::Registry<PragmaHandler>;
30603061

30613062
} // namespace clang
30623063

3064+
namespace llvm {
3065+
extern template class CLANG_TEMPLATE_ABI Registry<clang::PragmaHandler>;
3066+
} // namespace llvm
3067+
30633068
#endif // LLVM_CLANG_LEX_PREPROCESSOR_H

clang/include/clang/Tooling/CompilationDatabasePluginRegistry.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H
1010
#define LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H
1111

12+
#include "clang/Support/Compiler.h"
1213
#include "clang/Tooling/CompilationDatabase.h"
1314
#include "llvm/Support/Registry.h"
1415

@@ -42,4 +43,9 @@ using CompilationDatabasePluginRegistry =
4243
} // namespace tooling
4344
} // namespace clang
4445

46+
namespace llvm {
47+
extern template class CLANG_TEMPLATE_ABI
48+
Registry<clang::tooling::CompilationDatabasePlugin>;
49+
} // namespace llvm
50+
4551
#endif // LLVM_CLANG_TOOLING_COMPILATIONDATABASEPLUGINREGISTRY_H

clang/include/clang/Tooling/ToolExecutorPluginRegistry.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_CLANG_TOOLING_TOOLEXECUTORPLUGINREGISTRY_H
1010
#define LLVM_CLANG_TOOLING_TOOLEXECUTORPLUGINREGISTRY_H
1111

12+
#include "clang/Support/Compiler.h"
1213
#include "clang/Tooling/Execution.h"
1314
#include "llvm/Support/Registry.h"
1415

@@ -20,4 +21,9 @@ using ToolExecutorPluginRegistry = llvm::Registry<ToolExecutorPlugin>;
2021
} // namespace tooling
2122
} // namespace clang
2223

24+
namespace llvm {
25+
extern template class CLANG_TEMPLATE_ABI
26+
Registry<clang::tooling::ToolExecutorPlugin>;
27+
} // namespace llvm
28+
2329
#endif // LLVM_CLANG_TOOLING_TOOLEXECUTORPLUGINREGISTRY_H

0 commit comments

Comments
 (0)