Richard Henderson <richard.hender...@linaro.org> writes:

> Build the entire cross tool chain from source.
> For this reason, default to caching.
>
> Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
> ---
>  tests/docker/Makefile.include                 | 19 ++++
>  .../dockerfiles/debian-nios2-cross.docker     | 34 +++++++
>  .../build-toolchain.sh                        | 97 +++++++++++++++++++
>  3 files changed, 150 insertions(+)
>  create mode 100644 tests/docker/dockerfiles/debian-nios2-cross.docker
>  create mode 100755 
> tests/docker/dockerfiles/debian-nios2-cross.docker.d/build-toolchain.sh
>
> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
> index ff5d732889..2ccd93caa4 100644
> --- a/tests/docker/Makefile.include
> +++ b/tests/docker/Makefile.include
> @@ -168,10 +168,28 @@ docker-image-debian-hexagon-cross: 
> $(DOCKER_FILES_DIR)/debian-hexagon-cross.dock
>                               qemu/debian-hexagon-cross --add-current-user,   
>         \
>                       "PREPARE", "debian-hexagon-cross"))

We need^H^H^H^H (might need, see bellow) a separate patch with:

docker-image-debian10: NOUSER=1

to ensure the images we base our "handbuilt" compilers on don't include
a potentially clashing uid (which should only be added for local
builds).


> +docker-image-debian-nios2-cross: 
> $(DOCKER_FILES_DIR)/debian-nios2-cross.docker
> +     $(if $(NOCACHE),                                                        
>         \
> +             $(call quiet-command,                                           
>         \
> +                     $(DOCKER_SCRIPT) build -t qemu/debian-nios2-cross -f $< 
>         \
> +                     $(if $V,,--quiet) --no-cache                            
>         \
> +                     --registry $(DOCKER_REGISTRY) --extra-files             
>         \
> +                     
> $(DOCKER_FILES_DIR)/debian-nios2-cross.docker.d/build-toolchain.sh, \
> +                     "BUILD", "debian-nios2-cross"),                         
>         \
> +             $(call quiet-command,                                           
>         \
> +                     $(DOCKER_SCRIPT) fetch $(if $V,,--quiet)                
>         \
> +                             qemu/debian-nios2-cross $(DOCKER_REGISTRY),     
>         \
> +                     "FETCH", "debian-nios2-cross")                          
>         \
> +             $(call quiet-command,                                           
>         \
> +                     $(DOCKER_SCRIPT) update $(if $V,,--quiet)               
>         \
> +                             qemu/debian-nios2-cross --add-current-user,     
>         \
> +                     "PREPARE", "debian-nios2-cross"))
> +

Could we update the comment above to something like:

  #
  # The build rule for these cross compilers are special in so far for
  # most of the time we don't want to build them. While dockers caching
  # does avoid this most of the time sometimes we want to force the
  # issue. Also we want to ensure the image they are based on hasn't
  # been polluted with our UID because it will fail when users build
  # their local version from what has been pushed upstream.
  #

>  # Specialist build images, sometimes very limited tools
>  docker-image-debian-tricore-cross: docker-image-debian10
>  docker-image-debian-all-test-cross: docker-image-debian10
>  docker-image-debian-arm64-test-cross: docker-image-debian11
> +docker-image-debian-nios2-cross: docker-image-debian10
>  docker-image-debian-powerpc-test-cross: docker-image-debian11
>  
>  # These images may be good enough for building tests but not for test builds
> @@ -180,6 +198,7 @@ DOCKER_PARTIAL_IMAGES += debian-arm64-test-cross
>  DOCKER_PARTIAL_IMAGES += debian-powerpc-test-cross
>  DOCKER_PARTIAL_IMAGES += debian-hppa-cross
>  DOCKER_PARTIAL_IMAGES += debian-m68k-cross debian-mips64-cross
> +DOCKER_PARTIAL_IMAGES += debian-nios2-cross
>  DOCKER_PARTIAL_IMAGES += debian-riscv64-cross
>  DOCKER_PARTIAL_IMAGES += debian-sh4-cross debian-sparc64-cross
>  DOCKER_PARTIAL_IMAGES += debian-tricore-cross
> diff --git a/tests/docker/dockerfiles/debian-nios2-cross.docker 
> b/tests/docker/dockerfiles/debian-nios2-cross.docker
> new file mode 100644
> index 0000000000..208737fc5e
> --- /dev/null
> +++ b/tests/docker/dockerfiles/debian-nios2-cross.docker
> @@ -0,0 +1,34 @@
> +#
> +# Docker NIOS2 cross-compiler target
> +#
> +# This docker target is used for building tests. As it also needs to be
> +# able to build QEMU itself in CI we include it's build-deps. It is also
> +# a "stand-alone" image so as not to be triggered by re-builds on other
> +# base images given it takes a long time to build.
> +#
> +FROM qemu/debian10
> +
> +# Install build utilities for building gcc and glibc.
> +# ??? The build-dep isn't working, missing a number of
> +# minimal build dependiencies, e.g. libmpc.
> +
> +RUN apt update && \
> +    DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
> +    DEBIAN_FRONTEND=noninteractive eatmydata \
> +    apt install -y --no-install-recommends \
> +        bison \
> +        flex \
> +        gawk \
> +        libmpc-dev \
> +        libmpfr-dev \
> +        rsync \
> +        texinfo \
> +        wget \
> +        $(apt-get -s build-dep --arch-only gcc | egrep ^Inst | fgrep '[all]' 
> | cut -d\  -f2) \
> +        $(apt-get -s build-dep --arch-only glibc | egrep ^Inst | fgrep 
> '[all]' | cut -d\  -f2)
> +
> +ADD build-toolchain.sh /root/build-toolchain.sh
> +
> +RUN cd /root && ./build-toolchain.sh

We need to split this like in hexagon and have a second stage which does
a:

  COPY --from=0 /usr/local /usr/local

This will limit the size of the final image (and also avoid duplicting
the UID in the hexagon build).

-- 
Alex Bennée

Reply via email to