qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: fam@euphon.net, "Marek Vasut" <marex@denx.de>,
	"Thomas Huth" <thuth@redhat.com>,
	minyihh@uci.edu, berrange@redhat.com, kuhn.chenqun@huawei.com,
	"Chris Wulff" <crwulff@gmail.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	f4bug@amsat.org, robhenry@microsoft.com,
	"Willian Rampazzo" <willianr@redhat.com>,
	mahmoudabdalghany@outlook.com, aaron@os.amperecomputing.com,
	cota@braap.org,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com,
	ma.mandourr@gmail.com, "Alex Bennée" <alex.bennee@linaro.org>,
	aurelien@aurel32.net
Subject: [PATCH  v1 05/28] tests/docker: Add debian-nios2-cross image
Date: Tue, 26 Oct 2021 11:22:11 +0100	[thread overview]
Message-ID: <20211026102234.3961636-6-alex.bennee@linaro.org> (raw)
In-Reply-To: <20211026102234.3961636-1-alex.bennee@linaro.org>

From: Richard Henderson <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>
[AJB: honour NOUSER in cached fetch and build, update MAINTAINERS]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20211014224435.2539547-6-richard.henderson@linaro.org>
---
 MAINTAINERS                                   |  1 +
 tests/docker/Makefile.include                 | 25 ++++++
 .../debian-nios2-cross.d/build-toolchain.sh   | 87 +++++++++++++++++++
 .../dockerfiles/debian-toolchain.docker       | 36 ++++++++
 4 files changed, 149 insertions(+)
 create mode 100755 tests/docker/dockerfiles/debian-nios2-cross.d/build-toolchain.sh
 create mode 100644 tests/docker/dockerfiles/debian-toolchain.docker

diff --git a/MAINTAINERS b/MAINTAINERS
index 5423ae0cd4..aa515bd313 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -256,6 +256,7 @@ F: target/nios2/
 F: hw/nios2/
 F: disas/nios2.c
 F: configs/devices/nios2-softmmu/default.mak
+F: tests/docker/dockerfiles/debian-nios2-cross.d/build-toolchain.sh
 
 OpenRISC TCG CPUs
 M: Stafford Horne <shorne@gmail.com>
diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index d223100dff..24ed5c1f1d 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -148,11 +148,35 @@ docker-image-debian-sparc64-cross: docker-image-debian10
 # The native build should never use the registry
 docker-image-debian-native: DOCKER_REGISTRY=
 
+debian-toolchain-run = \
+	$(if $(NOCACHE), 						\
+		$(call quiet-command,					\
+			$(DOCKER_SCRIPT) build -t qemu/$1 -f $< 	\
+			$(if $V,,--quiet) --no-cache 			\
+			--registry $(DOCKER_REGISTRY) --extra-files	\
+			$(DOCKER_FILES_DIR)/$1.d/build-toolchain.sh,	\
+			"BUILD", $1),				        \
+		$(call quiet-command,					\
+			$(DOCKER_SCRIPT) fetch $(if $V,,--quiet)	\
+				qemu/$1 $(DOCKER_REGISTRY),		\
+			"FETCH", $1)					\
+		$(call quiet-command,					\
+			$(DOCKER_SCRIPT) update $(if $V,,--quiet) 	\
+				qemu/$1 				\
+				$(if $(NOUSER),,--add-current-user) 	\
+			"PREPARE", $1))
+debian-toolchain = $(call debian-toolchain-run,$(patsubst docker-image-%,%,$1))
+
+docker-image-debian-nios2-cross: $(DOCKER_FILES_DIR)/debian-toolchain.docker \
+    $(DOCKER_FILES_DIR)/debian-nios2-cross.d/build-toolchain.sh
+	$(call debian-toolchain, $@)
+
 # 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-hexagon-cross: docker-image-debian10
+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
@@ -161,6 +185,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-sh4-cross debian-sparc64-cross
 DOCKER_PARTIAL_IMAGES += debian-tricore-cross
 DOCKER_PARTIAL_IMAGES += debian-xtensa-cross
