Skip to content

zephyr-cp: do not rerun the sysbuild configure for every language build - #11424

Merged
dhalbert merged 5 commits into
adafruit:mainfrom
dhalbert:zephyr-skip-reconfigure
Sep 20, 2026
Merged

dhalbert merged 5 commits into
adafruit:mainfrom
dhalbert:zephyr-skip-reconfigure

Conversation

@dhalbert

Copy link
Copy Markdown
Collaborator

Claude found and fixed this, reviewed by @dhalbert.

Problem

ports/zephyr-cp/Makefile gives west build cmake arguments on every invocation, and west reruns the full two-pass sysbuild configure whenever it gets any. The release build does that 17 times per board, once per language, although the language only affects the build_circuitpython.py step; TRANSLATION is not used anywhere else in cmake. On the 4-core runner that is an estimated 10-20 s of each language build after #11416, roughly 80-150 runner-minutes per main build across the 30 boards.

Changes

  • build_circuitpython.py takes the translation from a TRANSLATION environment variable when set, then from the cmake argument, then en_US.
  • The Makefile exports TRANSLATION to the recipe and records the west arguments (board, shields, cmake arguments) in <build>/west_configure_args.txt. It runs the configuring west build -b ... --sysbuild -- ... only when the build directory is new or the recorded arguments differ; otherwise it runs west build -d <build>, which is ninja only. ninja still reconfigures by itself when a Kconfig, overlay or CMake file changes, so the record only has to cover argument changes such as DEBUG=1 or a different SHIELD.
  • The record is written before west runs and removed if west fails, so a failed configure cannot leave the directory configured with arguments the record does not show.

Together with #11416, this makes the zephyr-cp builds work like the make-based ports: building another language regenerates the translation data, recompiles the few files that use it and relinks, with no configure step.

Verification

Feather RP2040 build, locally, with #11422 and #11423 applied.

Step Configure passes CircuitPython compiles
fresh en_US 2 412
no change 0 0
de_DE 0 3
back to en_US 0 2
DEBUG=1 2, debug.conf merged, record updated 412 (flags changed)
DEBUG=1 again 0 0
without DEBUG 2 412
configure made to fail (missing fragment) 2, exits non-zero, record removed
next normal build 2, succeeds 0
and once more 0 0

The incremental de_DE binary is byte-identical to a clean de_DE build at the same path. cptools tests pass.

Depends on #11423 for DEBUG=1 to work at all; independent of it otherwise.

The Makefile gave west cmake arguments on every build, and west reruns the whole sysbuild configure whenever it gets any. The release build does that 17 times per board, once per language, for a change that only affects `build_circuitpython.py`.

Pass `TRANSLATION` to `build_circuitpython.py` in the environment instead of as a cmake variable, and run the configure only when the build directory is new or the west arguments differ from the ones recorded at the last configure. ninja still reconfigures on its own when a Kconfig, overlay or CMake file changes. The record is written before west runs and removed if it fails, so a failed configure cannot leave the directory configured with arguments the record does not show.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
mikeysklar
mikeysklar previously approved these changes Sep 20, 2026

@mikeysklar mikeysklar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turning DEBUG=1 off again does not work on the 8 boards with no board.conf: make DEBUG=1 then plain make stays a debug build until make clean. Main does the same, so it is not from this PR. Passing the argument every time, even empty, fixed it for me, in place of the ifneq/endif around it:

WEST_CMAKE_ARGS += -Dzephyr-cp_EXTRA_CONF_FILE=$(CP_BOARD_CONF)
Step main and this PR with the change
fresh normal normal
DEBUG=1 debug debug
no DEBUG debug (wrong) normal

Checked by elf md5 and .config on raspberrypi_rpi_pico_zephyr, Linux, make 4.3. The repeat build still skips the configure with the change (3 s).

The PR itself works as described here. The inline suggestions only shorten comments.

Comment thread ports/zephyr-cp/Makefile Outdated
Comment thread ports/zephyr-cp/Makefile Outdated
Comment thread ports/zephyr-cp/cptools/build_circuitpython.py Outdated
Co-authored-by: Mikey Sklar <mikeysklar@gmail.com>
@dhalbert

Copy link
Copy Markdown
Collaborator Author

Turning DEBUG=1 off again does not work on the 8 boards with no board.conf: make DEBUG=1 then plain make stays a debug build until make clean. Main does the same, so it is not from this PR. Passing the argument every time, even empty, fixed it for me, in place of the ifneq/endif around it:

I did this in a new commit; could you re-check that? Thanks.

@dhalbert

Copy link
Copy Markdown
Collaborator Author

Claude wrote this:

Re-checked the branch at 027d6ff, which carries @mikeysklar's always-pass-the-fragment change (cce234f) and #11423.

Board Step Configure passes debug.conf merged recorded fragment
raspberrypi_rpi_pico_zephyr (no board.conf) fresh 2 no ""
again 0 ""
DEBUG=1 2 yes debug.conf
plain 2 no, .config back to normal ""
plain again 0
de_DE 0
adafruit_feather_rp2040_zephyr (has board.conf) fresh 2 no board.conf
DEBUG=1 2 yes board.conf;debug.conf
plain 2 no board.conf
plain again 0

Dropping DEBUG=1 now reconfigures on both kinds of board, the semicolon quoting from #11423 survives the change, the empty argument draws no cmake complaint, and language switches still skip the configure.

@mikeysklar mikeysklar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked 027d6ff on rpi_pico_zephyr. DEBUG=1 then plain make now goes back to the normal build, and the repeat build still skips the configure. Looks good, approved.

@dhalbert
dhalbert merged commit 9701f33 into adafruit:main Sep 20, 2026
47 checks passed
@dhalbert
dhalbert deleted the zephyr-skip-reconfigure branch September 20, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants