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

Unexpected f32 values for println and format macros with powerpc64le-unknown-linux-gnu target #644

Closed
marcransome opened this issue Feb 23, 2022 · 1 comment
Labels
A-qemu Area: qemu runners bug

Comments

@marcransome
Copy link

marcransome commented Feb 23, 2022

The problem

The println! and format! macros yield unexpected results for f32 primitive type values when cross compiling for powerpc64le-unknown-linux-gnu.

Configuration

  • Toolchain: stable-x86_64-apple-darwin (rustc 1.58.1 (db9d1b20b 2022-01-20))
  • Target: powerpc64le-unknown-linux-gnu

Example

fn main() {
    println!("f32: {:.1}", 1.0f32);
    println!("f64: {:.1}", 1.0f64);
}

Expected result:

f32: 1.0
f64: 1.0

Output of cross run --target powerpc64le-unknown-linux-gnu (note the incorrect value printed for f32):

f32: 0.0
f64: 1.0

Additional information

It appears that the version of QEMU used for powerpc64le-unknown-linux-gnu was pinned to 3.0.1 here as a fix for issue #313. The upstream issue has supposedly been fixed and released with QEMU 4.2.0, though I'm unable to confirm for certain if this is related to the issue above.

@Alexhuszagh
Copy link
Contributor

This works as of 2f24bd4 (and likely much earlier).

cargo install cross --git https://github.com/cross-rs/cross
git clone https://github.com/Alexhuszagh/cross_issue644 && cd cross_issue644
cross run --target powerpc64le-unknown-linux-gnu

Which outputs:

    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `/linux-runner powerpc64le /target/powerpc64le-unknown-linux-gnu/debug/issue644`
f32: 1.0
f64: 1.0

The new Qemu version is 5.1.0, which fixes this and numerous other issues with floats on PowerPC architectures.

@Alexhuszagh Alexhuszagh added bug A-qemu Area: qemu runners labels May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-qemu Area: qemu runners bug
Projects
None yet
Development

No branches or pull requests

2 participants