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

Update our baseline and generic CPU models for WebAssembly #21818

Open
Tracked by #22014
alexrp opened this issue Oct 26, 2024 · 5 comments
Open
Tracked by #22014

Update our baseline and generic CPU models for WebAssembly #21818

alexrp opened this issue Oct 26, 2024 · 5 comments
Assignees
Labels
arch-wasm 32-bit and 64-bit WebAssembly enhancement Solving this issue will likely involve adding new logic or components to the codebase. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@alexrp
Copy link
Member

alexrp commented Oct 26, 2024

Currently, we use LLVM's generic model for both the generic and baseline models. LLVM's generic model for WebAssembly somewhat annoyingly represents a moving target that can change with any given LLVM version; it's basically just "what the major implementations support at this point in time". This makes it outright wrong as a generic model by our definition, but also a bad choice for a baseline model since our notion of "baseline" means wide compatibility, and that should clearly include more than just the major WebAssembly implementations. (An example of a problematic feature currently included in generic would be reference_types.)

So, the first order of business here should be to switch our generic model to LLVM's mvp model, which, as the name implies, targets a minimum viable WebAssembly implementation with no post-1.0 features. That can be done today while still mapping baseline to LLVM's generic.

Secondly, there is a WATC proposal to add a lime1 model to LLVM to address the problem of there not being a good baseline model:

The feature set proposed there seems to me to be a very reasonable one for a baseline model. So, if that proposal is accepted, I think we should switch our baseline for WebAssembly to lime1 after we update to LLVM 20.

This may involve a bit of work in wasm2c to add support for a couple of features. Note that neither LLVM nor our self-hosted backend make use of multivalue in the mvp ABI, so we don't actually need to support that in wasm2c. That only leaves relatively simple features like nontrapping_fptoint and extended_const.

@alexrp alexrp added enhancement Solving this issue will likely involve adding new logic or components to the codebase. standard library This issue involves writing Zig code for the standard library. arch-wasm 32-bit and 64-bit WebAssembly labels Oct 26, 2024
@alexrp alexrp added this to the 0.15.0 milestone Oct 26, 2024
@alexrp alexrp self-assigned this Oct 26, 2024
@alexrp
Copy link
Member Author

alexrp commented Oct 26, 2024

cc @Luukdegram

@alexrp
Copy link
Member Author

alexrp commented Nov 19, 2024

FYI, the WATC proposal for lime1 has been merged.

@andrewrk
Copy link
Member

andrewrk commented Nov 24, 2024

Everything you said made sense to me except for this bit:

This may involve a bit of work in wasm2c to add support for a couple of features.

While I wouldn't necessarily be against adding those features to wasm2c, I think the null hypothesis would be to disable those features when generating zig1.wasm.

@alexrp
Copy link
Member Author

alexrp commented Nov 24, 2024

While I wouldn't necessarily be against adding those features to wasm2c, I think the null hypothesis would be to disable those features when generating zig1.wasm.

Right, I should have clarified that we only need to implement those minor features if we actually want to be able to build zig1.wasm against lime1 as spec'd. I personally think that's a nice thing to do just because the purpose of lime1 is specifically to be a solid baseline model for WebAssembly that most engines agree on.

Whatever we decide to do in that regard, though, I agree that the first step would be to disable any lime1 features that we don't yet support in wasm2c.

@Luukdegram
Copy link
Contributor

cc @Luukdegram

For whatever it's worth, I agree with the changes outlined in the OP. Not only does it halter LLVM upgrades, it's not always clear for users of the Zig toolchain that upgrading their compiler can potentially involve enabling cpu features when targeting WebAssembly. So overall this is a good improvement to status quo, in my opinion.

alexrp added a commit to alexrp/zig that referenced this issue Nov 29, 2024
As discussed in ziglang#21818, generic is a poor baseline model because that model is a
moving target in LLVM. Instead, use mvp, which has no features enabled.
alexrp added a commit to alexrp/zig that referenced this issue Nov 29, 2024
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
alexrp added a commit to alexrp/zig that referenced this issue Nov 29, 2024
As discussed in ziglang#21818, generic is a poor baseline model because that model is a
moving target in LLVM. Instead, use mvp, which has no features enabled.
alexrp added a commit to alexrp/zig that referenced this issue Nov 29, 2024
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
alexrp added a commit to alexrp/zig that referenced this issue Nov 29, 2024
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
alexrp added a commit to alexrp/zig that referenced this issue Nov 29, 2024
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
alexrp added a commit to alexrp/zig that referenced this issue Nov 30, 2024
As discussed in ziglang#21818, generic is a poor baseline model because that model is a
moving target in LLVM. Instead, use mvp, which has no features enabled.
alexrp added a commit to alexrp/zig that referenced this issue Nov 30, 2024
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
alexrp added a commit to alexrp/zig that referenced this issue Nov 30, 2024
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
alexrp added a commit to alexrp/zig that referenced this issue Jan 18, 2025
As discussed in ziglang#21818, generic is a poor baseline model because that model is a
moving target in LLVM. Instead, use mvp, which has no features enabled.
alexrp added a commit to alexrp/zig that referenced this issue Jan 18, 2025
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
alexrp added a commit to alexrp/zig that referenced this issue Jan 22, 2025
As discussed in ziglang#21818, generic is a poor baseline model because that model is a
moving target in LLVM. Instead, use mvp, which has no features enabled.
alexrp added a commit to alexrp/zig that referenced this issue Jan 22, 2025
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
Fri3dNstuff pushed a commit to Fri3dNstuff/zig that referenced this issue Jan 27, 2025
As discussed in ziglang#21818, generic is a poor baseline model because that model is a
moving target in LLVM. Instead, use mvp, which has no features enabled.
Fri3dNstuff pushed a commit to Fri3dNstuff/zig that referenced this issue Jan 27, 2025
…embly.

See: WebAssembly/tool-conventions#235

This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.

Part of ziglang#21818.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm 32-bit and 64-bit WebAssembly enhancement Solving this issue will likely involve adding new logic or components to the codebase. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

3 participants