From patchwork Wed Aug 10 15:51:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preudhomme X-Patchwork-Id: 657735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3s8bJ53Qfbz9stY for ; Thu, 11 Aug 2016 01:52:21 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=R9gx8kR2; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :references:subject:to:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=okV2Eh0xPgxuGgLLL II98wdnTApfb0cDj87dGVbDdtoGAal9hIBkY3viGKvLD/3X1+SCeMHfd6hrK4ipb LlQqia5zu8bptyaG1R44zgLDuTYWUuqGhO5/r8WFzX8u9IriILkd/EcoszGWrn2H ekxRNY59gUnldblWfYS1s6Ch6M= 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 :references:subject:to:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=zO4oDC69lIccJkQMXkCcIbG 1+tc=; b=R9gx8kR21c643frGIBk34e/moA7K6xXk+0d1qRJLhpd1JROKh5zRasK 1waeYWbuJXe5qZxw7Q0qPT1XhUkTBUozObbzjOKXKozPAoAUMEArQbogZuCKeh1I 6mgADpFnhChRPfgpk74rBOpttST8bwAAcFCNPil8ZCsbNKAE4Dbg= Received: (qmail 21035 invoked by alias); 10 Aug 2016 15:52:00 -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 20945 invoked by uid 89); 10 Aug 2016 15:51:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=optout, sk:multili, 2016-08-01, 20160801 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Aug 2016 15:51:49 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D4584BFB for ; Wed, 10 Aug 2016 08:53:15 -0700 (PDT) Received: from [10.2.206.52] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8B2FA3F487 for ; Wed, 10 Aug 2016 08:51:47 -0700 (PDT) References: <550c58e1-762d-e8ff-e89d-0efc7c4a0a49@foss.arm.com> Subject: Fwd: [PATCH] genmultilib: improve error reporting for MULTILIB_REUSE To: gcc-patches@gcc.gnu.org From: Thomas Preudhomme X-Forwarded-Message-Id: <550c58e1-762d-e8ff-e89d-0efc7c4a0a49@foss.arm.com> Message-ID: <38226b76-e1bf-7ddc-7f2b-13f7d7b6a440@foss.arm.com> Date: Wed, 10 Aug 2016 16:51:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <550c58e1-762d-e8ff-e89d-0efc7c4a0a49@foss.arm.com> X-IsSubscribed: yes Forwarding to gcc-patches which I forgot past patch #1 Hi, It was discovered while working on ARM's aprofile multilib Makefile fragment that some REUSE rules were mentioning on the RHS options not in MULTILIB_OPTIONS. This is not supposed to happen and leads to unexpected behavior: genmultilib will generate a rule that matches for any option not in MULTILIB_OPTIONS (eg. in the case of ARM, it would create a rule matching for -march=armv7-a -mfloat-abi=hard with any -mfpu option not in MULTILIB_OPTIONS). This patch (i) adds logic in genmultilib to detect this situation and give an error. It also make sure (ii) the error is visible by outputing it to standard error since standard output is redirected to multilib.h when invoking genmultilib. Finally, (iii) it documents the need to use options present in MULTILIB_OPTIONS while doing various small wording fixes. Patch is in attachment. ChangeLog entry is as follows: *** gcc/ChangeLog *** 2016-08-01 Thomas Preud'homme * doc/fragments.texi (MULTILIB_REUSE): Mention that only options in MULTILIB_OPTIONS should be used. Small wording fixes. * genmultilib: Memorize set of all option combinations in combination_space. Detect if RHS of MULTILIB_REUSE uses an option not found in MULTILIB_OPTIONS by checking if option set is listed in combination_space. Output new and existing error message to stderr. GCC and libgcc have been built with multilib for all targets supporting --with-multilib-list without error as follows: * --build=i386-linux-gnu --with-multilib-list=m32,m64,mx32 * --target=x86_64-linux-gnu --with-multilib-list=m32,m64,mx32 * --target=sh-none-elf --with-multilib-list=m1,m2,m2e,m3,m3e,m4,m4-single,m4a-single-only,m4al,m2a,m2a-single,m2a-single-only (lib1func failed to build with -nofpu variants due to unrecognized instructions) * --target=aarch64-none-elf --with-multilib-list=default * --target=arm-none-eabi --with-multilib-list=aprofile Is this ok for trunk? Best regards, Thomas diff --git a/gcc/doc/fragments.texi b/gcc/doc/fragments.texi index f4e6636fb9510c0da40f1956c1f40f8bc0e23510..b6d8541c8ca820fa732363a05221e2cd4d1251c2 100644 --- a/gcc/doc/fragments.texi +++ b/gcc/doc/fragments.texi @@ -156,15 +156,16 @@ variants. And for some targets it is better to reuse an existing multilib than to fall back to default multilib when there is no corresponding multilib. This can be done by adding reuse rules to @code{MULTILIB_REUSE}. -A reuse rule is comprised of two parts connected by equality sign. The left part -is option set used to build multilib and the right part is option set that will -reuse this multilib. The order of options in the left part matters and should be -same with those specified in @code{MULTILIB_REQUIRED} or aligned with order in -@code{MULTILIB_OPTIONS}. There is no such limitation for options in right part -as we don't build multilib from them. But the equality sign in both parts should -be replaced with period. - -The @code{MULTILIB_REUSE} is different from @code{MULTILIB_MATCHES} in that it +A reuse rule is comprised of two parts connected by equality sign. The left +part is the option set used to build multilib and the right part is the option +set that will reuse this multilib. Both part should only use options specified +in @code{MULTILIB_OPTIONS} and the equality signs found in options name should +be replaced with periods. The order of options in the left part matters and +should be same with those specified in @code{MULTILIB_REQUIRED} or aligned with +the order in @code{MULTILIB_OPTIONS}. There is no such limitation for options +in the right part as we don't build multilib from them. + +@code{MULTILIB_REUSE} is different from @code{MULTILIB_MATCHES} in that it sets up relations between two option sets rather than two options. Here is an example to demo how we reuse libraries built in Thumb mode for applications built in ARM mode: diff --git a/gcc/genmultilib b/gcc/genmultilib index 083259aa82ca085be7410faa92929eb429393f92..eb5f661a5fded65a44a725884f77bf2e46f3ab1a 100644 --- a/gcc/genmultilib +++ b/gcc/genmultilib @@ -186,7 +186,8 @@ fi EOF chmod +x tmpmultilib -combinations=`initial=/ ./tmpmultilib ${options}` +combination_space=`initial=/ ./tmpmultilib ${options}` +combinations="$combination_space" # If there exceptions, weed them out now if [ -n "${exceptions}" ]; then @@ -472,14 +473,19 @@ for rrule in ${multilib_reuse}; do # in this variable, it means no multilib will be built for current reuse # rule. Thus the reuse purpose specified by current rule is meaningless. if expr "${combinations} " : ".*/${combo}/.*" > /dev/null; then - combo="/${combo}/" - dirout=`./tmpmultilib3 "${combo}" "${todirnames}" "${toosdirnames}" "${enable_multilib}"` - copts="/${copts}/" - optout=`./tmpmultilib4 "${copts}" "${options}"` - # Output the line with all appropriate matches. - dirout="${dirout}" optout="${optout}" ./tmpmultilib2 + if expr "${combination_space} " : ".*/${copts}/.*" > /dev/null; then + combo="/${combo}/" + dirout=`./tmpmultilib3 "${combo}" "${todirnames}" "${toosdirnames}" "${enable_multilib}"` + copts="/${copts}/" + optout=`./tmpmultilib4 "${copts}" "${options}"` + # Output the line with all appropriate matches. + dirout="${dirout}" optout="${optout}" ./tmpmultilib2 + else + echo "The rule ${rrule} contains an option absent from MULTILIB_OPTIONS." >&2 + exit 1 + fi else - echo "The rule ${rrule} is trying to reuse nonexistent multilib." + echo "The rule ${rrule} is trying to reuse nonexistent multilib." >&2 exit 1 fi done