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

.min and .floor operations for f64 types are non-functional on MIPS #34906

Closed
johnnyman727 opened this issue Jul 18, 2016 · 5 comments
Closed

Comments

@johnnyman727
Copy link

johnnyman727 commented Jul 18, 2016

I'm building Rust code for Tessel 2 using some instructions created by @badboy here.

Simple scripts compiled on the Rust playground and my personal computer work fine but fail for different reasons on Tessel (which has a MIPS architecture).

let testVal: f64 = 546.54;
assert!(testVal.floor(), 546); // Returns 546.54 instead
assert!(testVal.min(0)); // Returns 546.54 instead

Let me know if there are any other details I can provide to help debug!

@nagisa
Copy link
Member

nagisa commented Jul 18, 2016

Output of --emit=llvm-ir,asm (should output two files with .ll and .s extensions) would be useful.

testVal.float()

Contradiction with the issue title. Moreover assert is a macro (you’re missing a !) and assert!(testVal.floor(), 546); wouldn’t compile due various reasons.

@kevinmehall
Copy link
Contributor

I suspect this is due to a mismatch of float ABI (Tessel's OpenWrt uses soft float, while Rust's mipsel-unknown-linux-gnu default target uses hard float).

The following program succeeded on Tessel 2 with a custom target.json. I rebuilt libstd using that target, using a compiler-rt built with the GCC from the OpenWrt build system.

fn main() {
    let test_val: f64 = 546.54;
    assert_eq!(test_val.floor(), 546.0);
    assert_eq!(test_val.min(0.0), 0.0);
    println!("ok");
}

So this isn't really a rust-lang/rust bug, beyond a 👍 for something like RFC 1133 that makes it easier to use customized target options.

@japaric
Copy link
Member

japaric commented Jul 19, 2016

@kevinmehall Note that you are mixing different ABIs here: The OpenWRT toolchain is using uclibc and the Rust target (mips*-*-*-gnu) expects glibc. These two libcs are not ABI compatible (actually, uclibc never became ABI stable). This combination is not guaranteed to always work.

(Thought most of the problems you observed are likely caused by the float ABI mismatch.)

@alexcrichton
Copy link
Member

Thanks for the investigation @kevinmehall! Sounds like this is expected from ABI differences, so I'm going to close.

@johnnyman727
Copy link
Author

Thanks @nagisa for pointing out the syntax/functional issues with my example. I've updated for posterity's sake.

Thanks @kevinmehall for investigating the ABI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants