Conversation
--print-file-name cannot see the library paths the specs add, so on a distro that ships picolibc outside the toolchain sysroot it answers with newlib and the image silently links a libc that is not the one being shipped.
TurkeyMan
force-pushed
the
ow/picolibc-libc-probe
branch
from
September 10, 2026 15:11
1defcd4 to
0ae1f50
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.
--print-file-nameresolves against the compiler's own search directories anddoes not consult the library paths a specs file adds. On a distro where picolibc
is the toolchain sysroot (Debian) that goes unnoticed, because the answer is
picolibc either way. On a distro that keeps picolibc outside the sysroot (Ubuntu,
/usr/lib/picolibc/<triple>/lib/) the same probe answers with newlib wheneverlibnewlib-*is also installed, and the image silently links a libc that is notthe one being shipped.
The existing tail fallback was already the correct lookup, but hardcoded to
riscv64-unknown-elfand unreachable: the probe ahead of it returns a pathrather than nothing, so
$(or ...)never advances to it.This generalises that lookup to the triple and asks it first. Debian is
unaffected (the directory does not exist, so it falls through to the specs probe
exactly as before); Ubuntu arm targets switch from newlib to picolibc, which is
what the released firmware links. Measured on openwatt's bk7231n, where newlib
costs about 20KB of flash against a 0.4% margin.