From nobody Mon Feb 9 03:44:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496420676993335.7996995266759; Fri, 2 Jun 2017 09:24:36 -0700 (PDT) Received: from localhost ([::1]:50655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGpNK-0003uE-EJ for importer@patchew.org; Fri, 02 Jun 2017 12:24:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGp7w-0005wl-8R for qemu-devel@nongnu.org; Fri, 02 Jun 2017 12:08:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGp7u-0004yo-V8 for qemu-devel@nongnu.org; Fri, 02 Jun 2017 12:08:40 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:35830) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGp7u-0004yQ-OA for qemu-devel@nongnu.org; Fri, 02 Jun 2017 12:08:38 -0400 Received: by mail-wm0-x236.google.com with SMTP id b84so29299893wmh.0 for ; Fri, 02 Jun 2017 09:08:38 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h73sm4435042wma.10.2017.06.02.09.08.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 09:08:34 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 74C183E028C; Fri, 2 Jun 2017 17:08:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/eETwYi8yC5aBcH5pI9IhkPlstvELhvMY9I3yhbPgkw=; b=eVwO3j1xJy7R/p4N8UiB2I+bEhC4a5/VhICVoSzIfJs6hGRJpmE2H/t+KTlyudeyfq KreYr6kPdz0TFfv48Ib9886CB7Z1IuDHhfBKcHagXZicca+FBJ/ibJg1OSRa1/2Xaeyn 5jfnnixU/cMSSjPltNiIda5gXXLWc7Zozua3s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/eETwYi8yC5aBcH5pI9IhkPlstvELhvMY9I3yhbPgkw=; b=pq5vw+cM3Iy1RpkwjUOCwWRcyHhiUZ7Q0ObbB+DmGspytEryAr7doiwPSJToWbWlFJ buXOjQQ13RJsJZnkKpFzWZ4mPJghja+3ySTka3EoUWB6Ss4Hjjr8HXe14o0syJ5Lfwvn gZw5CfFbvX7M1GtYj6mjpcTWeBSm3Rr0BmHuz/6mSlw/MFrDV0QA2mHvHZ2JHzqFV70Z /iIx849FqzJ2IoHUHdLsWhPNhtF5C8+xpgPw0tPxjXPkwXgBU2cUF/6+HnV84VnyLEYE Fs18cMsWMi9YeXDMEvNICzfsaSLfMq/q+H7j//PeTkZePp+ovqxwdW2ZYrpyYlb2Dd2X 38uQ== X-Gm-Message-State: AODbwcAMSfnrvjF8DO++fIqCs8pv0diTvm/8K4Nrem/dKX7QghaMUBX9 S7Vibgy7fUG+TGAE X-Received: by 10.28.4.203 with SMTP id 194mr46571wme.118.1496419717422; Fri, 02 Jun 2017 09:08:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 2 Jun 2017 17:08:40 +0100 Message-Id: <20170602160848.4913-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170602160848.4913-1-alex.bennee@linaro.org> References: <20170602160848.4913-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 Subject: [Qemu-devel] [RISU PATCH v4 02/10] build-all-archs: support cross building via docker X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e --- 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 =20 -# 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[=3Dtags] 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" =3D -* ]]; do + opt=3D"$1"; shift + arg=3D + if [[ "$opt" =3D *=3D* ]]; then + arg=3D"${opt#*=3D}" + opt=3D"${opt%%=3D*}" + fi + case "$opt" in + --use-docker) + if [ -z "$arg" ]; then + default_tags=3D$(docker images qemu --format "{{.Repositor= y}}:{{.Tag}}" | grep "\(arm\|power\).*cross$") + docker_tags=3D$(echo $default_tags | sed 's/\n/\s/g' ) + else + docker_tags=3D"$arg" + fi + ;; + --help) + usage + ;; + *) + usage + ;; + esac +done =20 # 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=3D"docker run --rm -t -u $(id -u) -v $(pwd):$(pwd) -w $(pwd)" =20 program_exists() { + if [ ! -z "$docker_tags" ]; then + use_docker_tag=3D"" + for tag in $docker_tags; do + if ${DOCKER_RUN} ${tag} /bin/bash -c "command -v $1 >/dev/null= "; then + use_docker_tag=3D$tag + return + fi + done + fi + command -v "$1" >/dev/null 2>&1 } =20 @@ -30,19 +80,29 @@ for triplet in aarch64-linux-gnu arm-linux-gnueabihf m6= 8k-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 =20 # Do a complete rebuild from scratch, because it's cheap enough. rm -rf build/${triplet} mkdir -p build/${triplet} =20 - (cd build/${triplet} && CROSS_PREFIX=3D"${triplet}-" ../../configure) - make -C build/${triplet} EXTRA_CFLAGS=3D-Werror + CONFIGURE=3D"cd build/${triplet} && CROSS_PREFIX=3D"${triplet}-" ../.= ./configure" + MAKE=3D"make -C build/${triplet} EXTRA_CFLAGS=3D-Werror" =20 + 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 =20 # Now run risugen for all architectures mkdir -p build/risuout +set -o pipefail # detect failures in pipeline =20 for f in *.risu; do echo "Running risugen on $f..." --=20 2.13.0