Skip to content

Commit c99e0e1

Browse files
chore: Avoid Rosetta on Apple (#228)
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`: - Use platform appropriate `rustup-init` to avoid the problem documented in #70. `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 Co-authored-by: Jovy <joeiphone08@gmail.com>
1 parent 8de8796 commit c99e0e1

File tree

5 files changed

+53
-36
lines changed

5 files changed

+53
-36
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ ARG SDK=acap-native-sdk
44
ARG UBUNTU_VERSION=24.04
55
# Keep in sync with `install-sdk.sh`.
66
ARG VERSION=12.1.0
7-
ARG BASE_IMAGE=debian:bookworm-20240423
7+
ARG BASE_IMAGE=debian:trixie-20260223
88

9-
FROM --platform=linux/amd64 ${REPO}/${SDK}:${VERSION}-aarch64-ubuntu${UBUNTU_VERSION} AS sdk-aarch64
10-
FROM --platform=linux/amd64 ${REPO}/${SDK}:${VERSION}-armv7hf-ubuntu${UBUNTU_VERSION} AS sdk-armv7hf
11-
FROM --platform=linux/amd64 ${BASE_IMAGE}
9+
FROM ${REPO}/${SDK}:${VERSION}-aarch64-ubuntu${UBUNTU_VERSION} AS sdk-aarch64
10+
FROM ${REPO}/${SDK}:${VERSION}-armv7hf-ubuntu${UBUNTU_VERSION} AS sdk-armv7hf
11+
FROM ${BASE_IMAGE}
1212

1313
COPY --from=sdk-aarch64 /opt/axis/acapsdk/axis-acap-manifest-tools /opt/axis/acapsdk/axis-acap-manifest-tools
1414
COPY --from=sdk-aarch64 /opt/axis/acapsdk/environment-setup-cortexa53-crypto-poky-linux /opt/axis/acapsdk/environment-setup-cortexa53-crypto-poky-linux

.devhost/install-rust.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
#!/usr/bin/env sh
22
set -eux
33

4-
curl \
5-
--output /tmp/rustup-init \
6-
"https://static.rust-lang.org/rustup/archive/1.26.0/x86_64-unknown-linux-gnu/rustup-init"
4+
ARCH=$(uname -m)
5+
case "$ARCH" in
6+
x86_64)
7+
URL="https://static.rust-lang.org/rustup/archive/1.26.0/x86_64-unknown-linux-gnu/rustup-init"
8+
SHA256="0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db"
9+
;;
10+
aarch64)
11+
URL="https://static.rust-lang.org/rustup/archive/1.26.0/aarch64-unknown-linux-gnu/rustup-init"
12+
SHA256="673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800"
13+
;;
14+
*)
15+
echo "Unsupported architecture: $ARCH" >&2
16+
exit 1
17+
;;
18+
esac
719

8-
echo "0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db /tmp/rustup-init" \
9-
| sha256sum -c -
20+
curl --output /tmp/rustup-init "$URL"
21+
echo "$SHA256 /tmp/rustup-init" | sha256sum -c -
1022

1123
chmod +x /tmp/rustup-init
1224

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,19 @@ app can be built using
5757
only `docker`:
5858

5959
```sh
60-
docker build --file .devcontainer/Dockerfile --tag acap-rs .
60+
docker build \
61+
--file .devcontainer/Dockerfile \
62+
--platform linux/amd64 \
63+
--tag acap-rs \
64+
.
6165
docker run \
6266
--interactive \
6367
--rm \
6468
--tty \
69+
--platform linux/amd64 \
6570
--user $(id -u):$(id -g) \
66-
--volume $(pwd):$(pwd) \
67-
--workdir $(pwd) \
71+
--volume $(pwd):/workspaces/acap-rs \
72+
--workdir /workspaces/acap-rs \
6873
acap-rs \
6974
make build AXIS_PACKAGE=hello_world
7075
```

