[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/9] tests/docker: Add debian-nios2-cross image
From: |
Richard Henderson |
Subject: |
[PATCH 1/9] tests/docker: Add debian-nios2-cross image |
Date: |
Fri, 1 Oct 2021 11:33:37 -0400 |
Build the entire cross tool chain from source.
For this reason, default to caching.
Signed-off-by: Richard Henderson <richard.henderson@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"))
+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"))
+
# 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
+
+ENV PATH $PATH:/usr/local/bin/
diff --git
a/tests/docker/dockerfiles/debian-nios2-cross.docker.d/build-toolchain.sh
b/tests/docker/dockerfiles/debian-nios2-cross.docker.d/build-toolchain.sh
new file mode 100755
index 0000000000..d8cb428dab
--- /dev/null
+++ b/tests/docker/dockerfiles/debian-nios2-cross.docker.d/build-toolchain.sh
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+set -e
+
+TARGET=nios2-linux-gnu
+LINUX_ARCH=nios2
+
+J=$(expr $(nproc) / 2)
+TOOLCHAIN_INSTALL=/usr/local
+TOOLCHAIN_BIN=${TOOLCHAIN_INSTALL}/bin
+CROSS_SYSROOT=${TOOLCHAIN_INSTALL}/$TARGET/sys-root
+
+export PATH=${TOOLCHAIN_BIN}:$PATH
+
+mkdir cross
+cd cross
+
+#
+# Grab all of the source for the toolchain bootstrap.
+#
+
+wget https://ftp.gnu.org/gnu/binutils/binutils-2.37.tar.xz
+wget https://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.xz
+wget https://ftp.gnu.org/gnu/glibc/glibc-2.34.tar.xz
+wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.70.tar.xz
+
+tar axf binutils-2.37.tar.xz
+tar axf gcc-11.2.0.tar.xz
+tar axf glibc-2.34.tar.xz
+tar axf linux-5.10.70.tar.xz
+
+mv binutils-2.37 src-binu
+mv gcc-11.2.0 src-gcc
+mv glibc-2.34 src-glibc
+mv linux-5.10.70 src-linux
+
+mkdir -p bld-hdr bld-binu bld-gcc bld-glibc
+mkdir -p ${CROSS_SYSROOT}/usr/include
+
+#
+# Install kernel and glibc headers
+#
+
+cd src-linux
+make headers_install ARCH=${LINUX_ARCH} INSTALL_HDR_PATH=${CROSS_SYSROOT}/usr
+cd ..
+
+cd bld-hdr
+../src-glibc/configure --prefix=/usr --host=${TARGET}
+make install-headers DESTDIR=${CROSS_SYSROOT}
+touch ${CROSS_SYSROOT}/usr/include/gnu/stubs.h
+cd ..
+
+#
+# Build binutils
+#
+
+cd bld-binu
+../src-binu/configure --disable-werror \
+ --prefix=${TOOLCHAIN_INSTALL} --with-sysroot --target=${TARGET}
+make -j${J}
+make install
+cd ..
+
+#
+# Build gcc, without shared libraries, because we do not yet
+# have a shared libc against which to link.
+#
+
+cd bld-gcc
+../src-gcc/configure --disable-werror --disable-shared \
+ --prefix=${TOOLCHAIN_INSTALL} --with-sysroot --target=${TARGET} \
+ --enable-languages=c --disable-libssp --disable-libsanitizer \
+ --disable-libatomic --disable-libgomp --disable-libquadmath
+make -j${J}
+make install
+cd ..
+
+#
+# Build glibc
+# There are a few random things that use c++ but we didn't build that
+# cross-compiler. We can get away without them. Disable CXX so that
+# glibc doesn't try to use the host c++ compiler.
+#
+
+cd bld-glibc
+CXX=false ../src-glibc/configure --prefix=/usr --host=${TARGET}
+make -j${j}
+make install DESTDIR=${CROSS_SYSROOT}
+cd ..
+
+#
+# Clean up
+#
+
+cd ..
+rm -rf cross build-toolchain.sh
--
2.25.1
- [PATCH 2/9] linux-user/nios2: Properly emulate EXCP_TRAP, (continued)
- [PATCH 2/9] linux-user/nios2: Properly emulate EXCP_TRAP, Richard Henderson, 2021/10/01
- [PATCH 3/9] linux-user/nios2: Fixes for signal frame setup, Richard Henderson, 2021/10/01
- [PATCH 4/9] linux-user/elfload: Rename ARM_COMMPAGE to HI_COMMPAGE, Richard Henderson, 2021/10/01
- [PATCH 1/2] tests/docker: Remove fedora-i386-cross from DOCKER_PARTIAL_IMAGES, Richard Henderson, 2021/10/01
- [PATCH 5/9] linux-user/nios2: Map a real kuser page, Richard Henderson, 2021/10/01
- [PATCH 6/9] linux-user/nios2: Fix EA vs PC confusion, Richard Henderson, 2021/10/01
- [PATCH 1/9] tests/docker: Add debian-nios2-cross image,
Richard Henderson <=
[PATCH 8/9] linux-user/nios2: Use set_sigmask in do_rt_sigreturn, Richard Henderson, 2021/10/01
[PATCH 7/9] linux-user/nios2: Fix sigmask in setup_rt_frame, Richard Henderson, 2021/10/01