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

Link errors when compiling for i386 with +soft-float #62729

Open
roblabla opened this issue Jul 16, 2019 · 4 comments
Open

Link errors when compiling for i386 with +soft-float #62729

roblabla opened this issue Jul 16, 2019 · 4 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-x86_32 Target: x86 processors, 32 bit (like i686-*) O-x86_64 Target: x86-64 processors (like x86_64-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@roblabla
Copy link
Contributor

roblabla commented Jul 16, 2019

It appears that since #61408, rust now requires fminf and fmaxf functions to be present when compiling for i386 with +soft-float (using a custom target JSON). However, compiler-builtins only expose those functions for some targets, which don't include x86.

Maybe compiler-builtins should include a target-feature = "soft-float" in the list of conditions to enable the math module?

@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-x86 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 16, 2019
@roblabla
Copy link
Contributor Author

roblabla commented Aug 11, 2019

Going to be working on this. Anyone know a way to get the list of calls LLVM can lower instructions to for soft-float ops?

Nevermind, went through the intrinsics in std::intrinsics and tested them one after the other.

@bugadani
Copy link
Contributor

bugadani commented Jun 6, 2020

This issue also affects thumbv7em-none-eabihf. Note the fminf call here: godbolt.

Build fails with note: rust-lld: error: undefined symbol: fmaxf

At least the workaround is simple enough:

#[no_mangle]
fn fminf(a: f32, b: f32) -> f32 {
    if a < b {
        a
    } else {
        b
    }
}

#[no_mangle]
fn fmaxf(a: f32, b: f32) -> f32 {
    if a > b {
        a
    } else {
        b
    }
}

jordens added a commit to jordens/compiler-builtins that referenced this issue Oct 24, 2020
alexcrichton pushed a commit to rust-lang/compiler-builtins that referenced this issue Oct 26, 2020
AaronKutch pushed a commit to AaronKutch/compiler-builtins that referenced this issue Nov 28, 2020
@TheMatten
Copy link

Same problem seems to appear on x86_64-unknown-uefi.

@phip1611
Copy link

phip1611 commented Jan 12, 2022

Since yesterday I'm investigating a similar bug and finally came to this issue just now. Maybe my issue and this one are linked (at least partially). I'm getting a similar error response when compiling a certain library for a x86_64 bare-metal target with +soft-float

My issue on Rust: #92760
My minimal reproducible error repo: https://github.com/phip1611/rust-llvm-bug-20220112-minimal-example/blob/main/README.md

The workaround from @bugadani solves the build problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-x86_32 Target: x86 processors, 32 bit (like i686-*) O-x86_64 Target: x86-64 processors (like x86_64-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants