From: "Alex Bennée" <alex.bennee@linaro.org>
To: peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [RISU PATCH v4 02/10] build-all-archs: support cross building via docker
Date: Fri, 2 Jun 2017 17:08:40 +0100 [thread overview]
Message-ID: <20170602160848.4913-3-alex.bennee@linaro.org> (raw)
In-Reply-To: <20170602160848.4913-1-alex.bennee@linaro.org>
If we want to link to any other libraries we might find using simple
cross toolchains doesn't work so well. One way around this is to use a
dockerised cross-toolchain which then won't clash with your host
system. If the user specifies --use-docker the obvious will be done.
By default we use the QEMU projects qemu:debian-FOO-cross images as
RISU hackers are likely to be QEMU developers too. However any docker
tag can be passed on the command line.
If none of the docker images have usable compilers we fall back to
checking the host path.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
build-all-archs | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 66 insertions(+), 6 deletions(-)
diff --git a/build-all-archs b/build-all-archs
index 2768727..78f062e 100755
--- a/build-all-archs
+++ b/build-all-archs
@@ -11,15 +11,65 @@
# Contributors:
# Peter Maydell (Linaro) - initial implementation
-# So we notice risugen failing even though it's in a pipeline
-set -o pipefail
+# Simple usage
+usage() {
+ cat <<-EOF
+ Usage: $0 [options]
+
+ Options include:
+ --use-docker[=tags] use docker cross compile
+
+ If specifying docker the default will be to use the any
+ qemu:debian-FOO-cross targets available on your system.
+EOF
+ exit 1
+}
+
+while [[ "$1" = -* ]]; do
+ opt="$1"; shift
+ arg=
+ if [[ "$opt" = *=* ]]; then
+ arg="${opt#*=}"
+ opt="${opt%%=*}"
+ fi
+ case "$opt" in
+ --use-docker)
+ if [ -z "$arg" ]; then
+ default_tags=$(docker images qemu --format "{{.Repository}}:{{.Tag}}" | grep "\(arm\|power\).*cross$")
+ docker_tags=$(echo $default_tags | sed 's/\n/\s/g' )
+ else
+ docker_tags="$arg"
+ fi
+ ;;
+ --help)
+ usage
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
# Debian stretch and Ubuntu Xenial have cross compiler packages for
# all of these:
-# gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-m68k-linux-gnu
-# gcc-powerpc64le-linux-gnu gcc-powerpc64-linux-gnu
+# gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-m68k-linux-gnu
+# gcc-powerpc64le-linux-gnu gcc-powerpc64-linux-gnu
+# If docker is enabled we just brute force the various images until we
+# can set the one that has a workable cross compiler.
+
+DOCKER_RUN="docker run --rm -t -u $(id -u) -v $(pwd):$(pwd) -w $(pwd)"
program_exists() {
+ if [ ! -z "$docker_tags" ]; then
+ use_docker_tag=""
+ for tag in $docker_tags; do
+ if ${DOCKER_RUN} ${tag} /bin/bash -c "command -v $1 >/dev/null"; then
+ use_docker_tag=$tag
+ return
+ fi
+ done
+ fi
+
command -v "$1" >/dev/null 2>&1
}
@@ -30,19 +80,29 @@ for triplet in aarch64-linux-gnu arm-linux-gnueabihf m68k-linux-gnu \
if ! program_exists "${triplet}-gcc"; then
echo "Skipping ${triplet}: no compiler found"
continue
+ else
+ echo "Building ${triplet} on ${use_docker_tag:-host}..."
fi
# Do a complete rebuild from scratch, because it's cheap enough.
rm -rf build/${triplet}
mkdir -p build/${triplet}
- (cd build/${triplet} && CROSS_PREFIX="${triplet}-" ../../configure)
- make -C build/${triplet} EXTRA_CFLAGS=-Werror
+ CONFIGURE="cd build/${triplet} && CROSS_PREFIX="${triplet}-" ../../configure"
+ MAKE="make -C build/${triplet} EXTRA_CFLAGS=-Werror"
+ if [ -z "$use_docker_tag" ]; then
+ /bin/bash -c "${CONFIGURE}"
+ ${MAKE}
+ else
+ ${DOCKER_RUN} $use_docker_tag /bin/bash -c "${CONFIGURE}"
+ ${DOCKER_RUN} $use_docker_tag /bin/bash -c "${MAKE}"
+ fi
done
# Now run risugen for all architectures
mkdir -p build/risuout
+set -o pipefail # detect failures in pipeline
for f in *.risu; do
echo "Running risugen on $f..."
--
2.13.0
next prev parent reply other threads:[~2017-06-02 16:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 16:08 [Qemu-devel] [RISU PATCH v4 00/10] record/replay patches Alex Bennée
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 01/10] .gitignore: ignore build directories Alex Bennée
2017-06-06 9:51 ` Peter Maydell
2017-06-02 16:08 ` Alex Bennée [this message]
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 03/10] build-all-archs: support --static flag Alex Bennée
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 04/10] risu: a bit more verbosity when running Alex Bennée
2017-06-06 9:55 ` Peter Maydell
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 05/10] risu: paramterise send/receive functions Alex Bennée
2017-06-06 9:57 ` Peter Maydell
2017-06-06 10:13 ` Alex Bennée
2017-06-06 11:37 ` Peter Maydell
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 06/10] risu: add header to trace stream Alex Bennée
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 07/10] risu: add simple trace and replay support Alex Bennée
2017-06-06 13:39 ` Peter Maydell
2017-06-06 14:19 ` Alex Bennée
2017-06-06 14:32 ` Peter Maydell
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 08/10] risu: add support compressed tracefiles Alex Bennée
2017-06-06 13:45 ` Peter Maydell
2017-06-06 14:24 ` Alex Bennée
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 09/10] new: record_traces.sh helper script Alex Bennée
2017-06-06 13:47 ` Peter Maydell
2017-06-06 14:25 ` Alex Bennée
2017-06-02 16:08 ` [Qemu-devel] [RISU PATCH v4 10/10] new: run_risu.sh script Alex Bennée
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=20170602160848.4913-3-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=peter.maydell@linaro.org \
--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).