You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incremental build reuses main.cpp object when only the included sketch .ino changes #1948
Seen from FastLED on 2026-11-07, board stm32h747xi (giga_r1_m7, ststm32/arduino), via bash compile stm32h747xi --examples Blink.
The generated src/main.cpp is #include "sketch/Blink.ino". When only Blink.ino changes, fbuild reuses .fbuild/build/release/src/main_<hash>.cpp.o and reports success.
Repro:
Build once.
Append #error PROBE_REACHED to examples/Blink/Blink.ino and build again. Result: Compilation succeeded in about 2 s, and the object's mtime is unchanged.
Remove main_<hash>.cpp.o and .cmdhash, then build again. Result: src/sketch/Blink.ino:92:2: error: #error PROBE_REACHED.
So the dependency check for main.cpp does not include the headers or sketch files it includes, at least on this target; the .cmdhash covers only the command line. A build can therefore pass without compiling the current sketch, so 'compiles for board X' results can be stale.
Root cause — not the .cmdhash: the Arduino-mbed STM32 path emitted no
depfile at all. build_arduino_mbed_mcu_config built its flags from ArduinoCore-mbed/variants/<name>/cflags.txt, which is only the body of
Arduino's compile recipe — the -MMD lives in platform.txt's recipe, which
fbuild never replays. Every other MCU config carries -MMD in its JSON
(stm32f1/f4/h7/u5, sam*, teensy*, esp32*, rp2040, …), so this path was
the only one producing zero .d files, and CompilerBase::needs_rebuild fell
through to src_time > obj_time — where src is the generatedmain.cpp,
whose mtime never moves when only an included tab/header is edited.
Reproduced before the fix with a minimal giga_r1_m7 project (no FastLED
needed — the mechanism is generic to this path):
Fix — append -MMD to the mbed shared compile flags (deduped), matching
every JSON config. gcc's naming was verified against the real toolchain: arm-none-eabi-g++ -c -MMD TU.cpp -o TU.cpp.o writes TU.cpp.d, i.e. exactly object.with_extension("d"), with workspace-relative prerequisites that compile_cwd_from_output already resolves.
Tests — mbed_flags_request_a_depfile_so_included_files_invalidate (exactly
one -MMD; -c/-std= never leak into the shared block; the flag reaches both c_flags and cpp_flags) and every_mcu_config_json_requests_a_depfile
(walks all 24 checked-in MCU configs, so a new platform cannot ship without
dependency tracking). Both mutation-checked RED. fbuild-build-arm --lib: 254
passed. CI green including the board matrix — the Arduino GIGA R1 M7 / build
job on this PR and Build STM32H747XI on the merge commit both pass with the new
flags.
Two caveats worth knowing:
Adding a flag changes the rebuild signature, so the first mbed build after
upgrading recompiles that board's core once.
Re-running your exact stale-object repro needs a release that carries this
commit: fbuild always builds in the daemon provisioned by the installed
tool, so a fix cannot be exercised in-place from a checkout. Re-open if the
probe still reports "succeeded" on a build whose .fbuild contains no *.d files.
Activity
zackees commentedon Nov 7, 2026
Fixed by #1950 (squashed as
e48d9bd9).Root cause — not the
.cmdhash: the Arduino-mbed STM32 path emitted nodepfile at all.
build_arduino_mbed_mcu_configbuilt its flags fromArduinoCore-mbed/variants/<name>/cflags.txt, which is only the body ofArduino's compile recipe — the
-MMDlives inplatform.txt's recipe, whichfbuild never replays. Every other MCU config carries
-MMDin its JSON(
stm32f1/f4/h7/u5,sam*,teensy*,esp32*,rp2040, …), so this path wasthe only one producing zero
.dfiles, andCompilerBase::needs_rebuildfellthrough to
src_time > obj_time— wheresrcis the generatedmain.cpp,whose mtime never moves when only an included tab/header is edited.
Reproduced before the fix with a minimal
giga_r1_m7project (no FastLEDneeded — the mechanism is generic to this path):
Fix — append
-MMDto the mbed shared compile flags (deduped), matchingevery JSON config. gcc's naming was verified against the real toolchain:
arm-none-eabi-g++ -c -MMD TU.cpp -o TU.cpp.owritesTU.cpp.d, i.e. exactlyobject.with_extension("d"), with workspace-relative prerequisites thatcompile_cwd_from_outputalready resolves.Tests —
mbed_flags_request_a_depfile_so_included_files_invalidate(exactlyone
-MMD;-c/-std=never leak into the shared block; the flag reaches bothc_flagsandcpp_flags) andevery_mcu_config_json_requests_a_depfile(walks all 24 checked-in MCU configs, so a new platform cannot ship without
dependency tracking). Both mutation-checked RED.
fbuild-build-arm --lib: 254passed. CI green including the board matrix — the
Arduino GIGA R1 M7 / buildjob on this PR and
Build STM32H747XIon the merge commit both pass with the newflags.
Two caveats worth knowing:
upgrading recompiles that board's core once.
commit:
fbuildalways builds in the daemon provisioned by the installedtool, so a fix cannot be exercised in-place from a checkout. Re-open if the
probe still reports "succeeded" on a build whose
.fbuildcontains no*.dfiles.