Repository navigation
Build: link glibc libm ahead of the Rust staticlib so math calls use VFP - #821
Merged
Merged
Conversation
With stable Rust's prebuilt compiler_builtins, roundf/round/floorf/ceilf/ceil/trunc/fmodf/fmod/ cbrtf/sqrtf/sqrt/fma bound to compiler_builtins' weak soft-float copies because $(RUST_LIB) precedes -lm. Name -lm first so libm.so already defines them; add a check-elf.sh section and unit cases that fail on a local libm body or more than 16 soft arithmetic libcalls; correct the 'about 5 calls' comments. Part of #768. Follow-up to #816. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Part of #768. Follow-up to #816.
Cause
With stable Rust's prebuilt
compiler_builtins, every libm name our code calls (roundf, round, floorf, ceilf, ceil, trunc, fmodf, fmod, cbrtf, sqrtf, sqrt, fma) bound to compiler_builtins' WEAK soft-float copy instead of the TV's glibc libm (VFPv3, softfp).$(RUST_LIB)precedes-lmon the link line, and a definition extracted from an archive is never overridden by a shared library that comes later. roundf alone has 119 call sites in draw paths, and nanosvg's C calls insrc/svg.owent soft too. The fix names-lmahead of$(RUST_LIB)so libm.so already defines the names and the archive members are never extracted.Before / after (
make ARM_PROFILE=release, relink only for the second row)bl __aeabi_[fd](add/sub/rsub/mul/div/cmp*/2f/2d)bl __aeabi_fmulUND ...@GLIBC_2.4math symbolsvmul.f32/vsqrt.f32i64 to float conversions (
__aeabi_d2lz,__aeabi_l2d, ...) remain libcalls on ARMv7 regardless of ABI, since VFPv3 has no instruction for them.fw-compat review (manual,
.agents/agents/fw-compat-reviewer.md)Verdict: PASS, graded on a binary built from this diff. The change is link order only: no new
-l, nodynlib!/extern/dlopenchange, DT_NEEDED unchanged (15 entries,check-elf.sh).tools/fwcompat.py --min-release 4.4.2: OK on 4.4.2, 4.10.0, 5.3.1, 6.4.0, 7.4.0, 8.3.0, 9.2.0, 10.2.0, 11.2.0; the same verdicts as the pre-change binary (the older rows below the floor also match). The 11 new undefined math symbols are all resolved by libm on every gated release. This grades starting, not behavior; TV timing is separate.Tests
python3 ci/test_check_elf.py: Ran 20 tests, OK. New cases: red for a local body of each of the 12 names, red for more than 16 soft arithmetic calls, green for the fixed shape.ci/check-elf.shfails ("local definitions of libm functions (...)"); with it, "ok - no local libm bodies, 9 soft-float arithmetic calls",all ELF assertions passed.python3 ci/check-vfp.py: ok.ci/check-elf.shsection; corrected the "about 5 calls" comments in it andrust-modules/.cargo/config.toml.Pending / notes
make build-benchwas not run because the Mac is congested; CI gates.🤖 Generated with Claude Code