From patchwork Mon Jun 19 10:46:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 105821 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp810500qgd; Mon, 19 Jun 2017 03:51:16 -0700 (PDT) X-Received: by 10.159.48.1 with SMTP id h1mr14651714uab.102.1497869476815; Mon, 19 Jun 2017 03:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497869476; cv=none; d=google.com; s=arc-20160816; b=J3RO6aaRm+YhD32ubkBMGaqkElVF2dClA2SxkBKgnXyzh8CZr3MhKPpFbrGqw6Z0IW 5FbsDxu5RubJnF9AOcxxQdNm9d65aOK2PV1U2l0YZRVt3kpADrUopdnZluBCxMiybSEs 5PoD3OyWT7WsHcSnJKuydEoJlNF/ID/re0cMNcEzxup1U+SGGFkfIRcB0nwIa+tTxH3f bm89X0dA6LU/+6QEwN9SY57AvRG3VvPC1R7WEbMsqWThyXWmzGdQavJBI63A1BiZBS4q qwRryjJCIVRvt74DBbZy+KdnjDuCBuvUoLWmZeV+wX2nyummpHcMFyJG3vNMw0zGeDSW qpNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=0hV6icSBl6NGyP4dZPbmN3LtwMPFGu9f3EQ2z6M+6xQ=; b=x5KgEScRJqebmYdpsDN8pZW2D8Y3kd+8W2o4mSNzyHkpQ/KFS2BRqBX+x7GBeGSUU1 qs5nJOfsrYkPYkJhHesudYiuCix+oWqBoyNS9KxRkmKL8/txZdIKKGwCRl9ISQd66i8X Bb8+1GSLWvb9ORodHadHfVZ/ucpWSrf0WE5CaBtEu7w+20e0GfAOq/hBF8vTvCs9lnC0 PYfPT5rdZdvEnFAcUCl+CeNKF1fSmZcKPkEGORkYmjPElHgtsDqJS+XJX5ZQGiNANF0j 2zndgKNwzBxc+VvpJPNjDfKoQNehX4aywiM8x7JzAlkbqsZXBrWA9ZpvPbki7pv+MTql 6agA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=Et0Vx7Nk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u125si4385197vke.14.2017.06.19.03.51.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 19 Jun 2017 03:51:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=Et0Vx7Nk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuH6-0002nH-7n for patch@linaro.org; Mon, 19 Jun 2017 06:51:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dMuCR-0007Ki-AH for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dMuCQ-0004rw-65 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:27 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:35280) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dMuCP-0004r2-W4 for qemu-devel@nongnu.org; Mon, 19 Jun 2017 06:46:26 -0400 Received: by mail-wr0-x234.google.com with SMTP id y25so30273710wrd.2 for ; Mon, 19 Jun 2017 03:46:25 -0700 (PDT) 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=0hV6icSBl6NGyP4dZPbmN3LtwMPFGu9f3EQ2z6M+6xQ=; b=Et0Vx7NkoNl5yRSt8hvnwlzNs3ZlrT89pWPj7gNsXxutR7p4euTPHTHJgiCHe05sV5 Bivgyb5K8ENch69kV98KrQsalis3Y2CrKTTmD2wJhu3HyjQaq/xi6Wzhl9koWK7AxUHU otm3wqlVtGB3OpjoVuCFsv+OD0lMxUivfMlC8= 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=0hV6icSBl6NGyP4dZPbmN3LtwMPFGu9f3EQ2z6M+6xQ=; b=jaVFzHuIqqDVdhZEdP9MT5ENi3L8NnyUOhCOLupNW8/RlcqRFNzsZpDc0zhlmVM0Xu d8z75MIJv8VWyZLpKBVKvjVNABCkdwa70YNfo9Ltofm/GlNi3L8CvAbSf4O7NkrANDqW WhvxXMO9JmYUuam0x7utjEQ5oQQqHvZlvZ4o0dv3UlRabU2pjnmxbAMfVUHunhw4vOGy ESruswFDjTe9tvvBeF3KJZJuTayFY6MP66kQnTdIEptaEwQkPTwEmCMfqVKp0xnP7atm +tXKF6CpbZz2yIrhTDyoN6MVRMT9cXva5dKPfM0V/85AxEh4UtHfirZuHpI/lGUYbp45 +iaA== X-Gm-Message-State: AKS2vOzsvGQfdYPLESjWduAdTDYddTjjeNAVay6Z3ghZK+sse+1eRcJu lh08jEYyKZA8Lhzi X-Received: by 10.223.146.166 with SMTP id 35mr15769241wrn.104.1497869184821; Mon, 19 Jun 2017 03:46:24 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c55sm7365285wrc.7.2017.06.19.03.46.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 03:46:23 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 47BCB3E0BA1; Mon, 19 Jun 2017 11:47:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Jun 2017 11:46:47 +0100 Message-Id: <20170619104655.31104-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170619104655.31104-1-alex.bennee@linaro.org> References: <20170619104655.31104-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 Subject: [Qemu-devel] [RISU PATCH v5 05/13] 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_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- v5 - swapped with --static patch so this can be dropped if desired --- build-all-archs | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) -- 2.13.0 diff --git a/build-all-archs b/build-all-archs index 581a1b4..63918e5 100755 --- a/build-all-archs +++ b/build-all-archs @@ -11,9 +11,6 @@ # 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 @@ -21,7 +18,10 @@ usage() { Options include: --static build a static binary + --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 } @@ -37,6 +37,14 @@ while [[ "$1" = -* ]]; do --static) CONF="--static" ;; + --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 ;; @@ -48,10 +56,24 @@ 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 } @@ -62,19 +84,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 ${CONF}) - make -C build/${triplet} EXTRA_CFLAGS=-Werror + CONFIGURE="cd build/${triplet} && CROSS_PREFIX="${triplet}-" ../../configure ${CONF}" + 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..."