Repository navigation
waf: only require a Picolibc parser alias the binary actually uses - #35214
Draft
peterbarker wants to merge 1 commit into
Draft
peterbarker wants to merge 1 commit into
peterbarker wants to merge 1 commit into
Conversation
The SITL parser check required both halves of each public/implementation
pair whenever either of them appeared. An implementation can be linked
in on its own, though: picolibc's strtof calls its strtod, so
ap_picolibc_strtod ends up defined in a binary which never names strtod.
On Darwin the public alias AP_Common defines for a parser nothing
references is then dropped by the linker, and the check failed a correct
binary:
Missing Picolibc SITL symbols in build/sitl_periph_universal/bin/AP_Periph: _strtod
AP_Periph on macOS carries _strtof, _atof and all three _ap_picolibc_*
symbols, and no _strtod at all - neither defined nor undefined - so
nothing in it parses a double and there is no host-libc call to
redirect. Key the requirement on the public symbol, as the malloc check
below it already does for the same reason.
Global Size Summary (Total Flash delta in bytes)Built from a8434af rebased onto a42f84a
|
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.
Summary
The SITL Picolibc parser check fails every macOS
AP_Periphbuild:The check requires both halves of each public/implementation symbol pair
whenever either appears. An implementation can be linked in on its own, so a
correct binary fails. Key the requirement on the public symbol instead, as the
malloc check beside it already does.
Classification & Testing (check all that apply and add your own)
Tools/ardupilotwaf/tests/test_symbols.pygainstest_sitl_parser_implementation_without_public_use, which presents animplementation symbol with no public alias for each of the three parsers. It
fails 3/3 against the parent commit and passes with the fix; the file's suite
is 97 passed.
On a 10-core arm64 macOS host, at the parent commit:
and with the fix applied:
The
arduplanebuild is there to show the check still runs and still passeswhere both halves of a pair are present, rather than having been defanged.
Description
libraries/AP_Common/picolibc.cppredirectsatof,strtodandstrtoftoPicolibc's implementations. On Darwin there is no
--wrap, so it defines thepublic symbol directly, via
__asm__("_strtod")and friends. The check thenverifies that a binary which uses one of those parsers really does reach
Picolibc's version rather than the host's.
Its rule was "if either name of a pair appears, both must be defined". That
premise does not hold for the implementation half, for two reasons at once:
Picolibc's own
strtofcalls itsstrtod; andAP_Periphon macOS lands in exactly that state. It defines_strtof,_atofand all three_ap_picolibc_*symbols, and contains no_strtodatall —
nm -ulists no undefined reference to it andnm -afinds nodefinition. Nothing in the firmware parses a double, so there is no host-libc
call to redirect, yet the presence of
_ap_picolibc_strtoddemanded a_strtodwhich had been correctly omitted.Requiring the pair only when the public symbol appears keeps the protection
that matters: a referenced-but-undefined
_strtodstill fails, which is thecase where a call would reach the host's locale-dependent parser. The malloc
check fifteen lines below already reasons this way — "a binary that never
calls malloc doesn't pull in the wrapper".
Linux is unaffected, which is why CI did not catch this: there the public
alias is a plain strong definition in the object file and is not stripped, so
all three pairs stay complete. The practical effect of the bug is that
build.SITLPeriphUniversal,build.SITLPeriphBattMon,test.CANandtest.BattCANcannot run on macOS at all, along with the autotests that needa peripheral binary (
DroneCANCompass,PeriphMultiUARTTunnel,CircuitStatusScript).An alternative fix would be to mark the public aliases
__attribute__((used))inAP_Common/picolibc.cpp, guaranteeing theinterposition instead of detecting its absence, at the cost of carrying
unused functions in every binary. This PR takes the smaller change, on the
grounds that the check's premise was simply wrong.
This contribution was AI-assisted: the diagnosis, the change and this
description were produced with Claude Code, and reviewed by the submitter.