Skip to content

Conversation

@alexcrichton
Copy link
Member

... And then also add an escape hatch to allow loading code. This commit is the culmination of discussion on #11506 with a proposed resolution for Wasmtime. The resolution being:

  • Wasmtime will reject loading code on x86_64-unknown-none platforms by default.
  • A new Config::x86_float_abi_ok escape hatch is added to bypass this check.
  • Documentation/errors are updated around x86_float_abi_ok to document the situation.
  • The min-platform example is updated to showcase how this is valid to run in that particular embedding (aka enable more features and sufficiently detect said features).

The basic tl;dr; is that we can't detect in stable Rust what float ABI is being used so therefore we pessimistically assume that x86_64-unknown-none is using a soft-float ABI. This is incompatible with libcalls unless they aren't actually called which is only possible when sufficiently many target features are enabled.

The goal of this commit is to be a relatively low-effort way to place a roadblock in the way of "ok ABIs are weird" but at the same time enable getting around the roadblock easily. Additionally the roadblock points to documentation about itself to learn more about what's going on here.

Closes #11506

... And then also add an escape hatch to allow loading code. This commit
is the culmination of discussion on bytecodealliance#11506 with a proposed resolution
for Wasmtime. The resolution being:

* Wasmtime will reject loading code on `x86_64-unknown-none` platforms
  by default.
* A new `Config::x86_float_abi_ok` escape hatch is added to bypass this
  check.
* Documentation/errors are updated around `x86_float_abi_ok` to
  document the situation.
* The `min-platform` example is updated to showcase how this is valid to
  run in that particular embedding (aka enable more features and
  sufficiently detect said features).

The basic tl;dr; is that we can't detect in stable Rust what float ABI
is being used so therefore we pessimistically assume that
`x86_64-unknown-none` is using a soft-float ABI. This is incompatible
with libcalls unless they aren't actually called which is only possible
when sufficiently many target features are enabled.

The goal of this commit is to be a relatively low-effort way to place a
roadblock in the way of "ok ABIs are weird" but at the same time enable
getting around the roadblock easily. Additionally the roadblock points
to documentation about itself to learn more about what's going on here.

Closes bytecodealliance#11506
@alexcrichton
Copy link
Member Author

For posterity @fitzgen I tried to get min-platform working on aarch64-unknown-none but there's relocation errors about compiling libembedding.a (Rust code for aarch64-unknown-none) into a Linux shared library. I don't know how to resolve the errors without first going off and memorizing a bunch of relocation/shared-object things about aarch64...

Turns out it doesn't go through the same path as other bits
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.

Thanks for following up from our Cranelift meeting discussion! A minor documentation thought below in the example but otherwise this looks workable for us at least...

Comment on lines +91 to +95
"sse3" => Some(id.get_feature_info()?.has_sse3()),
"ssse3" => Some(id.get_feature_info()?.has_sse3()),
"sse4.1" => Some(id.get_feature_info()?.has_sse41()),
"sse4.2" => Some(id.get_feature_info()?.has_sse42()),
"fma" => Some(id.get_feature_info()?.has_fma()),
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these features are required to bypass the libcalls or just a subset?

Copy link
Member Author

Choose a reason for hiding this comment

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

SE4.1 is sufficient if you're not using relaxed-simd, but with relaxed-simd you'll also need FMA.

@github-actions github-actions bot added wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime labels Aug 27, 2025
@github-actions
Copy link

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.

    Our documentation should be of the following form:

    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.
    
  • If you added a new Config method, or modified an existing one, you
    ensured that this configuration is exercised by the fuzz targets.

    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 (or one
    of its nested structs).

    Rarely, this may require authoring a new fuzz target to specifically test this
    configuration. See our docs on fuzzing for more 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.


To modify this label's message, edit the .github/label-messager/wasmtime-config.md file.

To add new label messages or remove existing label messages, edit the
.github/label-messager.json configuration file.

Learn more.

@alexcrichton alexcrichton enabled auto-merge August 28, 2025 16:00
@alexcrichton alexcrichton added this pull request to the merge queue Aug 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 28, 2025
@alexcrichton alexcrichton enabled auto-merge August 28, 2025 19:01
@alexcrichton alexcrichton added this pull request to the merge queue Aug 28, 2025
Merged via the queue into bytecodealliance:main with commit c7dc2d5 Aug 28, 2025
44 checks passed
@alexcrichton alexcrichton deleted the float-abis-are-weird branch August 28, 2025 19:54
bongjunj pushed a commit to prosyslab/wasmtime that referenced this pull request Oct 20, 2025
* Disallow loading code on `x86_64-unknown-none`

... And then also add an escape hatch to allow loading code. This commit
is the culmination of discussion on bytecodealliance#11506 with a proposed resolution
for Wasmtime. The resolution being:

* Wasmtime will reject loading code on `x86_64-unknown-none` platforms
  by default.
* A new `Config::x86_float_abi_ok` escape hatch is added to bypass this
  check.
* Documentation/errors are updated around `x86_float_abi_ok` to
  document the situation.
* The `min-platform` example is updated to showcase how this is valid to
  run in that particular embedding (aka enable more features and
  sufficiently detect said features).

The basic tl;dr; is that we can't detect in stable Rust what float ABI
is being used so therefore we pessimistically assume that
`x86_64-unknown-none` is using a soft-float ABI. This is incompatible
with libcalls unless they aren't actually called which is only possible
when sufficiently many target features are enabled.

The goal of this commit is to be a relatively low-effort way to place a
roadblock in the way of "ok ABIs are weird" but at the same time enable
getting around the roadblock easily. Additionally the roadblock points
to documentation about itself to learn more about what's going on here.

Closes bytecodealliance#11506

* Add audit of raw-cpuid

* Add back in check

Turns out it doesn't go through the same path as other bits

* Review comments

* Fix running floats without without custom support
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 wasmtime:config Issues related to the configuration of Wasmtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiling wasmtime for the embedding with a target of x86_64-unknown-none doesn't match Cranelift compilation

3 participants