apps-aarch64.checksum

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
8fff02275de11d5f3aba0e4aba4ab162a489200c target-aarch64/acap/Challenge_Build_Tools_1_0_0_all.eap
2-
a21721df06c91115d99f718353586ee8eaa0356e target-aarch64/acap/axoverlay_example_0_0_0_aarch64.eap
3-
bfc22269e9bf53b6a2526009413e0e8c281b3d5b target-aarch64/acap/axparameter_example_0_0_0_aarch64.eap
4-
ff26e764367290e803fbe96f32d2f89c613aad30 target-aarch64/acap/axstorage_example_0_0_0_aarch64.eap
5-
fa337bdd8d797f9b66602630b5ce7675c3d1350f target-aarch64/acap/bounding_box_example_0_0_0_aarch64.eap
6-
cb773a1f92cbf3b18a3869ec386c6794d2daf57b target-aarch64/acap/consume_analytics_metadata_0_0_0_aarch64.eap
7-
16310c12bb50db85d69c744d13c93ebf0c628953 target-aarch64/acap/embedded_web_page_0_0_0_aarch64.eap
8-
f037f30b1459ae4db14336a51618db3bb5f2ff89 target-aarch64/acap/event_subscribe_1_0_0_aarch64.eap
9-
60d4574e576c4762d1b51bdbe53f416d4a36f093 target-aarch64/acap/hello_world_0_0_0_aarch64.eap
10-
c8d98b2b6478a073a8f1893fcf8698fb204180b1 target-aarch64/acap/inspect_env_0_0_0_aarch64.eap
11-
bfb74d7d675b6adcd48fb0be3e542fcfdb0c888e target-aarch64/acap/licensekey_handler_0_0_0_aarch64.eap
12-
6fe4c136fb1ee7c3ec9fbd82240505402e7d4e60 target-aarch64/acap/object_detection_1_0_0_aarch64.eap
13-
0c0711cbf6c20699909d712175ef4a806df3720b target-aarch64/acap/reverse_proxy_0_0_0_aarch64.eap
14-
1cb74047887821a199fe18fb146475f73c67d29e target-aarch64/acap/send_event_1_0_0_aarch64.eap
15-
e01115210714bb7b83d89fd5f645d997b6bcae1d target-aarch64/acap/subscribe_to_event_1_0_0_aarch64.eap
16-
9df8dead66b245aa19d3aafa758871118b8cc25f target-aarch64/acap/using_a_build_script_0_0_0_aarch64.eap
17-
2d373306d132d68f7c3755bb93eb45b906347ae2 target-aarch64/acap/vapix_access_0_0_0_aarch64.eap
18-
3cdc345e9a3db8c78a6866e80ced733a61f8307f target-aarch64/acap/vdoencodeclient_1_0_0_aarch64.eap
1+
27c2f1c9ccb02741fd7c412793ced13550fd0ee3 target-aarch64/acap/Challenge_Build_Tools_1_0_0_all.eap
2+
5250ef2bd726138fc5f242596587156eab5e64f4 target-aarch64/acap/axoverlay_example_0_0_0_aarch64.eap
3+
36bb02351514cdab558e2dff77762bf8a9080590 target-aarch64/acap/axparameter_example_0_0_0_aarch64.eap
4+
4ab515a362d34c42a1723bfedfbab583c5ebe2fc target-aarch64/acap/axstorage_example_0_0_0_aarch64.eap
5+
7d29034492ff57f3b46e876618090b7ef6de1c2f target-aarch64/acap/bounding_box_example_0_0_0_aarch64.eap
6+
09946b3dd2a772c7be146b121b99343c550f3789 target-aarch64/acap/consume_analytics_metadata_0_0_0_aarch64.eap
7+
e2cab11965f638c6c2409bdbc835b12cf6d84aef target-aarch64/acap/embedded_web_page_0_0_0_aarch64.eap
8+
2d49a1c142043b300c9ce21b45aeb58356166d7f target-aarch64/acap/event_subscribe_1_0_0_aarch64.eap
9+
a12f184fdcacfaf4c1d3b9f11f2dddc64ec21f14 target-aarch64/acap/hello_world_0_0_0_aarch64.eap
10+
d4d351038d3af3d995ac5137f070afe7b56763ef target-aarch64/acap/inspect_env_0_0_0_aarch64.eap
11+
babe2fd2009f796efe6529d240e8e81368c1982a target-aarch64/acap/licensekey_handler_0_0_0_aarch64.eap
12+
387a1b17f14ec4103a582956ced1a9fe12fd0b91 target-aarch64/acap/object_detection_1_0_0_aarch64.eap
13+
ee33a597448238ce7e483d590aad51945dd92637 target-aarch64/acap/reverse_proxy_0_0_0_aarch64.eap
14+
e2f518d019878a90fd75e0fa5c381cd076e7a850 target-aarch64/acap/send_event_1_0_0_aarch64.eap
15+
031e059b2b3d8a528b04befc557d7978fca4587b target-aarch64/acap/subscribe_to_event_1_0_0_aarch64.eap
16+
a6e0ee05e0ea5b0e76308b6d91b06b61fb2d9029 target-aarch64/acap/using_a_build_script_0_0_0_aarch64.eap
17+
61c0f96d5388ebb6a46a80f0fd2f57b86143a2f6 target-aarch64/acap/vapix_access_0_0_0_aarch64.eap
18+
8f9dea1da7a39c1c37b99d6ab1a33d0abe0d643f target-aarch64/acap/vdoencodeclient_1_0_0_aarch64.eap

