Skip to content

Commit 22e85b0

Browse files
Merge pull request #84349 from kateinoigakukun/pr-c060d7df7f5ebd5db851a07367d4128bf3b3f9ec
[IRGen] Use PrivateLinkage for `@__Swift_AST` global
2 parents 494dcad + 9cb5e37 commit 22e85b0

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)