Conversation
cezarbbb
force-pushed
the
142119-libm-shadowing
branch
from
September 21, 2026 01:53
48d367b to
ad6c9ea
Compare
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
cezarbbb
force-pushed
the
142119-libm-shadowing
branch
2 times, most recently
from
September 21, 2026 03:07
4cd5271 to
bc52f25
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix issue #142119 (Not yet)
compiler-builtins emits weak definitions for the f32/f64 math functions (its
full_availabilitymodule) sono_stdtargets without a system libm still work. The trouble is that when the link also records libm (-lm), those weak definitions come before-lmand get pulled in first, soceilf/sqrtfand friends resolve to compiler-builtins instead of glibc (#142119). This bites in two places: binaries/cdylibs where rustc does the link itself, and staticlibs that bundle the weak definitions for the consumer.For the self-link case this emits
-lmbefore the upstream rlibs on glibc targets that record-lm, so glibc's strong definitions win. I chose to move-lmforward rather than move compiler-builtins back, because moving only-lmfixes the math symbols without also flipping which of the compiler-builtins/libgcc intrinsic overlaps wins — those stay as they are.For staticlibs it omits the 28 overlapping weak f32/f64 math members from compiler-builtins' rlib when
-lmis recorded, so the consumer's libm provides them. (The rename-based alternative was discussed on Zulip and set aside.) There's a run-make test covering the positive case, theno--lmcontrol, and a check that the omission isn't a blanket strip (f16/f128 and integer fallbacks survive).This is a draft to get the direction in front of people. The staticlib skip depends on compiler-builtins being left out of LTO (
ignored_for_lto) — that's the only reason its members are still individual objects to skip, and thedebug_assert!inlink_staticlibspells that assumption out. @bjorn3 floated the idea of moving rustc-driven LTO into link_binary, which would let us skip objects before the LTO merge instead of relying on that; nothing along those lines has landed yet, so I've kept the assert to flag it and would adapt the skip when (if) that happens. The main thing still open is which symbols to omit — whether the 28-symbol list is the right cut, or f16/f128/roundeven should be included too.r? @bjorn3 @tgross35