diff --git a/tests/docker/dockerfiles/debian-nios2-cross.d/build-toolchain.sh b/tests/docker/dockerfiles/debian-nios2-cross.d/build-toolchain.sh
new file mode 100755
index 0000000000..ba3c9d8aff
--- /dev/null
+++ b/tests/docker/dockerfiles/debian-nios2-cross.d/build-toolchain.sh
@@ -0,0 +1,87 @@
+#!/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
+
+#
+# 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 ..
diff --git a/tests/docker/dockerfiles/debian-toolchain.docker b/tests/docker/dockerfiles/debian-toolchain.docker
new file mode 100644
index 0000000000..738d808aa6
--- /dev/null
+++ b/tests/docker/dockerfiles/debian-toolchain.docker
@@ -0,0 +1,36 @@
+#
+# Docker toolchain cross-compiler
+#
+# This dockerfile is used for building a cross-compiler toolchain.
+# The script for building the toolchain is supplied via extra-files.
+#
+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 && \
+    DEBIAN_FRONTEND=noninteractive eatmydata \
+    apt build-dep -yy --arch-only gcc glibc
+
+ADD build-toolchain.sh /root/build-toolchain.sh
+
+RUN cd /root && ./build-toolchain.sh
+
+# Throw away the extra toolchain build deps, the downloaded source,
+# and the build trees by restoring the original debian10 image,
+# then copying the built toolchain from stage 0.
+FROM qemu/debian10
+COPY --from=0 /usr/local /usr/local
-- 
2.30.2



  parent reply	other threads:[~2021-10-26 10:33 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26 10:22 [PATCH v1 00/28] testing, plugins and gdbstub for 6.2 Alex Bennée
2021-10-26 10:22 ` [PATCH v1 01/28] tests/docker: Use apt build-dep in debian10 Alex Bennée
2021-10-26 10:22 ` [PATCH v1 02/28] tests/docker: Simplify debian-all-test-cross Alex Bennée
2021-10-26 10:22 ` [PATCH v1 03/28] tests/docker: Update debian-hexagon-cross to a newer toolchain Alex Bennée
2021-10-26 14:58   ` Philippe Mathieu-Daudé
2021-10-26 14:59     ` Philippe Mathieu-Daudé
2021-10-26 10:22 ` [PATCH v1 04/28] gitlab-ci: Remove special casing for hexagon testing Alex Bennée
2021-10-26 15:00   ` Philippe Mathieu-Daudé
2021-10-26 20:46   ` Willian Rampazzo
2021-10-26 10:22 ` Alex Bennée [this message]
2021-10-26 15:01   ` [PATCH v1 05/28] tests/docker: Add debian-nios2-cross image Philippe Mathieu-Daudé
2021-10-26 20:49   ` Willian Rampazzo
2021-10-26 10:22 ` [PATCH v1 06/28] tests/docker: Add debian-microblaze-cross image Alex Bennée
2021-10-26 15:02   ` Philippe Mathieu-Daudé
2021-10-26 20:50   ` Willian Rampazzo
2021-10-26 10:22 ` [PATCH v1 07/28] tests/tcg: Enable container_cross_cc for microblaze Alex Bennée
2021-10-26 15:03   ` Philippe Mathieu-Daudé
2021-10-26 10:22 ` [PATCH v1 08/28] tests/tcg: Fix some targets default cross compiler path Alex Bennée
2021-10-26 10:41   ` Philippe Mathieu-Daudé
2021-10-26 10:22 ` [PATCH v1 09/28] tests/docker: split PARTIAL into PARTIAL and VIRTUAL images Alex Bennée
2021-10-26 20:01   ` Richard Henderson
2021-10-26 20:52   ` Willian Rampazzo
2021-10-26 10:22 ` [PATCH v1 10/28] tests/docker: allow non-unique userid Alex Bennée
2021-10-26 20:42   ` Richard Henderson
2021-11-01 15:10     ` Alex Bennée
2021-10-26 10:22 ` [PATCH v1 11/28] tests/tcg: enable debian-nios2-cross for test building Alex Bennée
2021-10-26 15:04   ` Philippe Mathieu-Daudé
2021-10-26 20:02   ` Richard Henderson
2021-10-26 10:22 ` [PATCH v1 12/28] ebpf: really include it only in system emulators Alex Bennée
2021-10-26 20:03   ` Richard Henderson
2021-10-27 16:10   ` Warner Losh
2021-10-26 10:22 ` [PATCH v1 13/28] plugins/cache: freed heap-allocated mutexes Alex Bennée
2021-10-26 15:06   ` Philippe Mathieu-Daudé
2021-10-26 10:22 ` [PATCH v1 14/28] plugins/cache: implement unified L2 cache emulation Alex Bennée
2021-10-26 10:22 ` [PATCH v1 15/28] plugins/cache: split command line arguments into name and value Alex Bennée
2021-10-26 10:22 ` [PATCH v1 16/28] plugins/cache: make L2 emulation optional through args Alex Bennée
2021-10-26 10:22 ` [PATCH v1 17/28] docs/tcg-plugins: add L2 arguments to cache docs Alex Bennée
2021-10-26 10:22 ` [PATCH v1 18/28] chardev: don't exit() straight away on C-a x Alex Bennée
2021-10-26 10:22 ` [PATCH v1 19/28] tests/plugins: extend the insn plugin to track opcode sizes Alex Bennée
2021-10-26 10:22 ` [PATCH v1 20/28] plugins: try and make plugin_insn_append more ergonomic Alex Bennée
2021-10-26 20:09   ` Richard Henderson
2021-10-26 10:22 ` [PATCH v1 21/28] docs: remove references to TCG tracing Alex Bennée
2021-10-26 20:10   ` Richard Henderson
2021-10-26 10:22 ` [PATCH v1 22/28] tracing: remove TCG memory access tracing Alex Bennée
2021-10-26 20:15   ` Richard Henderson
2021-10-26 10:22 ` [PATCH v1 23/28] tracing: remove the trace-tcg includes from the build Alex Bennée
2021-10-26 20:20   ` Richard Henderson
2021-10-26 10:22 ` [PATCH v1 24/28] tracing: excise the tcg related from tracetool Alex Bennée
2021-10-26 20:23   ` Richard Henderson
2021-10-26 10:22 ` [PATCH v1 25/28] plugins: add helper functions for coverage plugins Alex Bennée
2021-10-26 20:25   ` Richard Henderson
2021-10-27 16:09     ` Warner Losh
2021-10-27 18:58       ` Richard Henderson
2021-10-28 17:09         ` Warner Losh
2021-10-26 10:22 ` [PATCH v1 26/28] contrib/plugins: add a drcov plugin Alex Bennée
2021-10-26 10:22 ` [PATCH v1 27/28] tests/tcg: remove duplicate EXTRA_RUNS Alex Bennée
2021-10-26 15:11   ` Philippe Mathieu-Daudé
2021-10-26 20:27   ` Richard Henderson
2021-10-27 14:48     ` Alex Bennée
2021-10-26 10:22 ` [PATCH v1 28/28] gdbstub: Switch to the thread receiving a signal Alex Bennée
2021-10-26 20:34   ` 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=20211026102234.3961636-6-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=aaron@os.amperecomputing.com \
    --cc=aurelien@aurel32.net \
    --cc=berrange@redhat.com \
    --cc=cota@braap.org \
    --cc=crosa@redhat.com \
    --cc=crwulff@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=fam@euphon.net \
    --cc=kuhn.chenqun@huawei.com \
    --cc=ma.mandourr@gmail.com \
    --cc=mahmoudabdalghany@outlook.com \
    --cc=marex@denx.de \
    --cc=minyihh@uci.edu \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=robhenry@microsoft.com \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    --cc=willianr@redhat.com \
    /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).