Repository navigation
fix(stm32-mbed): emit depfiles so included sketches/headers invalidate objects - #1950
Merged
Merged
Conversation
…e objects
ArduinoCore-mbed's variants/<name>/{c,cxx,ld}flags.txt are only the body of
Arduino's compile recipe: the -MMD that makes gcc write a per-TU .d lives in
platform.txt's recipe, which this build path never replays. Every other MCU
config carries -MMD in its JSON, so the mbed path was the only one producing
zero depfiles and CompilerBase::needs_rebuild degraded to a source-mtime
comparison of the GENERATED main.cpp -- which never moves when an included
sketch tab or header is edited, so a stale object kept reporting success
(#1948).
Split the mcu-config builder into a pure flag-text function so the policy is
testable without an installed framework, append -MMD, and guard the whole
checked-in config set with a test that fails if any config declares no -MMD.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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
ArduinoCore-mbed'svariants/<name>/{c,cxx,ld}flags.txtare only the body ofArduino's compile recipe. The
-MMDthat makes gcc write a per-TU.dlives inplatform.txt's recipe, which the mbed build path never replays. Every other MCUconfig (
stm32f1/f4/h7/u5,sam*,teensy*,esp32*, …) carries-MMDin itsJSON, so the Arduino-mbed path was the only one producing zero depfiles.
CompilerBase::needs_rebuildthen degrades to a source-mtime comparison — and forthe generated
main.cppthat source's mtime never moves when the sketch tab or aheader it includes is edited. A build could therefore report
compilation succeededwhile reusing an object built from a sketch that no longer compiles.Reported in #1948 (
bash compile stm32h747xi --examples Blink).Real repro (installed fbuild 2.5.50, before this change)
Minimal
giga_r1_m7project,src/main.cppincludessrc/widget.h:find .fbuild -name '*.d' | wc -l→ 0#error PROBE_REACHEDtosrc/widget.h, build 2 →build succeeded in 3.3s,object mtime unchanged (
09:09:49.101),PROBE_REACHEDabsent from the outputmain_34d2.cpp.o+.cmdhash, build 3 →src/widget.h:3:2: error: #error PROBE_REACHED— the header really was broken; only the dependency check missed itChange
arduino_mbed_mcu_config_from_variant_text(a pure split ofbuild_arduino_mbed_mcu_config, so the flag policy is testable without aninstalled framework) appends
-MMDto the shared compile flags, matching everyJSON MCU config.
arm-none-eabi-g++ -c -MMD TU.cpp -o TU.cpp.owritesTU.cpp.d, which is exactlythe
object.with_extension("d")pathneeds_rebuildreads and matches theworkspace-relative prerequisites
compile_cwd_from_outputresolves against.Tests
mbed_flags_request_a_depfile_so_included_files_invalidate— exactly one-MMD;-cand-std=never leak into the shared block; the flag survives into bothc_flagsandcpp_flags.every_mcu_config_json_requests_a_depfile— walks all 24 checked-in MCU JSONconfigs and fails if any declares no
-MMD, so a new platform cannot shipwithout dependency tracking.
-MMDfromstm32u5.json→ test 2 RED.soldr cargo test -p fbuild-build-arm --lib→ 254 passed, 0 failed, 2 ignored(includes both new tests);
ci/enforce_platform_boundary.py --print-totals→rows=44; dylint_rows=43rc 0;ci/check_test_layout.py→ ok;soldr lint rust --cross-dylint→ rc 0.Notes
recompiles the mbed boards' core once. Steady state is unchanged.
fbuildalways runs builds inthe daemon provisioned by the installed tool, so worktree code cannot be
exercised daemon-side. The flag contract is unit-tested and the depfile naming
is asserted against the real gcc.