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

Improve support for completely unknown architectures #10107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexcrichton
Copy link
Member

This commit is a step in the direction of trying to make Wasmtime more portable by default. The goal here is to enable Wasmtime to compile for architectures that it has no prior knowledge of. There's a few miscellaneous locations through Wasmtime where we need architecture-specific intrinsics and such but that's all in service of Cranelift itself. Without Cranelift support none of them are necessary.

This commit plumbs a custom #[cfg] from Wasmtime's build.rs script into the crate about whether there's a supported Cranelift backend. If this isn't available some architecture-specific intrinsics are turned off and not included. An example is that vm::arch entirely disappears which is only in service of UnwindHost, which also disappears. Furthermore the helpers.c file also entirely disappears as it's not necessary on unknown architectures.

To help keep this working I've added CI to build Wasmtime for powerpc64le-unknown-linux-gnu. Wasmtime currently has no support for this architecture, although if it grows such support in the future this'll need to be changed to some other unsupported architecture.

This commit is a step in the direction of trying to make Wasmtime more
portable by default. The goal here is to enable Wasmtime to compile for
architectures that it has no prior knowledge of. There's a few
miscellaneous locations through Wasmtime where we need
architecture-specific intrinsics and such but that's all in service of
Cranelift itself. Without Cranelift support none of them are necessary.

This commit plumbs a custom `#[cfg]` from Wasmtime's `build.rs` script
into the crate about whether there's a supported Cranelift backend. If
this isn't available some architecture-specific intrinsics are turned
off and not included. An example is that `vm::arch` entirely disappears
which is only in service of `UnwindHost`, which also disappears.
Furthermore the `helpers.c` file also entirely disappears as it's not
necessary on unknown architectures.

To help keep this working I've added CI to build Wasmtime for
`powerpc64le-unknown-linux-gnu`. Wasmtime currently has no support for
this architecture, although if it grows such support in the future
this'll need to be changed to some other unsupported architecture.
@alexcrichton alexcrichton requested review from a team as code owners January 24, 2025 21:17
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team January 24, 2025 21:17
@github-actions github-actions bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Jan 24, 2025
Comment on lines +1649 to +1654
// When Cranelift has support for the host then we might be running native
// compiled code meaning we need to read the actual stack pointer. If
// Cranelift can't be used though then we're guaranteed to be running pulley
// in which case this stack poitner isn't actually used as Pulley has custom
// mechanisms for stack overflow.
#[cfg(has_cranelift_host_backend)]
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename this has_host_compiler_backend? While we don't have any target supported on Winch but not Cranelift now, it doesn't seem like it would be impossible in the future, so we should just try to be a little more precise about what we are saying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants