From patchwork Tue Apr 10 19:38:57 2018 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: 133094 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1631880ljb; Tue, 10 Apr 2018 12:40:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx49LANB09ZZKngUTowlFqPXMzORc7olRp9WljGUz0xAdnvJqnt5Y7am7ij8xzDHOmvFdXIyE X-Received: by 10.55.130.67 with SMTP id e64mr2616382qkd.128.1523389199908; Tue, 10 Apr 2018 12:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523389199; cv=none; d=google.com; s=arc-20160816; b=GhUpg0ashIR6KAs9kByLmsoUAuizB/FwCPg5oFUCVOhrUpHaA0Ph7Pja2EK4BLcDNd n8HdZoIhDyjSDuDKI1tUCDRNbzcZGXtDhuWx9Q7EAvpEPciwJtsNgXwIeW2vSYUviPU3 6nS8agif1LZJne/1l1Gf1rj//p5Q/dqDL4Ahn8DBGSMhEA3MPYfmFOgs3YeMw9LLwL7N 5rd3InT7c6z7XS66r50sSWAMNRTIuunW1MNSrw7Fum6ZSnv7my2irLrgX42ygJb9NuyO JsoV3Ihbu9WCwRWSiliyUpSJGmGx7cNPikV6OziXsIDs6EfCZkDbrerxg6dCuO937r4o A76g== 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=q5tHR9W1VGlVHRbwWx5NGHMfhuyYinJGu9UTmTekjmg=; b=vS6aFZ6HmIuoj0MyGhGygKeLuCmN7hdE1TY09x1OMATIeUi1gu37dbTi2X4kfmOswf a5zcaNwaVzGHm8gFGokkwDnRstxoFf1P36v/F74lWP2sRrcVbc2CXeanec43ooz8n7vl IXzVXHtwVhM+JZUvtgx7iQNvM9q+1AFobHMHSPxZ9DiSMBsxm7AhP+jjZE8pG9fnLYkg qfz+084H9WEF/OzL10hWJsNf7r0kw9g63/QZWQzT000EX3P0DtnRfE0S8TQCi5vzN9FS IZGPQe2miH73n3YVMV40kporsPPF1WMZUezw4dNNnvjzAibQWUkZWGxV4B3F4F+b9Hq/ VTsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KvURY5Al; 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 b186si426036qke.118.2018.04.10.12.39.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Apr 2018 12:39:59 -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.s=google header.b=KvURY5Al; 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]:39687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5z7X-0000Cn-9f for patch@linaro.org; Tue, 10 Apr 2018 15:39:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5z6z-000057-AL for qemu-devel@nongnu.org; Tue, 10 Apr 2018 15:39:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5z6x-0006Fv-Md for qemu-devel@nongnu.org; Tue, 10 Apr 2018 15:39:25 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:44429) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f5z6x-0006FB-Fs for qemu-devel@nongnu.org; Tue, 10 Apr 2018 15:39:23 -0400 Received: by mail-wr0-x22b.google.com with SMTP id u46so13917259wrc.11 for ; Tue, 10 Apr 2018 12:39:23 -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=q5tHR9W1VGlVHRbwWx5NGHMfhuyYinJGu9UTmTekjmg=; b=KvURY5Al2QjKiHqYYTXvkCMH3OfbBNsLy+H62HKkZWZROw92AM6GyvT/hdR2b06qpp FHmWlif19i1kQXSeoTNwOXAW8tlIcN5X+oGNd9d1MJTGPa8kiZKL7Pl5OpHncdSMJY7t kAHCkzkRrrFA8IyEuGUud55hAuWhj+2YXr93g= 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=q5tHR9W1VGlVHRbwWx5NGHMfhuyYinJGu9UTmTekjmg=; b=SJRW4o0w7KwR0NtS9C1UrE0ykCzyBj2A4ENiqIzSRdB5zweklMwI7B9iH0Ozb+yyEr WnOvFwoza/VpyKsQNdBqrqwZV2uWAeBE/xlq99FhB1MmLv9yffM0liWcB0589j8HGmNS Av739t0uThwLQF4LGYero7yprnVYFHqntd8LFckK70LcS+/qqyVv09qlY41ONdgTBnI9 dwjWFS6mSq1w7371lPSu3R52BT5Ze28KODx45a6Q1J0RBI4i+Wam9N3BQ3F8t4J8DQo+ C7lEPohF8tYY7LNKLhifR0Gz0gYPIoBWPJVfgt/m+WAM83WcY1rz9GIChhpgyKOFoxiS zNWQ== X-Gm-Message-State: ALQs6tAOOENKQFy/fyuRUP+hqHQ1LQO2lbodbkI8+770+FI+Vv21U3Un cgxQqZVprEVxH5tw/WNJNH7fyQ== X-Received: by 10.223.160.91 with SMTP id l27mr1250135wrl.114.1523389162342; Tue, 10 Apr 2018 12:39:22 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t142sm2405474wmt.12.2018.04.10.12.39.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 12:39:20 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 87A943E06C8; Tue, 10 Apr 2018 20:39:19 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 10 Apr 2018 20:38:57 +0100 Message-Id: <20180410193919.28026-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180410193919.28026-1-alex.bennee@linaro.org> References: <20180410193919.28026-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::22b Subject: [Qemu-devel] [PATCH v1 02/24] configure: add support for --cross-cc-FOO 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?= , famz@redhat.com, cota@braap.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows us to specify cross compilers for our guests. This is useful for building test images/programs. Currently we re-run the compile test for each target. I couldn't think of a way to cache the value for a given arch without getting messier configure code. The cross compiler for the guest is visible to each target as CROSS_CC_GUEST in config-target.mak. Signed-off-by: Alex Bennée --- configure | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) -- 2.16.2 diff --git a/configure b/configure index b402befe94..b5f3b3fe29 100755 --- a/configure +++ b/configure @@ -453,6 +453,13 @@ vxhs="" libxml2="" docker="no" +# cross compilers defaults, can be overridden with --cross-cc-ARCH +cross_cc_aarch64="aarch64-linux-gnu-gcc" +cross_cc_arm="arm-linux-gnueabihf-gcc" +cross_cc_powerpc="powerpc-linux-gnu-gcc" + +enabled_cross_compilers="" + supported_cpu="no" supported_os="no" bogus_os="no" @@ -483,6 +490,11 @@ for opt do ;; --disable-debug-info) debug_info="no" ;; + --cross-cc-*[!a-zA-Z0-9_0]=*) error_exit "Passed bad --cross-cc-FOO option" + ;; + --cross-cc-*) cc_arch=${opt#--cross-cc-} + eval "cross_cc_${cc_arch}=\$optarg" + ;; esac done # OS specific @@ -675,10 +687,12 @@ case "$cpu" in i386|i486|i586|i686|i86pc|BePC) cpu="i386" supported_cpu="yes" + cross_cc_i386=gcc ;; x86_64|amd64) cpu="x86_64" supported_cpu="yes" + cross_cc_x86_64=gcc ;; armv*b|armv*l|arm) cpu="arm" @@ -912,6 +926,8 @@ for opt do ;; --disable-debug-info) ;; + --cross-cc-*) + ;; --enable-modules) modules="yes" ;; @@ -6766,6 +6782,8 @@ case "$target" in ;; esac +target_compiler="" + mkdir -p $target_dir echo "# Automatically generated by configure - do not modify" > $config_target_mak @@ -6794,6 +6812,7 @@ case "$target_name" in bflt="yes" mttcg="yes" gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" + target_compiler=$cross_cc_arm ;; aarch64|aarch64_be) TARGET_ARCH=aarch64 @@ -6801,6 +6820,7 @@ case "$target_name" in bflt="yes" mttcg="yes" gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" + target_compiler=$cross_cc_aarch64 ;; cris) ;; @@ -6842,6 +6862,7 @@ case "$target_name" in ;; ppc) gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" + target_compiler=$cross_cc_powerpc ;; ppcemb) TARGET_BASE_ARCH=ppc @@ -6916,6 +6937,25 @@ if [ "$TARGET_BASE_ARCH" = "" ]; then TARGET_BASE_ARCH=$TARGET_ARCH fi +# Do we have a cross compiler for this target? +if has $target_compiler; then + + cat > $TMPC << EOF +#include +int main(void) { + printf("Hello World!\n"); +} +EOF + + if ! do_compiler $target_compiler -o $TMPE $TMPC -static ; then + target_compiler="" + else + enabled_cross_compilers="${enabled_cross_compilers} ${target_compiler}" + fi +else + target_compiler="" +fi + symlink "$source_path/Makefile.target" "$target_dir/Makefile" upper() { @@ -6989,6 +7029,10 @@ if test "$target_bsd_user" = "yes" ; then echo "CONFIG_BSD_USER=y" >> $config_target_mak fi +if test -n "$target_compiler"; then + echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak +fi + # generate QEMU_CFLAGS/LDFLAGS for targets cflags="" @@ -7111,6 +7155,12 @@ echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak done # for target in $targets +if test -n "$enabled_cross_compilers"; then + echo + echo "NOTE: cross-compilers enabled:" + printf '%s\n' $enabled_cross_compilers | sort -u +fi + if [ "$dtc_internal" = "yes" ]; then echo "config-host.h: subdir-dtc" >> $config_host_mak fi