From patchwork Mon Nov 12 11:59:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 996388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-489728-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bYzDK3pf"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42tq8Z2j64z9s1x for ; Mon, 12 Nov 2018 23:00:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=gDK67KVS3mZnnRQ0 R5QzulPoFGvysHO9+RBLm5A7UKlTy8MwDW7CU2oAiwPI08BtmcPikj2FZji56w2z HK2MT7WUTV6aO5O6ktI47xcJbcAwv3vB3yMoJZp34aGges/jnyPRLSWxQL5fVuBH Mow2gtcRt4uaGE92y9bh+vdUi7w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=6L5QchAyoqxnx4VMgRo2yY dG5U8=; b=bYzDK3pfT4CRqfInOqYFaXcHYAIjCOoigHBBSyL+qUHplF0+Wgnv4z /kH+gb+D6QXkW9aL+PYjTtkKL/TesAADkdw+CZdJ1fSauGQMakX0rB5vgK1Z4Bdn 0xX8u/WDSmNJPNIRb88g4SKVkGj/Mqzam5Vt/BJ8IV+jBry/nPYto= Received: (qmail 98876 invoked by alias); 12 Nov 2018 12:00:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 98715 invoked by uid 89); 12 Nov 2018 12:00:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=machinery, rework X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Nov 2018 12:00:02 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B5DDE561F6; Mon, 12 Nov 2018 07:00:00 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id TH84KJsFbRKV; Mon, 12 Nov 2018 07:00:00 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 630AC561EA; Mon, 12 Nov 2018 07:00:00 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTP id wACBxeB5177990; Mon, 12 Nov 2018 09:59:41 -0200 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: Arnaud Charlet , Eric Botcazou , Pierre-Marie de Rodat Subject: [PR81878]: fix --disable-bootstrap --enable-languages=ada, and cross-back gnattools build Date: Mon, 12 Nov 2018 09:59:40 -0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 gnattools build machinery uses just-build xgcc and xg++ as $(CC) and $(CXX) in native builds. However, if C and C++ languages are not enabled, it won't find them. So, enable C and C++ if Ada is enabled. Most of the time, this is probably no big deal: C is always enabled anyway, and C++ is already enabled for bootstraps. We need not enable those for cross builds, however. At first I just took the logic from gnattools/configure, but found it to be lacking: it would use the just-built tools even in cross-back settings, whose tools just built for the host would not run on the build machine. So I've narrowed down the test to rely on autoconf-detected cross-ness (build->host only), but also to ensure that host matches build, and that target matches host. I've considered sourcing ada/config-lang.in from within gnattools/configure, and testing lang_requires as set by it, so as to avoid a duplication of tests that ought to remain in sync, but decided it would be too fragile, as ada/config-lang.in does not expect srcdir to refer to gnattools. Please let me know if there are objections to this change in the next few days, e.g., if enabling C and C++ for an Ada-only build is too onerous. It is certainly possible to rework gnattools build machinery so that it uses CC and CXX as detected by the top-level configure if we can't find xgcc and xg++ in ../gcc. At least in cross builds, we already require build-time Ada tools to have the same version as that we're cross-building, so we might as well use preexisting gcc and g++ under the same requirements. for gcc/ada/gcc-interface/ChangeLog PR ada/81878 * config-lang.in (lang_requires): Set to "c c++" when gnattools wants it. for gnattools/ChangeLog PR ada/81878 * configure.ac (default_gnattools_target): Do not mistake just-built host tools as native in cross-back toolchains. * configure: Rebuilt. --- gcc/ada/gcc-interface/config-lang.in | 9 +++++++++ gnattools/configure | 32 ++++++++++++++++++++++---------- gnattools/configure.ac | 30 +++++++++++++++++++++--------- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/gcc/ada/gcc-interface/config-lang.in b/gcc/ada/gcc-interface/config-lang.in index 5dc77df282ce..8eacf7bb870e 100644 --- a/gcc/ada/gcc-interface/config-lang.in +++ b/gcc/ada/gcc-interface/config-lang.in @@ -34,6 +34,15 @@ gtfiles="\$(srcdir)/ada/gcc-interface/ada-tree.h \$(srcdir)/ada/gcc-interface/gi outputs="ada/gcc-interface/Makefile ada/Makefile" +# gnattools native builds use both $(CC) and $(CXX), see PR81878. +# This is not too onerous: C is always enabled anyway, and C++ is +# always enabled for bootstrapping. Use here the same logic used in +# gnattools/configure to decide whether to use -native or -cross tools +# for the build. +if test "x$cross_compiling/$build/$host" = "xno/$host/$target" ; then + lang_requires="c c++" +fi + target_libs="target-libada" lang_dirs="gnattools" diff --git a/gnattools/configure b/gnattools/configure index ccb512e39b6b..c2d755b723a9 100755 --- a/gnattools/configure +++ b/gnattools/configure @@ -584,6 +584,7 @@ PACKAGE_URL= ac_unique_file="Makefile.in" ac_subst_vars='LTLIBOBJS LIBOBJS +default_gnattools_target warn_cflags OBJEXT EXEEXT @@ -595,7 +596,6 @@ CC ADA_CFLAGS EXTRA_GNATTOOLS TOOLS_TARGET_PAIRS -default_gnattools_target LN_S target_noncanonical host_noncanonical @@ -2050,15 +2050,6 @@ $as_echo "no, using $LN_S" >&6; } fi -# Determine what to build for 'gnattools' -if test $build = $target ; then - # Note that build=target is almost certainly the wrong test; FIXME - default_gnattools_target="gnattools-native" -else - default_gnattools_target="gnattools-cross" -fi - - # Target-specific stuff (defaults) TOOLS_TARGET_PAIRS= @@ -2134,6 +2125,8 @@ esac # From user or toplevel makefile. +# This is testing the CC passed from the toplevel Makefile, not the +# one we will select below. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2929,6 +2922,25 @@ if test "x$GCC" = "xyes"; then fi +# Determine what to build for 'gnattools'. Test after the above, +# because testing for CC sets the final value of cross_compiling, even +# if we end up using a different CC. We want to build +# gnattools-native when: (a) this is a native build, i.e., +# cross_compiling=no, otherwise we know we cannot run binaries +# produced by the toolchain used for the build, not even the binaries +# created within ../gcc/; (b) build and host are the same, otherwise +# this is to be regarded as a cross build environment even if it seems +# that we can run host binaries; (c) host and target are the same, +# otherwise the tools in ../gcc/ generate code for a different +# platform. If you change this test, be sure to adjust +# ../gcc/ada/gcc-interface/config-lang.in as well. +if test "x$cross_compiling/$build/$host" = "xno/$host/$target" ; then + default_gnattools_target="gnattools-native" +else + default_gnattools_target="gnattools-cross" +fi + + # Output: create a Makefile. ac_config_files="$ac_config_files Makefile" diff --git a/gnattools/configure.ac b/gnattools/configure.ac index 0a94224a5362..40d015ce8b0d 100644 --- a/gnattools/configure.ac +++ b/gnattools/configure.ac @@ -51,15 +51,6 @@ ACX_NONCANONICAL_TARGET # Need to pass this down for now :-P AC_PROG_LN_S -# Determine what to build for 'gnattools' -if test $build = $target ; then - # Note that build=target is almost certainly the wrong test; FIXME - default_gnattools_target="gnattools-native" -else - default_gnattools_target="gnattools-cross" -fi -AC_SUBST([default_gnattools_target]) - # Target-specific stuff (defaults) TOOLS_TARGET_PAIRS= AC_SUBST(TOOLS_TARGET_PAIRS) @@ -135,6 +126,8 @@ esac # From user or toplevel makefile. AC_SUBST(ADA_CFLAGS) +# This is testing the CC passed from the toplevel Makefile, not the +# one we will select below. AC_PROG_CC warn_cflags= if test "x$GCC" = "xyes"; then @@ -142,6 +135,25 @@ if test "x$GCC" = "xyes"; then fi AC_SUBST(warn_cflags) +# Determine what to build for 'gnattools'. Test after the above, +# because testing for CC sets the final value of cross_compiling, even +# if we end up using a different CC. We want to build +# gnattools-native when: (a) this is a native build, i.e., +# cross_compiling=no, otherwise we know we cannot run binaries +# produced by the toolchain used for the build, not even the binaries +# created within ../gcc/; (b) build and host are the same, otherwise +# this is to be regarded as a cross build environment even if it seems +# that we can run host binaries; (c) host and target are the same, +# otherwise the tools in ../gcc/ generate code for a different +# platform. If you change this test, be sure to adjust +# ../gcc/ada/gcc-interface/config-lang.in as well. +if test "x$cross_compiling/$build/$host" = "xno/$host/$target" ; then + default_gnattools_target="gnattools-native" +else + default_gnattools_target="gnattools-cross" +fi +AC_SUBST([default_gnattools_target]) + # Output: create a Makefile. AC_CONFIG_FILES([Makefile])