Skip to content

Cranelift caller gets wrong Quat from LLVM callee on Win64 #1647

@Maxime-Verrier

Description

@Maxime-Verrier

Summary

Had a mesh rendering with the wrong rotation in my Bevy game. Traced it
down to glam::Quat::from_rotation_x(-FRAC_PI_2) returning a different
value under cranelift than under LLVM, but only when a cranelift crate is
calling into an LLVM-compiled glam.

Quat is #[repr(C, align(16))] over [f32; 4]. Under pure LLVM the call
returns (-sqrt(2)/2, 0, 0, sqrt(2)/2) like you'd expect. Under the mixed
build the value just comes back wrong. No panic, no link warning.

Configs I tried

Bevy 0.17, rustc nightly:

workspace deps link target result
cranelift llvm dylib x86_64-pc-windows-gnu wrong
cranelift llvm static x86_64-pc-windows-gnu wrong
cranelift llvm static x86_64-pc-windows-msvc wrong
llvm llvm dylib x86_64-pc-windows-gnu correct
llvm llvm static x86_64-pc-windows-gnu correct
cranelift cranelift static x86_64-pc-windows-gnu correct

Every failing row has a cranelift caller invoking an LLVM callee. Doesn't
matter whether it's static or DLL, gnu or msvc. A friend runs the same
cranelift-workspace + LLVM-deps + bevy dynamic_linking setup on
x86_64-unknown-linux-gnu with no issues, so this looks Win64-specific.

Couldn't test

Related

Can cut a smaller repo without Bevy if it'd help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-abiArea: ABI handlingC-bugCategory: This is a bug.O-windowsOperating system: WindowsO-x86_64Target: x64 processors

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions