Skip to content
Merged
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
8 changes: 6 additions & 2 deletions lib/Driver/WebAssemblyToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,16 @@ toolchains::WebAssembly::constructInvocation(const DynamicLinkJobAction &job,

// WebAssembly doesn't reserve low addresses But without "extra inhabitants"
// of the pointer representation, runtime performance and memory footprint are
// worse. So assume that compiler driver uses wasm-ld and --global-base=1024
// to reserve low 1KB.
// worse. So assume that compiler driver uses wasm-ld and --global-base=4096
// to reserve low 4KB.
Arguments.push_back("-Xlinker");
Arguments.push_back(context.Args.MakeArgString(
Twine("--global-base=") +
std::to_string(SWIFT_ABI_WASM32_LEAST_VALID_POINTER)));
Arguments.push_back("-Xlinker");
Arguments.push_back(context.Args.MakeArgString(
Twine("--table-base=") +
std::to_string(SWIFT_ABI_WASM32_LEAST_VALID_POINTER)));

// These custom arguments should be right before the object file at the end.
context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group);
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/swift/shims/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@

// WebAssembly doesn't reserve low addresses. But without "extra inhabitants" of
// the pointer representation, runtime performance and memory footprint are
// worse. So assume that compiler driver uses wasm-ld and --global-base=1024 to
// reserve low 1KB.
// worse. So assume that compiler driver uses wasm-ld and --global-base=4096 to
// reserve low 4KB.
#define SWIFT_ABI_WASM32_LEAST_VALID_POINTER 4096

#endif // SWIFT_STDLIB_SHIMS_ABI_SYSTEM_H