Skip to content

Conversation

@the-ssd
Copy link
Contributor

@the-ssd the-ssd commented Dec 27, 2025

Used to close #1158, allows for cranelift to be used in a no_std environment, like a kernel.

There is already #9007, which stalled.

And I am at a point I think it makes sense to ask someone what do you want to be done about FxHashMap and OnceLock. There are alternative crates that implement it, like this one (also has a comparison chart).

What is left to do:

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:meta Everything related to the meta-language. labels Dec 27, 2025
@the-ssd the-ssd changed the title Support for no_std in cranelift_codegen and cranelift_assembler_x86 Support for no_std in cranelift_codegen Jan 1, 2026
@the-ssd
Copy link
Contributor Author

the-ssd commented Jan 2, 2026

@the-ssd
Copy link
Contributor Author

the-ssd commented Jan 2, 2026

I've removed OnceLock, but MachineEnv is now recomputed each time.

@the-ssd
Copy link
Contributor Author

the-ssd commented Jan 2, 2026

core feature can be removed

let slot_offset = self.abi.get_spillslot_offset(slot);
let slot_base_to_caller_sp_offset = self.abi.slot_base_to_caller_sp_offset();
#[cfg(not(feature = "unwind"))]
let caller_sp_to_cfa_offset = 0;
Copy link
Contributor Author

@the-ssd the-ssd Jan 5, 2026

Choose a reason for hiding this comment

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

Unsure if this is correct, function always returns 0

Copy link
Member

Choose a reason for hiding this comment

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

cc @cfallin should this perhaps continue to skip this value? Or panic! since this should be unreachable? Or is 0 ok to leave in?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, if we don't have unwind then we don't have the appropriate metadata to allow a native debugger to interpret frames anyway, so we should continue. I'm a bit curious how this built in a non-unwind build before -- or was that broken because std always enabled unwind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was broken

Copy link
Member

Choose a reason for hiding this comment

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

@the-ssd OK, yep, let's do a continue in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you check if I did it correctly?
It just looks a bit wrong, like there has to be a better solution

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me!

@the-ssd the-ssd changed the title Support for no_std in cranelift_codegen Partial support for no_std in cranelift_codegen Jan 5, 2026
@github-actions github-actions bot added the cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. label Jan 6, 2026
@alexcrichton alexcrichton enabled auto-merge January 7, 2026 16:26
@alexcrichton alexcrichton added this pull request to the merge queue Jan 7, 2026
Merged via the queue into bytecodealliance:main with commit 76911c2 Jan 7, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cranelift-codegen no longer builds with no_std

3 participants