Skip to content

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

@jsturtevant

Description

@jsturtevant

Test Case

a module/component with a simple c function that will trigger this:

int RoundToNearestInt()
{
    float c = 1.331* 24.0;
    float r = lrintf(c);
    printf("rounded answer: %f\n", r); // should print 32
    return r;
}

Steps to Reproduce

  1. Build wasmtime for an emedding using the x86_64-unknown-none. Similar to how https://github.com/bytecodealliance/wasmtime/tree/release-36.0.0/examples/min-platform does it.
    2.Then pre-compile module/component
    let mut config = Config::new();
    config.target(&triple)?;
    // If signals-based-traps are disabled then that additionally means that
    // some configuration knobs need to be turned to match the expectations of
    // the guest program being loaded.
    if !cfg!(feature = "custom") {
    config.memory_init_cow(false);
    config.memory_reservation(0);
    config.memory_guard_size(0);
    config.memory_reservation_for_growth(0);
    config.signals_based_traps(false);
    }
    let engine = Engine::new(&config)?;
    let smoke = engine.precompile_module(b"(module)")?;
    let simple_add = engine.precompile_module(

run the wasm

Expected Results

rounding is completed properly

Actual Results

incorrect result. Example above prints 31

Versions and Environment

Wasmtime version or commit: was using 34+

Operating system: Linux

Architecture: x86

Extra Info

Anything else you'd like to add?
I wasn't able to reproduce this with the min-platform example. I believe this is because its actually compiling to a platform Linux platform?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions