From patchwork Thu Apr 19 13:58:21 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: 133766 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp673871ljf; Thu, 19 Apr 2018 07:03:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/LV9Dxh9OJxYkqpotAlkIy4SbsO7kW7B1mm+MBMj+6kiobTAl4WcNIjm7fJm8CRgGA4E/r X-Received: by 10.55.215.198 with SMTP id t67mr6068506qkt.190.1524146580680; Thu, 19 Apr 2018 07:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524146580; cv=none; d=google.com; s=arc-20160816; b=zJ0mYobsiUBmRIlydatbfkntsRRJKvD7TxejRHL1erIYAnGBxTfeGrzD46rnljQD5H C9WSyYpaQsfaJ1zjjo3SkkT+ukme7eAqWxxD8V8VkUwMX0ZmvcPNurIwvE5SLk0tEsSx Twgp2Icx5C2FbCA94VGjkVJgDN2tVLZRPOmBAzWN3+6Gwkc17CJUjGqWrV9PeHNew4QA ld/IOFrfIrv7arnx353CTKqrx+dc9uK0uyKlaEw9a82gu6/ZFPST8c/CoyZTntJCLmSn 7yakxTRthEWLR/TdOWJ2KJOllgle4v6t5KJANTzEkBi/RJU1B9zh+Io0GC5ttX5s70q2 dL6w== 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=57DG2ledkL4kd6fdevGAh9vF1I76amNVFoyAwiMCJcs=; b=d89gkErX26mC2aeBV38pcobHH1jrd5FnBn+0Lj9wLlyLqaY84v7G6937plF3wkqnXL 2v3q+MThkSWmrIy3xR6iBHNL6aljNaz6iXBqH9iO5ylhmkQzAsQM8GHE5QYSlsMlhQMj ArpTGBy7ZUg1AwFIw+p53oSoJqvSI9PQiiwjFaLMpjY2/8z+FWV3wgeo9T9eyUlfVkqi 0inddisxsehAvclgaAFHIl6dy36j5Z2oevNn0Rvd8NnTmsVPEiSjLjdYqkxgBSoKE8MD z35BqukQtswHHWqEzGd69sUsT6pYs/WbTL5E3utrFjfNytXN5lh5Gqk4Fi48yjf0v6ls Zkrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SHvC6Jl+; 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 x3si1102288qke.294.2018.04.19.07.03.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Apr 2018 07:03:00 -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=SHvC6Jl+; 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]:49819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9A9M-0000MY-4D for patch@linaro.org; Thu, 19 Apr 2018 10:03:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9A5c-0005vz-Ig for qemu-devel@nongnu.org; Thu, 19 Apr 2018 09:59:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9A5b-00026K-27 for qemu-devel@nongnu.org; Thu, 19 Apr 2018 09:59:08 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:43743) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f9A5a-00025g-Qq for qemu-devel@nongnu.org; Thu, 19 Apr 2018 09:59:06 -0400 Received: by mail-wr0-x233.google.com with SMTP id u4-v6so14330461wrg.10 for ; Thu, 19 Apr 2018 06:59:06 -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=57DG2ledkL4kd6fdevGAh9vF1I76amNVFoyAwiMCJcs=; b=SHvC6Jl+6ToQeeadlGScZVRg7JNGAVHiRhVSUD0TrLBfSYHXRmxv5ZrLi7T25XmjXD 0aWQuJX3XUEUqJV7dBDB9Oqe+7PkhOj9/k2IdzLOpIvIJIrxjcrq1ltfg7atTrrkUzCR vEgEjoVRjkERr9WdCs06Nda9106LgExr5OV0w= 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=57DG2ledkL4kd6fdevGAh9vF1I76amNVFoyAwiMCJcs=; b=cn4f/kJih8He9XiatvtcHIQ9eaXHn2w5s6AC0xgNAa6wn5oTFjIL/Q7a2fQtHT6mVQ dVEKNrNYde1FRCKCeIKPtV1WvI1KtyMxAiDyR4Fa2Vf861xkHy9vujz7/V3p5+vz2823 IleNgnXYwgvBCUGQVsumcpHron0v7Sz+1NntcqDVEJnPDuHBoLP6KbxP7Ns8e2pnG3z2 PGx0NTluPCjFDZerUC7cwQYSniudxcR/xBuwVKszWqwbTKHzd25EWrN/ssKVOy1sJ5mW 1MGEE4S+kGUpd3yDssizerr7Pe8qCCtHd0co+HC9KEDCongqt0f0hQvsPcsPdSyegv+E 3zkw== X-Gm-Message-State: ALQs6tA8r3rGAkmcxNbGaM127Tij+oNsI6uO6SLddAtvoFOwxa9M2bjL G3YwZOt6TjK+Iw07Hjow03LIKQ== X-Received: by 2002:adf:db90:: with SMTP id u16-v6mr5069350wri.90.1524146345625; Thu, 19 Apr 2018 06:59:05 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u187sm2632wmu.46.2018.04.19.06.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Apr 2018 06:59:02 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id BED9B3E0308; Thu, 19 Apr 2018 14:59:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, cota@braap.org, famz@redhat.com, berrange@redhat.com, f4bug@amsat.org, richard.henderson@linaro.org, balrogg@gmail.com, aurelien@aurel32.net, agraf@suse.de Date: Thu, 19 Apr 2018 14:58:21 +0100 Message-Id: <20180419135901.30035-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419135901.30035-1-alex.bennee@linaro.org> References: <20180419135901.30035-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::233 Subject: [Qemu-devel] [PATCH v2 03/43] 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?= , qemu-devel@nongnu.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.17.0 diff --git a/configure b/configure index b0ae632ee4..0dca341f2a 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" ;; @@ -6777,6 +6793,8 @@ case "$target" in ;; esac +target_compiler="" + mkdir -p $target_dir echo "# Automatically generated by configure - do not modify" > $config_target_mak @@ -6805,6 +6823,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 @@ -6812,6 +6831,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) ;; @@ -6853,6 +6873,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 @@ -6927,6 +6948,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() { @@ -7000,6 +7040,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="" @@ -7122,6 +7166,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