Skip to content
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

wasm-linker: finish shared-memory & TLS implementation #16439

Merged
merged 6 commits into from
Jul 19, 2023

Conversation

Luukdegram
Copy link
Sponsor Member

This fixes several bugs in the shared-memory implementation and adds TLS relocations which was the last component required to get the shared-memory linker feature fully working.

With this PR, we can now use the self-hosted WebAssembly linker to link the threading example from: #16207 (i.e. appending -fno-LLD to the listed command).

src/link/Wasm.zig Outdated Show resolved Hide resolved
test/link/wasm/shared-memory/build.zig Outdated Show resolved Hide resolved
Rather than verifying if importing memory is false, we now rely
on the option that was passed to the CLI (where export is defaulted
to `true` unless only import-memory is given).
Implements the `start` section which will execute a given function
at startup of the program. After function execution, the _start
function will be called by the runtime. In the case of shared-memory
we set this section to the function `__wasm_init_memory` which will
initialize all memory on startup.

This also fixes the above mentioned function to ensure we correctly
lower the i32 values.

Lastly, this fixes a typo where we would retrieve a global, instead
of setting its value.
Previously, they were only created when we had any TLS segment.
This meant that while the symbol existed, the global itself wouldn't.
The result of this was a crash during symbol names writing as it
would attempt to write the symbol name of a global that didn't exist.
Now we always create them, and instead update its `init` value during
`setupMemory`.

In the future, the entire symbol (and global) will be removed by
the garbage collector.
@Luukdegram Luukdegram merged commit cec1e97 into ziglang:master Jul 19, 2023
10 checks passed
@Luukdegram Luukdegram deleted the wasm-linker branch July 19, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants