Repository navigation
Conversation
The per-target source and include lists are built with list(APPEND) on cache variables, so on a reconfigure of an existing build directory the append starts from what the previous run left in the cache: every list gains another copy of itself, and a source file removed from a CMakeLists stays in the build until that cache entry is deleted by hand. The lists are cleared once in the top level CMakeLists, before the target subdirectories that fill them are added, so the trees where several CMakeLists contribute to the same list keep working.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe CMake build adds a macro that clears cached target source and include-directory lists. The top-level build script calls the macro during configuration before platform subdirectories repopulate those lists. ChangesCMake cached target lists
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The configure clears cached target lists before platform directories repopulate them, addressing the reported reconfigure issue. No concrete remaining merge risk was established. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
josesimoes
left a comment
There was a problem hiding this comment.
We should avoid solving this by maintaining a hard-coded list of cache variables.
This list is easy to get out of sync with the variables that are introduced by the target CMake files: a newly added source/include list may be omitted here, while a renamed or removed variable may leave stale cleanup code behind. In that case the original reconfigure bug would silently return for that target.
The underlying issue appears to be that transient, computed source/include lists are being stored in the CMake cache and then extended with list(APPEND) on subsequent configure runs. The cache persists by design, so this is not limited to unsupported local changes or an unusually dirty build directory. After all, reconfiguring an existing build tree after changing a source list is a normal CMake workflow.
The proposed likely fixes the current reported failure, but it adds a second manually maintained source-of-truth and leaves the underlying cache/state design unchanged.
Ideally we should be attaching sources and include directories directly to the relevant CMake target with target_sources() and target_include_directories(), but that requires a serious rewrite on the build system. Which is not ideal in the current time frame (develop branch in active development along with IFU).
I suggest we keep this in the to-do list and address it in a near future when that is more convinient.
For the time being, please be patient and midful of the issue on your local development work.
Description
nf_clear_cached_target_lists()macro inCMake/binutils.common.cmake, whichunsets the 37 cache variables that hold the per-target source and include lists.CMakeLists.txt, right before the RTOS dispatch, so it runs ahead of everyadd_subdirectory()that fills those lists.Motivation and Context
The lists are built with
list(APPEND ...)and then stored in the cache:list(APPEND)starts from the value already in the cache, so on every reconfigure of an existing build directory the list gains another full copy of itself, and — the part that actually breaks builds — a source file removed from a CMakeLists stays in the cache forever:Deleting that one cache entry, or the whole build directory, is the only way out today. CI never sees it because it always configures a fresh build directory; it hits developers doing incremental builds across any commit that removes a source file.
The clear is done centrally rather than per file because several trees fill one list from more than one CMakeLists —
TARGET_THREADX_COMMON_SOURCESis contributed to bytargets/ThreadX/_common,targets/ThreadX/ST/_common,targets/ThreadX/ST/_common/CubeMXand the board directory — so a reset at the top of each writing file would drop the earlier contributions. One reset in the parent scope, before the subdirectories are added, is correct for every tree and covers ChibiOS, ESP32, FreeRTOS/NXP, ThreadX and TI_SimpleLink alike.TARGET_BASE_LOCATIONand the other cached scalars are left alone: they are written with plainset(), not appended to, so they were never affected.How Has This Been Tested?
On hardware I only have ESP32 parts, so the ESP32 tree is what was exercised end to end. Everything below is on
ESP32_S3_QUAD, IDF 5.5.4, configured through the preset.The bug, reproduced on a real build directory. With the call commented out, a single reconfigure of an already configured directory:
With the fix. The same reconfigure keeps all six ESP32 lists at their correct length with no duplicates, and a directory already poisoned by the numbers above recovers to 16/13/4 on the next configure — no need to wipe it.
The failure from the issue. Removed
targetHAL_Time.cppfromtargets/ESP32/_common/CMakeLists.txtand reconfigured the existing build directory: the entry is gone fromTARGET_ESP32_IDF_COMMON_SOURCES(16 → 15). Putting the line back and reconfiguring again gives a list byte for byte identical to the first clean configure.For the other RTOS trees I read through the append chains rather than building them — the reset sits in the only scope that runs before all of them, which is what makes the multi-contributor case above safe. As you said on the issue, the pipeline can take those.
Types of changes
Checklist