CI: Set up for an arm64 runner
v5 cover CI: Set up for an arm64 runner
All gitlab runners are currently amd64 machines. This series attempts to create a docker image which can also support arm64 so that sandbox tests can be run on it.
The TARGET_... environment variables for grub could perhaps be adjusted, using the new variables, but I have not done that for now.
Currently this builds OK on amd64 but fails when built on arm64, in grub on arm64-efi:
2022.6 gcc -DHAVE_CONFIG_H -I. -I../../.. -D_FILE_OFFSET_BITS=64
-MT argp-pvh.o -MD -MP -MF $depbase.Tpo -c -o argp-pvh.o argp-pvh.c &&\
2022.6 mv -f $depbase.Tpo $depbase.Po
2023.0 gcc: internal compiler error: Segmentation fault signal terminated program cc1 2023.0 Please submit a full bug report,
2023.0 with preprocessed source if appropriate.
2023.0 See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions. 2023.0 make[4]: *** [Makefile:1714: argp-pvh.o] Error 4
Perhaps this doesn't matter, though, at least for now.
This passes gitlab:
https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines
but still fails on arm64:
https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/23346
Changes in v5:
- Drop the comment in the gitlab file
- Add back a final missing sudo
Changes in v4:
- Leave the 'sudo' in
Changes in v3:
- Move ARGs to the top
- Revise documentation to explain a common error and building on arm64
- Use grub-efi and linux-image-generic for both archs
- Add patch to install toolchains on arm64 host
- Drop patches which remove grub and tracing for arm64
Changes in v2:
- Update docs also
- Add comments to the ARG variables
- Swap order so that amd64 is the exception
Simon Glass (6):
docker: Support building for multiple architectures
docker: Adjust packages for arm64
docker: Drop coreboot for arm64
docker: Fix LegacyKeyValueFormat warning with PYTHONPATH
docker: Install toolchains on arm64 host
CI: Add platform variable
.gitlab-ci.yml | 1 + doc/build/docker.rst | 23 ++++++++++++-- tools/docker/Dockerfile | 69 ++++++++++++++++++++++++++++------------- 3 files changed, 69 insertions(+), 24 deletions(-)
Signature · 1 line
2.34.1
PATCH v5 1/6 docker: Support building for multiple architectures
Add instructions on how to build the file for multiple architectures. Add a message indicating what is happening.
Update the documentation as well.
---
Changes in v5:
- Drop the comment in the gitlab file
- Add back a final missing sudo
Changes in v4:
- Leave the 'sudo' in
Changes in v3:
- Move ARGs to the top
- Revise documentation to explain a common error and building on arm64
Changes in v2:
- Update docs also
- Add comments to the ARG variables
doc/build/docker.rst | 23 +++++++++++++++++++++-- tools/docker/Dockerfile | 9 +++++++++ 2 files changed, 30 insertions(+), 2 deletions(-)
doc/build/docker.rst +21 -2
@@ -1,11 +1,30 @@ GitLab CI / U-Boot runner container =================================== -In order to have a reproducible and portable build environment for CI we use a container for building in. This means that developers can also reproduce the CI environment, to a large degree at least, locally. This file is located in the tools/docker directory. To build the image yourself +In order to have a reproducible and portable build environment for CI we use a container for building in. This means that developers can also reproduce the CI environment, to a large degree at least, locally. This file is located in the tools/docker directory. + +The docker image supports both amd64 and arm64. Ensure that the +'docker-buildx' Debian package is installed (or the equivalent on another +distribution). + +You will need a multi-platform container, otherwise this error is shown:: + + ERROR: Multi-platform build is not supported for the docker driver. + Switch to a different driver, or turn on the containerd image store, and try again. + +You can add one with:: + + sudo docker buildx create --name multiarch --driver docker-container --use + +Building is supported on both amd64 (i.e. 64-bit x86) and arm64 machines. While +both amd64 and arm64 happen in parallel, the non-native part will take +considerably longer as it must use QEMU to emulate the foreign code. + +To build the image yourself:: .. code-block:: bash - sudo docker build -t your-namespace:your-tag . + sudo docker buildx build --platform linux/arm64/v8,linux/amd64 -t your-namespace:your-tag . Or to use an existing container
tools/docker/Dockerfile +9 -0
@@ -6,9 +6,18 @@ FROM ubuntu:jammy-20240808 LABEL org.opencontainers.image.authors="Tom Rini <[email protected]>" LABEL org.opencontainers.image.description=" This image is for building U-Boot inside a container" +# Used by docker to set the target platform: valid values are linux/arm64/v8 +# and linux/amd64 +ARG TARGETPLATFORM + +# Used by docker to set the build platform: the only valid value is linux/amd64 +ARG BUILDPLATFORM + # Make sure apt is happy ENV DEBIAN_FRONTEND=noninteractive +RUN echo "Building on $BUILDPLATFORM, for target $TARGETPLATFORM" + # Add LLVM repository RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/* RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
Signature · 1 line
2.34.1
PATCH 1/1 docker.rst: Reword slightly around "buildx"
Try and be slightly clearer about what "buildx" is, and how to install it.
---
I rephrased this slightly to try and be clearer as if you're using the docker.io provided packages you need to just install the plugin.
--- doc/build/docker.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
doc/build/docker.rst +2 -2
@@ -4,8 +4,8 @@ GitLab CI / U-Boot runner container In order to have a reproducible and portable build environment for CI we use a container for building in. This means that developers can also reproduce the CI environment, to a large degree at least, locally. This file is located in the tools/docker directory. The docker image supports both amd64 and arm64. Ensure that the -'docker-buildx' Debian package is installed (or the equivalent on another -distribution). +`buildx` Docker CLI plugin is installed. This is often available in your +distribution via the 'docker-buildx' or 'docker-buildx-plugin' package. You will need a multi-platform container, otherwise this error is shown::
Signature · 1 line
2.43.0
Re: [PATCH] docker.rst: Reword slightly around "buildx"
Quoted 18 lines · Tom Rini
Try and be slightly clearer about what "buildx" is, and how to install it.
Signed-off-by Tom Rini <[email protected]>---
I rephrased this slightly to try and be clearer as if you're using the docker.io provided packages you need to just install the plugin.Cc Simon Glass <[email protected]>--- doc/build/docker.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)doc/build/docker.rst +0
-0
doc/build/docker.rst GitLab CI / U-Boot runner container · line 10
Quoted 9 lines
doc/build/docker.rst +2
-2@@ -4,8 +4,8 @@ GitLab CI / U-Boot runner container In order to have a reproducible and portable build environment for CI we use a container for building in. This means that developers can also reproduce the CI environment, to a large degree at least, locally. This file is located in the tools/docker directory. The docker image supports both amd64 and arm64. Ensure that the -'docker-buildx' Debian package is installed (or the equivalent on another -distribution). +`buildx` Docker CLI plugin is installed. This is often available in your +distribution via the 'docker-buildx' or 'docker-buildx-plugin' package. You will need a multi-platform container, otherwise this error is shown::
And as a note to the future, understanding
https://docs.docker.com/build/building/multi-platform/ and a very quick guide to how to practically add multiple nodes would likely be good. I feel like most of the SBCs I have on-hand would be quicker than QEMU at this part, and with actual arm64 builder in CI as well that's likely the path forward.
Signature · 1 line
Tom
PATCH v5 2/6 docker: Adjust packages for arm64
In reply to Simon GlassThe package names are slightly different for arm64 and we don't seem to have a linux-image-kvm package. Provide some extra ones for x86
---
(no changes since v3)
Changes in v3:
- Use grub-efi and linux-image-generic for both archs
Changes in v2:
- Swap order so that amd64 is the exception
tools/docker/Dockerfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
tools/docker/Dockerfile +7 -5
@@ -41,7 +41,10 @@ RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_ RUN wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz # Update and install things from apt now -RUN apt-get update && apt-get install -y \ +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + EXTRA_PACKAGES="grub-efi-ia32-bin libc6-i386"; \ + fi; \ + apt-get update && apt-get install -y \ automake \ autopoint \ bc \
@@ -67,13 +70,11 @@ RUN apt-get update && apt-get install -y \ gnu-efi \ gnutls-dev \ graphviz \ - grub-efi-amd64-bin \ - grub-efi-ia32-bin \ + grub-efi \ help2man \ iasl \ imagemagick \ iputils-ping \ - libc6-i386 \ libconfuse-dev \ libgit2-dev \ libjson-glib-dev \
@@ -91,7 +92,7 @@ RUN apt-get update && apt-get install -y \ libtool \ libudev-dev \ libusb-1.0-0-dev \ - linux-image-kvm \ + linux-image-generic \ lzma-alone \ lzop \ mount \
@@ -128,6 +129,7 @@ RUN apt-get update && apt-get install -y \ xilinx-bootgen \ xxd \ zip \ + ${EXTRA_PACKAGES} \ && rm -rf /var/lib/apt/lists/* # Make kernels readable for libguestfs tools to work correctly
Signature · 1 line
2.34.1
PATCH v5 3/6 docker: Drop coreboot for arm64
In reply to Simon GlassThis isn't needed for sandbox builds and coreboot isn't much used on arm64, nor does U-Boot have a build that supports running from coreboot on any ARM target.
So drop it.
---
(no changes since v1)
tools/docker/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/docker/Dockerfile +4 -2
@@ -255,7 +255,8 @@ RUN mkdir /tmp/trace && \ rm -rf /tmp/trace # Build coreboot -RUN wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp -xJ && \ +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp -xJ && \ cd /tmp/coreboot-24.08 && \ make crossgcc-i386 CPUS=$(nproc) && \ make -C payloads/coreinfo olddefconfig && \
@@ -266,7 +267,8 @@ RUN wget -O - https://coreboot.org/releases/coreboot-24.08.tar.xz | tar -C /tmp make olddefconfig && \ make -j $(nproc) && \ sudo mkdir /opt/coreboot && \ - sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/ + sudo cp build/coreboot.rom build/cbfstool /opt/coreboot/; \ + fi # Create our user/group RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
Signature · 1 line
2.34.1
PATCH v5 4/6 docker: Fix LegacyKeyValueFormat warning with PYTHONPATH
In reply to Simon GlassFix a warning due to the syntax used for PYTHONPATH:
LegacyKeyValueFormat: "ENV key=value" should be used instead of
legacy "ENV key value" format (line 304)
---
(no changes since v1)
tools/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/docker/Dockerfile +1 -1
@@ -298,4 +298,4 @@ RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman; # Add mkbootimg tool RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg /home/uboot/mkbootimg -ENV PYTHONPATH "${PYTHONPATH}:/home/uboot/mkbootimg" +ENV PYTHONPATH="${PYTHONPATH}:/home/uboot/mkbootimg"
Signature · 1 line
2.34.1
PATCH v5 5/6 docker: Install toolchains on arm64 host
In reply to Simon GlassRefactor the code to support downloading toolchains for arm64 as well as x86_64
There doesn't seem to be an xtensa toolchain for arm64 at the same location, so download that only on x86
---
(no changes since v3)
Changes in v3:
- Add patch to install toolchains on arm64 host
tools/docker/Dockerfile | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-)
tools/docker/Dockerfile +26 -14
@@ -16,6 +16,15 @@ ARG BUILDPLATFORM # Make sure apt is happy ENV DEBIAN_FRONTEND=noninteractive +# Set architectures to build for (leaving out ARM which is an exception) +ENV ARCHS="aarch64 arc i386 m68k mips microblaze nios2 powerpc riscv64 riscv32 sh2" + +# Mirror containing the toolchains +ENV MIRROR=https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin + +# Toolchain version +ENV TCVER=13.2.0 + RUN echo "Building on $BUILDPLATFORM, for target $TARGETPLATFORM" # Add LLVM repository
@@ -23,22 +32,25 @@ RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main | tee /etc/apt/sources.list.d/llvm.list -# Manually install the kernel.org "Crosstool" based toolchains for gcc-13.2.0 -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-aarch64-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arc-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ -RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ +# Create a list of URLs to process, then pass them into a 'while read' loop +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then HOSTARCH=x86_64; else HOSTARCH=arm64; fi; ( \ + # Manually install the kernel.org "Crosstool"-based toolchains + for arch in $ARCHS; do \ + echo $MIRROR/$HOSTARCH/$TCVER/${HOSTARCH}-gcc-$TCVER-nolibc-${arch}-linux.tar.xz; \ + done; \ + \ + # Deal with ARM, which has a 'gnueabi' suffix + echo $MIRROR/${HOSTARCH}/$TCVER/${HOSTARCH}-gcc-$TCVER-nolibc-arm-linux-gnueabi.tar.xz; \ + \ + ) | while read url; do \ + # Read the URL and unpack it into /opt + wget -O - $url | tar -C /opt -xJ; \ + done # Manually install other toolchains -RUN wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz; \ + fi # Update and install things from apt now RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
Signature · 1 line
2.34.1
PATCH v5 6/6 CI: Add platform variable
In reply to Simon GlassAdd a list of possible platforms that can be used by gitlab runners.
---
(no changes since v3)
Changes in v3:
- Drop patches which remove grub and tracing for arm64
.gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+)
.gitlab-ci.yml +1 -0
@@ -3,6 +3,7 @@ variables: DEFAULT_TAG: "" MIRROR_DOCKER: docker.io + PLATFORM: linux/amd64,linux/arm64 default: tags:
Signature · 1 line
2.34.1