Skip to content

[WASM] Avoid to emit GOT for WASM #30071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
7 changes: 7 additions & 0 deletions include/swift/IRGen/Linking.h
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,13 @@ class ApplyIRLinkage {
if (Triple.isOSBinFormatELF())
return;

// Avoid to create GOT because wasm doesn't support
// dynamic linking yet
if (Triple.isOSBinFormatWasm()) {
GV->setDSOLocal(true);
return;
}

if (IRL.Linkage == llvm::GlobalValue::LinkOnceODRLinkage ||
IRL.Linkage == llvm::GlobalValue::WeakODRLinkage)
if (Triple.supportsCOMDAT())
Expand Down
5 changes: 5 additions & 0 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2910,6 +2910,11 @@ IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity) {
return {gotEquivalent, ConstantReference::Indirect};
};

// Avoid to create GOT because wasm32 doesn't support
// dynamic linking yet
if (TargetInfo.OutputObjectFormat == llvm::Triple::Wasm) {
return direct();
}
// The integrated REPL incrementally adds new definitions, so always use
// indirect references in this mode.
if (IRGen.Opts.IntegratedREPL)
Expand Down