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
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,11 @@ extension WebAssemblyToolchain {
// The value of lowest valid address, called "global base", must be always
// synchronized with `SWIFT_ABI_WASM32_LEAST_VALID_POINTER` defined in
// apple/swift's runtime library.
let SWIFT_ABI_WASM32_LEAST_VALID_POINTER = 4096
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to be this PR specifically, but should we export this value as part of the target info that the frontend prints? That way, we don't need to have the hardcoded value duplicated across code bases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea, let me make a follow up change on the main branch!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you! I don't think we need to cherry-pick the change to release/6.2 or hold up this PR for it, but it would be excellent future-proofing and will help with other platforms where we might need to propagate this information.

commandLine.appendFlag(.Xlinker)
commandLine.appendFlag("--global-base=4096")
commandLine.appendFlag("--global-base=\(SWIFT_ABI_WASM32_LEAST_VALID_POINTER)")
commandLine.appendFlag(.Xlinker)
commandLine.appendFlag("--table-base=\(SWIFT_ABI_WASM32_LEAST_VALID_POINTER)")

// Delegate to Clang for sanitizers. It will figure out the correct linker
// options.
Expand Down
1 change: 1 addition & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,7 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertTrue(commandContainsTemporaryResponsePath(cmd, "Test.autolink"))
XCTAssertTrue(cmd.contains(.responseFilePath(.absolute(path.appending(components: "wasi", "static-executable-args.lnk")))))
XCTAssertTrue(cmd.contains(subsequence: [.flag("-Xlinker"), .flag("--global-base=4096")]))
XCTAssertTrue(cmd.contains(subsequence: [.flag("-Xlinker"), .flag("--table-base=4096")]))
XCTAssertTrue(cmd.contains(.flag("-O3")))
XCTAssertEqual(linkJob.outputs[0].file, try toPath("Test"))

Expand Down