From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: marex@denx.de, crwulff@gmail.com, alex.bennee@linaro.org,
laurent@vivier.eu
Subject: [PATCH 1/9] tests/docker: Add debian-nios2-cross image
Date: Fri, 1 Oct 2021 11:33:37 -0400 [thread overview]
Message-ID: <20211001153347.1736014-2-richard.henderson@linaro.org> (raw)
In-Reply-To: <20211001153347.1736014-1-richard.henderson@linaro.org>
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
next prev parent reply other threads:[~2021-10-01 15:45 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 15:33 [PATCH 0/9] nios2: Enable cross compile and fix signals Richard Henderson
2021-10-01 15:33 ` Richard Henderson [this message]
2021-10-12 17:03 ` [PATCH 1/9] tests/docker: Add debian-nios2-cross image Alex Bennée
2021-10-12 18:24 ` Richard Henderson
2021-10-12 18:33 ` Alex Bennée
2021-10-14 9:34 ` Alex Bennée
2021-10-14 17:17 ` Richard Henderson
2021-10-14 17:25 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 1/2] tests/docker: Remove fedora-i386-cross from DOCKER_PARTIAL_IMAGES Richard Henderson
2021-10-14 9:35 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 2/9] linux-user/nios2: Properly emulate EXCP_TRAP Richard Henderson
2021-10-14 9:36 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 2/2] tests/docker: Fix fedora-i386-cross Richard Henderson
2021-10-14 9:38 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 3/9] linux-user/nios2: Fixes for signal frame setup Richard Henderson
2021-10-14 9:43 ` Alex Bennée
2021-10-01 15:33 ` [PATCH 4/9] linux-user/elfload: Rename ARM_COMMPAGE to HI_COMMPAGE Richard Henderson
2021-10-12 6:11 ` Laurent Vivier
2021-10-01 15:33 ` [PATCH 5/9] linux-user/nios2: Map a real kuser page Richard Henderson
2021-10-01 15:33 ` [PATCH 6/9] linux-user/nios2: Fix EA vs PC confusion Richard Henderson
2021-10-01 15:33 ` [PATCH 7/9] linux-user/nios2: Fix sigmask in setup_rt_frame Richard Henderson
2021-10-12 6:16 ` Laurent Vivier
2021-10-01 15:33 ` [PATCH 8/9] linux-user/nios2: Use set_sigmask in do_rt_sigreturn Richard Henderson
2021-10-12 6:29 ` Laurent Vivier
2021-10-01 15:33 ` [PATCH 9/9] tests/tcg: Enable container_cross_cc for nios2 Richard Henderson
2021-10-11 19:06 ` [PATCH 0/9] nios2: Enable cross compile and fix signals Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211001153347.1736014-2-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=crwulff@gmail.com \
--cc=laurent@vivier.eu \
--cc=marex@denx.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).