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

stage2: wasm - Initial C-ABI implementation #11521

Merged
merged 2 commits into from Apr 26, 2022

Conversation

Luukdegram
Copy link
Sponsor Member

This implements an initial round of changes to support the C-ABI as specified by https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md.

The goal of these changes is to implement the base required to support linking with compiler-rt. As compiler-rt will be built by the LLVM backend by default, we must ensure the ABI's between the backends match. Above mentioned C-ABI matches that of clang to ensure we have maximum compatibility with other compilers as well.

There are definitely some rough edges with regards to branching (in the backend) and codegen that could be improved. But before doing that, I'd like to implement basic compiler-rt linking first, so I get a better view of how to structure the backend.

In the near future, I'd like to enable the C-ABI tests specified in https://github.com/ziglang/zig/tree/master/test/stage1/c_abi for the wasm backend as well.

This implements the C-ABI convention as specified by:
https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md
While not an official specification, it's the ABI that is output by clang/LLVM.
As we use LLVM to compile compiler-rt, and want to integrate with C-libraries,
we follow the same convention when the calling convention results in 'C'.
This implements passing arguments and storing return values correctly
for the C-ABI as specified by the tool-convention:
https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md

There's definitely room for better codegen in follow-up commits.
@Luukdegram Luukdegram merged commit 5f2d0d4 into ziglang:master Apr 26, 2022
@Luukdegram Luukdegram deleted the wasm-abi branch April 26, 2022 10:20
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

1 participant