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

Run the full test suite on 32-bit platforms #9837

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

alexcrichton
Copy link
Member

This commit switches to running the full test suite in its entirety (./ci/run-tests.sh) on 32-bit platforms in CI in addition to 64-bit platforms. This notably adds i686 and armv7 as architectures that are tested in CI.

Lots of little fixes here and there were applied to a number of tests. Many tests just don't run on 32-bit platforms or a platform without Cranelift support, and they've been annotated as such where necessary. Other tests were adjusted to run on all platforms a few minor bug fixes are here as well.

This commit switches to running the full test suite in its entirety
(`./ci/run-tests.sh`) on 32-bit platforms in CI in addition to 64-bit
platforms. This notably adds i686 and armv7 as architectures that are
tested in CI.

Lots of little fixes here and there were applied to a number of tests.
Many tests just don't run on 32-bit platforms or a platform without
Cranelift support, and they've been annotated as such where necessary.
Other tests were adjusted to run on all platforms a few minor bug fixes
are here as well.

prtest:full
@alexcrichton alexcrichton requested review from a team as code owners December 16, 2024 21:30
@alexcrichton alexcrichton requested review from cfallin and fitzgen and removed request for a team December 16, 2024 21:30
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

I'll defer to @fitzgen on the Pulley interpreter changes but a few thoughts on the conditional logic -- my main thought is that I'd prefer we didn't conflate "32-bit host" with "has no backend" and instead of a specific feature (or other method) meaning "we have a native codegen backend for the host platform"; seems less likely to cause unintentional issues later.

cranelift/filetests/src/function_runner.rs Outdated Show resolved Hide resolved
cranelift/filetests/src/test_run.rs Outdated Show resolved Hide resolved
cranelift/src/run.rs Outdated Show resolved Hide resolved
@alexcrichton alexcrichton mentioned this pull request Dec 17, 2024
12 tasks
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:aarch64 Issues related to AArch64 backend. pulley Issues related to the Pulley interpreter wasmtime:api Related to the API of the `wasmtime` crate itself labels Dec 17, 2024
Copy link

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "cranelift", "cranelift:area:aarch64", "cranelift:area:machinst", "pulley", "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: pulley

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Just looked at the runtime and pulley changes themselves since Chris looked at the other parts.

Comment on lines +7 to +15
// Flag pulley as enabled unconditionally on 32-bit targets to ensure that
// wasm is runnable by default like it is on other 64-bit native platforms.
// Note that this doesn't actually enable the Cargo feature, it just changes
// the cfg's passed to the crate, so for example care is still taken in
// `Cargo.toml` to handle pulley-specific dependencies on 32-bit platforms.
let target_pointer_width = std::env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap();
if target_pointer_width == "32" {
println!("cargo:rustc-cfg=feature=\"pulley\"");
}
Copy link
Member

Choose a reason for hiding this comment

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

Here I think it is worth explicitly checking against our ISAs supported by Cranelift.

Comment on lines +100 to +106
# On 32-bit platforms where Cranelift currently doesn't have any supported host
# unconditionally pull in the `pulley-interpreter` crate. Runtime support is
# enabled via `build.rs` which prints `feature="pulley"` by default here and
# compilation support, if enabled via the `cranelift` feature, is handled in the
# `wasmtime-cranelift` crate enabling Pulley on 32-bit platforms.
[target.'cfg(target_pointer_width = "32")'.dependencies]
pulley-interpreter = { workspace = true }
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this happen automatically when the build script enables the feature?

@alexcrichton
Copy link
Member Author

Ok I've been thinking about how to clean this up. For the tests that @cfallin flagged I added logic to them all to check cranelift_native::builder() and see whether that's an error. That indicates whether the native platform is supported by Cranelift and tests will early-return if that's an error.

@fitzgen for your points though I'm not sure how to make it better. I'll note that the cargo:rustc-cfg in the build script is not enabling the pulley feature, it's just affecting the --cfg flags to the compiler. Accurately reflecting Cranelift's supported architecture would mean having:

[target.'cfg(not(any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "s390x", target_arch = "riscv64")))'.dependencies]
pulley-interpreter = { workspace = true }

And then reflecting that same condition into build.rs

This feels "zoomed out" enough to me that leaving target_pointer_width = "32" as a proxy there for now is probably sufficient, but I want to confirm with you and/or see if you know of a way to simplify this.

@fitzgen
Copy link
Member

fitzgen commented Dec 17, 2024

That cfg is certainly annoying but seems like it is probably better than baking in new assumptions that we know are unlikely to be true for too long?

@alexcrichton
Copy link
Member Author

To clarify though the precise assumption here is that 32-bit platforms don't have a Cranelift backend so pulley is pulled in as a dependency. This doesn't actually change any logic internally within Cranelift or Wasmtime, it just compiles in Pulley by default without a way to turn that off. That's only a problem with respect to binary size.

If all of Cranelift's currently supported architectures are listed out here then that's duplicated in two places in Wasmtime (not counting the ones in Cranelift) and they're just going to get blindly added to in the future. Alternatively if Cranelift gets a 32-bit backend then that would be added as an exception to the cfg as-is when binary size becomes a problem.

To me this is six-to-one-half-dozen-or-the-other where I have a preference for what's as-is as it's a managable cfg that's by-default workable for most platforms (it doesn't work for 64-bit platforms without a Cranelift backend). Listing out architectures individually feels "just as bad" to me basically.

The main alternative to me is that we leave pulley disabled by default on all platforms, regardless of Cranelift support. That feels like a worse experience to me though because it means that Wasmtime only works by default on Cranelift-supported platforms, which if someone's new to Wasmtime they might not understand to enable the Pulley backend.

@alexcrichton
Copy link
Member Author

ping @fitzgen on ^

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 Issues related to the Cranelift code generator pulley Issues related to the Pulley interpreter wasmtime:api Related to the API of the `wasmtime` crate itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants