Skip to content

Commit 9cb5e37

Browse files
[IRGen] Use PrivateLinkage for @__Swift_AST global
`.swift_ast` section is now recognized as a "metadata" section by LLVM's object emission. On WebAssembly, metadata symbols must not appear in the object file symbol table. Therefore, change the linkage of the `@__Swift_AST` global from InternalLinkage to PrivateLinkage to avoid exposing the symbol. swiftlang/llvm-project@555eaef
1 parent 2b6ea81 commit 9cb5e37

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,8 +1851,12 @@ void swift::createSwiftModuleObjectFile(SILModule &SILMod, StringRef Buffer,
18511851
llvm::ConstantDataArray::getString(IGM.getLLVMContext(),
18521852
Buffer, /*AddNull=*/false);
18531853
auto &M = *IGM.getModule();
1854+
// Use PrivateLinkage here. The ".swift_ast" section is specially recognized
1855+
// by LLVM’s object emission and classified as a "metadata" section. On
1856+
// WebAssembly, metadata symbols must not appear in the object file symbol
1857+
// table, so using PrivateLinkage avoids exposing the symbol.
18541858
auto *ASTSym = new llvm::GlobalVariable(M, Ty, /*constant*/ true,
1855-
llvm::GlobalVariable::InternalLinkage,
1859+
llvm::GlobalValue::PrivateLinkage,
18561860
Data, "__Swift_AST");
18571861

18581862
std::string Section;

0 commit comments

Comments
 (0)