From c61e6edc21c8f76f4e8e4a9484cdda46cb1f56e8 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sat, 19 Sep 2026 00:02:50 -0400 Subject: [PATCH] zephyr-cp: create libcircuitpython.a from scratch on every build `cpbuild.archive()` updated the archive with `ar rvs`, which replaces the members named on the command line and keeps every other member. After the en_US build of a release job, each later language added its own `translations-.o` and `autogen_display_resources-.o` but the en_US members stayed in the archive ahead of them, and the linker used the English ones. Every non-en_US zephyr-cp firmware shipped this way has the English compressed strings with another language's decompression tables; on a Feather RP2040 the 10.3.1 fr build has an unresponsive REPL. Delete the archive before running `ar rcs`. The archive is now rebuilt on every build, under a second for ~450 objects. Co-Authored-By: Claude Fable 5.1 --- ports/zephyr-cp/cptools/cpbuild.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ports/zephyr-cp/cptools/cpbuild.py b/ports/zephyr-cp/cptools/cpbuild.py index d76f5d34855..8121f4b8016 100644 --- a/ports/zephyr-cp/cptools/cpbuild.py +++ b/ports/zephyr-cp/cptools/cpbuild.py @@ -434,8 +434,13 @@ async def compile( async def archive(self, objects: list[pathlib.Path], output_file: pathlib.Path): output_file.parent.mkdir(parents=True, exist_ok=True) responsefile = output_file.with_suffix(".rsp") + # Always create the archive from scratch. `ar r` on an existing archive replaces the + # members named on its command line and keeps every other member, so after a build + # of another language the old translations-*.o and autogen_display_resources-*.o + # stayed in the archive ahead of the new ones and the linker used them. + output_file.unlink(missing_ok=True) await run_command( - [self.ar, "rvs", output_file, *objects], + [self.ar, "rcs", output_file, *objects], description=f"Create archive {output_file.relative_to(self.srcdir)}", working_directory=self.srcdir, responsefile=responsefile,