Repository navigation
waf: make --asan work with gcc - #34779
shine-mild wants to merge 2 commits into
Conversation
3dda81b to
50fa124
Compare
khancyr
left a comment
There was a problem hiding this comment.
Looks good.
Test change don't impact flight code so no worries on this.
if asan is now working with gcc we need to remove the comment on g.add_option('--asan') that state that is for clang.
I was able to build copter with gcc 15 and gcc 13 and asan but not running it :
╰─$ /home/pierre/Workspace/ardupilot/ardupilot/build/sitl/bin/arducopter --model + --speedup 1 --slave 0 --sim-address=127.0.0.1 -I0
Setting SIM_SPEEDUP=1.000000
../../libraries/AP_Param/AP_Param.cpp:1508:32: runtime error: 65535 is outside the range of representable values of type 'short int'
So I would say to just remove the config comment and we should be able to use this ! Thanks
|
collide with #33976 |
-fsanitize=address was only added to LINKFLAGS when the compiler was clang++, so "CC=gcc CXX=g++ ./waf configure --board sitl --debug --asan" compiled every object with ASan instrumentation and then failed to link with hundreds of undefined references to __asan_*. Add the link flag whenever --asan is given. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
The example enforces -Wframe-larger-than=2000 on loop(); ASan redzones push the frame to ~3040 bytes and the --asan build fails. Keep the check for non-ASan builds. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
50fa124 to
4d6589e
Compare
|
Thanks for the review. Updated the The runtime error you hit ( On the overlap with #33976: that PR carries the same link-flag change plus the C-side instrumentation and lsan symbol handling, which is more complete. I'm happy to drop the |
Global Size Summary (Total Flash delta in bytes)Built from 4d6589e rebased onto b032bcb
|
Summary
./waf configure --board sitl --debug --asancurrently only works with clang. With gcc the build fails in two places; this PR makes the gcc path work.Tools/ardupilotwaf/boards.py):-fsanitize=addresswas added toLINKFLAGSonly whenclang++was the compiler, so with gcc every object is instrumented and the final link fails with hundreds ofundefined reference to '__asan_report_load8'etc. Add the flag whenever--asanis given.-Wframe-larger-than=2000pragma fails (-Werror, frame becomes ~3040 bytes). Skip the check when__SANITIZE_ADDRESS__is defined. (The equivalent EKF check is already limited to ChibiOS on master, so no change is needed there.)The
--asanhelp text already says clang is required; with these changes gcc 15 builds and runsarducopter,examples/RCProtocolTestandtests/test_gsofwith ASan instrumentation.Note
Example/test binaries (APM_BUILD_UNKNOWN) still trip UBSan's null check at startup via
AP_Vehicle& vehicle = *AP_Vehicle::get_singleton();(AP_Vehicle.cpp:305) when--ubsan-abortis also enabled. That is unrelated to ASan and left for a separate change;-fno-sanitize=nullis a local workaround.Testing
CC=gcc CXX=g++ ./waf configure --board sitl --debug --asan --ubsan-abort && ./waf copter --target examples/RCProtocolTest,tests/test_gsofon Ubuntu 26.04 / gcc 15.2: links and runs; a deliberate stack overflow test program confirms the ASan runtime is active.🤖 Generated with Claude Code