Allow cranelift and satellite crates to be able to build in full no-std mode#13607
Open
stevefan1999-personal wants to merge 2 commits into
Open
Allow cranelift and satellite crates to be able to build in full no-std mode#13607stevefan1999-personal wants to merge 2 commits into
stevefan1999-personal wants to merge 2 commits into
Conversation
bjorn3
reviewed
Jun 10, 2026
Contributor
There was a problem hiding this comment.
I feel like if you want a no_std JIT, you should make your own cranelift_module::Module implementation instead tailored to the constraints of your OS.
Member
|
Is your motivation here @stevefan1999-personal tied to using Wasmtime-with-Cranelift-enabled in a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is the part 1 of the 2 to convert wasmtime into no-std build capable runtime, that makes Cranelift crates to be able to build in fully no-std mode with hopefully minimal code changes, which is needed because https://github.com/wasmi-labs/wasmi lacked so many features I needed.
The first step is to enable Cranelift and its satellite crates to be no-std capable, and since a platform is no longer a guarantee, which means that only Pulley interpreter is available for no-std mode, and thus no need for virtual memory support, so I added a Vec arena backed memory allocator for the "JIT" (but which honestly should be a no-op).
This is also needed because I'm also writing a C compiler, and I don't really want each unit tests to invoke the codegen which sometimes exhitbits strange memory protection error during normal
cargo test. My educated guess for that is because of the allocated JIT memory map is so frequent, but the memory protection region has overlapped with ongoing page fault, so the internal virtual memory allocator can't keep up, causing general memory protection error. Although I can sidestep it withcargo nextestwhich runs each test as an independent process for now, but I'm also curious why that would happen.I also opted for using libm entirely for the Cranelift interpreter (what's the difference between this and Pulley by the way?), that a deeper research revealed that the fundamental reason for the seemingly faulty fma behavior is due to different ISA platforms implementations, a close analogy for that is the different implementation of
long doublein x87 and in ARM NEON, which I hope could make things easy to explain. As such, I would suggest just normalize it by using libm anyway.