Linking a Rust staticlib unexpectedly changes C math functions from libm to bundled ones from compiler-builtins #142119
Labels
A-compiler-builtins
Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins)
A-linkage
Area: linking into static, shared libraries and binaries
C-bug
Category: This is a bug.
I-prioritize
Issue: Indicates that prioritization has been requested for this issue.
regression-from-stable-to-stable
Performance or correctness regression from one stable version to another.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
Code
Given a staticlib with the source:
compiled as
crate-type = ["staticlib"]
and the C program:When linking the program like this:
$(CC) main.o as-crate/target/debug/libas_crate.a -lm -o out/tgt-from-crate
the resulting binary ends up usingceilf
from compiler-builtins rather than libm.I expected to see this happen: The binary should still get ceilf from libm, eg
Instead, this happened: Instead, the ceilf symbol was satisfied by the matching symbol in compiler-builtins, and so the C call was surprise-migrated to a different implementation.
Version it worked on
1.86
rustc --version --verbose
:Version with regression
1.87
rustc --version --verbose
:Additional information
I suspect this is related to some work tracked in #137578. I also found out Chromium has already stumbled on this: https://issues.chromium.org/issues/419258012#comment5 and for them it caused observable behavior changes. Apologies for not catching this sooner - we hadn't upgraded compiler-builtins for a while and didn't notice until a couple of weeks ago. :(
The text was updated successfully, but these errors were encountered: