Skip to content

Commit

Permalink
tests/docker: use prebuilt toolchain for debian-hexagon-cross
Browse files Browse the repository at this point in the history
The current docker image for cross compiling hexagon guests
is manually built since it takes >2 hours to build from source.

This patch:
 1. Solves the above issue by using the prebuilt clang
    toolchain hosted on CodeLinaro [1] and maintained by QUIC [2].
 2. The dockerfile is also switched from multi-stage to single stage
    build to allow the CI docker engine to reuse the layer cache.
 3. Re-enables the hexagon-cross-container job to be always run in
    CI and makes it a non-optional dependency for the
    build-user-hexagon job.

The changes for 1 & 2 together bring down the build time to
~3 minutes in GitLab CI when cache is reused and ~9 minutes
when cache cannot be reused.

[1]: https://github.com/CodeLinaro/hexagon-builder
[2]: https://github.com/quic/toolchain_for_hexagon/releases/

Signed-off-by: Mukilan Thiyagarajan <quic_mthiyaga@quicinc.com>
[AJB: also tweak MAINTAINERS]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20221219144354.11659-1-quic_mthiyaga@quicinc.com>
Message-Id: <20221221090411.1995037-6-alex.bennee@linaro.org>
  • Loading branch information
mukilan-quic authored and stsquad committed Dec 21, 2022
1 parent 87f1bc1 commit c729b32
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 202 deletions.
4 changes: 0 additions & 4 deletions .gitlab-ci.d/buildtest.yml
Expand Up @@ -275,14 +275,10 @@ build-user-static:
CONFIGURE_ARGS: --disable-tools --disable-system --static
MAKE_CHECK_ARGS: check-tcg

# Because the hexagon cross-compiler takes so long to build we don't rely
# on the CI system to build it and hence this job has an optional dependency
# declared. The image is manually uploaded.
build-user-hexagon:
extends: .native_build_job_template
needs:
job: hexagon-cross-container
optional: true
variables:
IMAGE: debian-hexagon-cross
TARGETS: hexagon-linux-user
Expand Down
19 changes: 1 addition & 18 deletions .gitlab-ci.d/container-cross.yml
Expand Up @@ -37,28 +37,11 @@ armhf-debian-cross-container:
# We never want to build hexagon in the CI system and by default we
# always want to refer to the master registry where it lives.
hexagon-cross-container:
extends: .base_job_template
image: docker:stable
extends: .container_job_template
stage: containers
variables:
NAME: debian-hexagon-cross
GIT_DEPTH: 1
QEMU_JOB_ONLY_FORKS: 1
services:
- docker:dind
before_script:
- export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
- export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
- docker info
- docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
script:
- echo "TAG:$TAG"
- echo "COMMON_TAG:$COMMON_TAG"
- docker pull $COMMON_TAG
- docker tag $COMMON_TAG $TAG
- docker push "$TAG"
after_script:
- docker logout

hppa-debian-cross-container:
extends: .container_job_template
Expand Down
1 change: 0 additions & 1 deletion MAINTAINERS
Expand Up @@ -204,7 +204,6 @@ F: tests/tcg/hexagon/
F: disas/hexagon.c
F: configs/targets/hexagon-linux-user/default.mak
F: docker/dockerfiles/debian-hexagon-cross.docker
F: docker/dockerfiles/debian-hexagon-cross.docker.d/build-toolchain.sh

Hexagon idef-parser
M: Alessandro Di Federico <ale@rev.ng>
Expand Down
4 changes: 0 additions & 4 deletions tests/docker/Makefile.include
Expand Up @@ -109,10 +109,6 @@ debian-toolchain-run = \
"PREPARE", $1))
debian-toolchain = $(call debian-toolchain-run,$(patsubst docker-image-%,%,$1))

docker-image-debian-hexagon-cross: $(DOCKER_FILES_DIR)/debian-hexagon-cross.docker \
$(DOCKER_FILES_DIR)/debian-hexagon-cross.d/build-toolchain.sh
$(call debian-toolchain, $@)

docker-image-debian-microblaze-cross: $(DOCKER_FILES_DIR)/debian-toolchain.docker \
$(DOCKER_FILES_DIR)/debian-microblaze-cross.d/build-toolchain.sh
$(call debian-toolchain, $@)
Expand Down
141 changes: 0 additions & 141 deletions tests/docker/dockerfiles/debian-hexagon-cross.d/build-toolchain.sh

This file was deleted.

53 changes: 19 additions & 34 deletions tests/docker/dockerfiles/debian-hexagon-cross.docker
Expand Up @@ -7,44 +7,29 @@
#
FROM docker.io/library/debian:11-slim

# Install common build utilities
RUN apt update && \
# Duplicate deb line as deb-src
RUN cat /etc/apt/sources.list | sed "s/^deb\ /deb-src /" >> /etc/apt/sources.list
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
DEBIAN_FRONTEND=noninteractive eatmydata \
apt install -y --no-install-recommends \
bison \
# Install common build utilities
apt-get install -y --no-install-recommends \
curl \
xz-utils \
ca-certificates \
clang \
cmake \
bison \
flex \
gcc \
lld \
make \
ninja-build \
python3 \
rsync \
wget \
xz-utils

ENV TOOLCHAIN_INSTALL /usr/local
ENV ROOTFS /usr/local

ENV LLVM_URL https://github.com/llvm/llvm-project/archive/bfcd21876adc3498065e4da92799f613e730d475.tar.gz
ENV MUSL_URL https://github.com/quic/musl/archive/aff74b395fbf59cd7e93b3691905aa1af6c0778c.tar.gz
ENV LINUX_URL https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.18.tar.xz

ADD build-toolchain.sh /root/hexagon-toolchain/build-toolchain.sh

RUN cd /root/hexagon-toolchain && ./build-toolchain.sh

FROM docker.io/library/debian:11-slim
# Duplicate deb line as deb-src
RUN cat /etc/apt/sources.list | sed "s/^deb\ /deb-src /" >> /etc/apt/sources.list
git \
ninja-build && \
# Install QEMU build deps for use in CI
RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
DEBIAN_FRONTEND=noninteractive eatmydata apt install -yy bison flex git ninja-build && \
DEBIAN_FRONTEND=noninteractive eatmydata \
apt build-dep -yy --arch-only qemu
COPY --from=0 /usr/local /usr/local
ENV PATH $PATH:/usr/local/bin/


ENV TOOLCHAIN_INSTALL /opt
ENV TOOLCHAIN_RELEASE 15.0.3
ENV TOOLCHAIN_BASENAME "clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-linux-musl"
ENV TOOLCHAIN_URL https://codelinaro.jfrog.io/artifactory/codelinaro-toolchain-for-hexagon/v${TOOLCHAIN_RELEASE}/${TOOLCHAIN_BASENAME}.tar.xz

RUN curl -#SL "$TOOLCHAIN_URL" | tar -xJC "$TOOLCHAIN_INSTALL"
ENV PATH $PATH:${TOOLCHAIN_INSTALL}/${TOOLCHAIN_BASENAME}/x86_64-linux-gnu/bin

0 comments on commit c729b32

Please sign in to comment.