apps-aarch64.filesize

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
3215 target-aarch64/acap/axoverlay_example_0_0_0_aarch64.eap
33
2865 target-aarch64/acap/axparameter_example_0_0_0_aarch64.eap
44
2937 target-aarch64/acap/axstorage_example_0_0_0_aarch64.eap
5-
1597 target-aarch64/acap/bounding_box_example_0_0_0_aarch64.eap
6-
1480 target-aarch64/acap/consume_analytics_metadata_0_0_0_aarch64.eap
5+
1598 target-aarch64/acap/bounding_box_example_0_0_0_aarch64.eap
6+
1481 target-aarch64/acap/consume_analytics_metadata_0_0_0_aarch64.eap
77
899 target-aarch64/acap/embedded_web_page_0_0_0_aarch64.eap
8-
3543 target-aarch64/acap/event_subscribe_1_0_0_aarch64.eap
8+
3544 target-aarch64/acap/event_subscribe_1_0_0_aarch64.eap
99
1406 target-aarch64/acap/hello_world_0_0_0_aarch64.eap
10-
1440 target-aarch64/acap/inspect_env_0_0_0_aarch64.eap
10+
1441 target-aarch64/acap/inspect_env_0_0_0_aarch64.eap
1111
1430 target-aarch64/acap/licensekey_handler_0_0_0_aarch64.eap
1212
1408 target-aarch64/acap/object_detection_1_0_0_aarch64.eap
1313
10315 target-aarch64/acap/reverse_proxy_0_0_0_aarch64.eap
1414
3437 target-aarch64/acap/send_event_1_0_0_aarch64.eap
15-
3417 target-aarch64/acap/subscribe_to_event_1_0_0_aarch64.eap
15+
3418 target-aarch64/acap/subscribe_to_event_1_0_0_aarch64.eap
1616
899 target-aarch64/acap/using_a_build_script_0_0_0_aarch64.eap
17-
11327 target-aarch64/acap/vapix_access_0_0_0_aarch64.eap
17+
11330 target-aarch64/acap/vapix_access_0_0_0_aarch64.eap
1818
1407 target-aarch64/acap/vdoencodeclient_1_0_0_aarch64.eap

0 commit comments

Comments
 (0)