alexcrichton opened PR #9837 from alexcrichton:pulley-full-test-suite
to bytecodealliance:main
:
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.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested cfallin for a review on PR #9837.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #9837.
alexcrichton requested wasmtime-core-reviewers for a review on PR #9837.
alexcrichton requested fitzgen for a review on PR #9837.
alexcrichton requested wasmtime-default-reviewers for a review on PR #9837.
alexcrichton updated PR #9837.
alexcrichton updated PR #9837.
alexcrichton updated PR #9837.
cfallin submitted PR review:
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.
cfallin created PR review comment:
This is fairly counterintuitive -- could we take an
Option
or a custom enum here?Err
turning into some other meaning below seems to go against what I'd expectErr
to mean.
cfallin created PR review comment:
likewise here as above re: "has native backend" feature. Or alternatively, allowlist the natively supported ISAs; then at least when we add a new ISA we can grep for all the places ISAs are mentioned...
cfallin created PR review comment:
The non-support here has less to do with "32-bit" than "no Cranelift backend for the host architecture", right? I wonder if we could add some build-script logic to add a
cranelift-has-host-backend
feature and thencfg
on that here? My concern is otherwise that a bunch of "exclude 32-bit" conditions scattered through tests get missed if/when we do add a native backend for say arm32 or riscv32.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
I'll try to think of something better yeah, but I also don't want to go too too overboard here because the tests handled in this PR are about 1% of our tests and are probably all largely redundant with all other tests we do from a "run this on all platforms" perspective. I definitely agree with what you're thinking though, I'm also not a fan of writing these #[cfg] and I like the idea of a
build.rs
-based thing (although it may be difficult to propagate that out beyond cranelift-codegen...)
cfallin submitted PR review.
cfallin created PR review comment:
Alternate idea: could we add a method to
Engine
(orConfig
or ...) that lets the user query whether Wasmtime has a native compilation backend? Then the affected tests could early-out succeed. Such a query is probably useful for other cases too...
cfallin submitted PR review.
cfallin created PR review comment:
(Likewise at the
cranelift-native
level, or whatever other level, for Cranelift.)
cfallin edited PR review comment.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
It might help yeah, but the problem is that we have tests all over the place in all sorts of crates that need this logic. That leads to either duplication of the logic, moving tests, or something like that. Basically it's just really difficult wrangling a ubiquitous dependency on platform-specific logic when testing across platforms.
github-actions[bot] commented on PR #9837:
Subscribe to Label Action
cc @fitzgen
<details>
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 <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
fitzgen submitted PR review:
Just looked at the runtime and pulley changes themselves since Chris looked at the other parts.
fitzgen created PR review comment:
Here I think it is worth explicitly checking against our ISAs supported by Cranelift.
fitzgen created PR review comment:
Shouldn't this happen automatically when the build script enables the feature?
fitzgen submitted PR review.
fitzgen created PR review comment:
I guess we could push and dedupe the check into some common dependency, which is a bit annoying, but would otherwise work.
wasmtime-environ
?There is someone actively working on a riscv32 backend for cranelift, they've been commenting on zulip, so it would be a shame to build in new cranelift-doesn't-support-32-bit assumptions at this point...
alexcrichton updated PR #9837.
alexcrichton updated PR #9837.
alexcrichton commented on PR #9837:
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 thepulley
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 commented on PR #9837:
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 commented on PR #9837:
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 commented on PR #9837:
ping @fitzgen on ^
fitzgen submitted PR review:
I don't feel strongly enough on the issue of
cfg
s that I want to hold this up from landing. I do think writing out all the targets is slightly better than using pointer-width=32, but even better is running the full test suite on 32-bit platforms.
alexcrichton updated PR #9837.
alexcrichton commented on PR #9837:
Doing a bit of thinking on this, @fitzgen mind looking at the last commit? (https://github.com/bytecodealliance/wasmtime/pull/9837/commits/b476a2e7e414413a8c6a72de9c85db77477f93d6) It's a different strategy for enabling Pulley but it pulls the on-vs-off out of
Cargo.toml
which makes it manageable to list out targets IMO (and it's also going to be hard to forget to update because if it's not updated then the native Cranelift backend isn't used by default which would almost surely get noticed)
github-actions[bot] commented on PR #9837:
Label Messager: wasmtime:config
It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:
[ ] If you added a new
Config
method, you wrote extensive documentation for
it.<details>
Our documentation should be of the following form:
```text
Short, simple summary sentence.More details. These details can be multiple paragraphs. There should be
information about not just the method, but its parameters and results as
well.Is this method fallible? If so, when can it return an error?
Can this method panic? If so, when does it panic?
Example
Optional example here.
```</details>
[ ] If you added a new
Config
method, or modified an existing one, you
ensured that this configuration is exercised by the fuzz targets.<details>
For example, if you expose a new strategy for allocating the next instance
slot inside the pooling allocator, you should ensure that at least one of our
fuzz targets exercises that new strategy.Often, all that is required of you is to ensure that there is a knob for this
configuration option in [wasmtime_fuzzing::Config
][fuzzing-config] (or one
of its nestedstruct
s).Rarely, this may require authoring a new fuzz target to specifically test this
configuration. See [our docs on fuzzing][fuzzing-docs] for more details.</details>
[ ] If you are enabling a configuration option by default, make sure that it
has been fuzzed for at least two weeks before turning it on by default.[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html
<details>
To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.
To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.</details>
alexcrichton updated PR #9837.
alexcrichton commented on PR #9837:
I'll also call out the now-currently-last commit in this PR which is new and (somewhat) substantial. It resolves a segfault on CI which I could reproduce locally and was one of the items listed in https://github.com/bytecodealliance/wasmtime/issues/9747 namely that the setjmp/longjmp implementation for Pulley needed to restore callee-save state and this was the first time that turned up.
alexcrichton updated PR #9837.
fitzgen submitted PR review:
Latest commit seems like a good balance.
Did you happen to verify that code size didn't increase under this set up when not using Pulley?
alexcrichton updated PR #9837.
alexcrichton commented on PR #9837:
Code size is expected to increase due to the Pulley backend being unconditionally enabled in Cranelift now, but otherwise for Wasmtime itself I've confirmed that Pulley support in Wasmtime is not compiled in on x86_64 (I introduced a compile failure in the pulley-specific integration and it didn't get compiled with default features)
alexcrichton has enabled auto merge for PR #9837.
alexcrichton updated PR #9837.
alexcrichton updated PR #9837.
alexcrichton updated PR #9837.
alexcrichton updated PR #9837.
alexcrichton merged PR #9837.
Scutua submitted PR review.
Last updated: Jan 24 2025 at 00:11 UTC