Skip to content

chore: Avoid Rosetta on Apple#228

Merged
apljungquist merged 6 commits intomainfrom
no-rosetta
Mar 12, 2026
Merged

chore: Avoid Rosetta on Apple#228
apljungquist merged 6 commits intomainfrom
no-rosetta

Conversation

@apljungquist
Copy link
Copy Markdown
Collaborator

@apljungquist apljungquist commented Mar 7, 2026

This speeds up both building and using the dev container by a lot on Apple silicon, see benchmarks below. Unfortunately, the checksums do not reproduce and developers would have to either wait for PRs to fail once in CI or run the image with --platform linux/amd64.

The major workflows check_other, check_generated_files, check_generated_files_container all work in the new dev container on an aarch64 host. What doesn't work is running some apps on in the container (as opposed to on device). These can run outside the container in most cases so in the unlikely event that it impacts anyone, there's a workaround available.

Benchmarks

These ran on an Apple M4 Max.

time docker build --no-cache -f .devcontainer/Dockerfile .:

  • before: 5:55.01
  • after: 3:08.48 (-47%)

These are the steps that took the most time:

                                                          Before  After
 => [stage-2  9/10] RUN ./install-system-packages.sh ...   58.6s  22.0s
 => [stage-2 10/10] RUN --mount=type=bind,target=/con ... 245.7s 119.4s
 => exporting to image ...                                 45.4s  44.3s
 => => exporting layers ...                                30.8s  30.6s
 => => unpacking to ...                                    14.6s  13.7s

Unsurprisingly, the most time saved was from commands running containerized. These run more than twice as fast. This is reflected also when building apps inside the dev container:

rm -r target-aarch64/
time make build
  • before: 0m20.285s
  • after: 0m7.264s (-64%)

Details

.devcontainer/Dockerfile:

  • Update to Debian trixie to avoid version 'GLIBC_2.39' not found errors when running cargo-acap-sdk. The best explanation I could find for this is that the host pre-built standard lib depends on different versions depending on the platform they were build on.

.devhost/install-rust.sh:

README.md:

  • Update the suggested docker commands to one that can easily be adapted to run make check_generated_files_container. Note that inspect_env still doesn't reproduce.

Footers

Related-to: #229

This speeds up both building and using the dev container by a lot on
Apple silicon, see benchmarks below:

`time docker build --no-cache -f .devcontainer/Dockerfile .`:
- before: 5:55.01
- after:  3:08.48 (-47%)

These are the steps that took the most time:

```
                                                          Before  After
 => [stage-2  9/10] RUN ./install-system-packages.sh ...   58.6s  22.0s
 => [stage-2 10/10] RUN --mount=type=bind,target=/con ... 245.7s 119.4s
 => exporting to image ...                                 45.4s  44.3s
 => => exporting layers ...                                30.8s  30.6s
 => => unpacking to ...                                    14.6s  13.7s
```

Unsurprisingly, the most time saved was from commands running
containerized. These run more than twice as fast. This is reflected
also when building apps inside the dev container:

```
rm -r target-aarch64/
time make build
```

- before: 0m20.285s
- after:  0m7.264s (-64%)
@apljungquist apljungquist requested a review from a team as a code owner March 7, 2026 12:01
Specifying the platform and changing the working dir allows most checksums to be reproduced
This completes the revert of 5148b0
@apljungquist apljungquist requested review from guoxe and removed request for guoxe March 7, 2026 12:54
@apljungquist
Copy link
Copy Markdown
Collaborator Author

apljungquist commented Mar 7, 2026

Moving this back to draft because the #[cfg(not(any(target_arch = "x86_64", target_os = "macos")))] may not work in the new container because 😐

And cargo-acap-sdk fails to start: cargo-acap-sdk: /lib/aarch64-linux-gnu/libc.so.6: version 'GLIBC_2.39' not found (required by cargo-acap-sdk)

@apljungquist apljungquist marked this pull request as draft March 7, 2026 13:19
This avoids `cargo-acap-sdk: /lib/aarch64-linux-gnu/libc.so.6: version 'GLIBC_2.39' not found (required by cargo-acap-sdk)`. Curiously this does not happen with for instance `cargo-acap-build`.

The best explanation I could find is that a glibc dependency gets baked into the pre-built standard library and this is varies between platforms.
@apljungquist apljungquist marked this pull request as ready for review March 8, 2026 09:01
@apljungquist apljungquist requested a review from guoxe March 8, 2026 09:01
Co-authored-by: Jovy <joeiphone08@gmail.com>
@apljungquist apljungquist merged commit c99e0e1 into main Mar 12, 2026
5 checks passed
@apljungquist apljungquist deleted the no-rosetta branch March 12, 2026 12:10
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