From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1652) id ECB5D3858417; Mon, 21 Nov 2022 09:21:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECB5D3858417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669022476; bh=nE29d2Pbj8dtLvef8wW+7pmYTHbgT6y0erXy5ZJ+z7s=; h=From:To:Subject:Date:From; b=hD1r2M3e8izQwqf4HbEnAB7G8zpWa6+Arpsw61VflE+db3FwVi+SojkzF8274hGEr AK1R/mrbAn2yDiTtOEc2vmw4MUH13cWEnj8bRr3jVStuYaSQJ4zbjYgN9KiShkP1H2 IeEQmRhoOdLo7FpgrmNtvGew95wQkcjdt+/F4608= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Christophe Lyon To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4186] genmultilib: Add sanity check X-Act-Checkin: gcc X-Git-Author: Christophe Lyon X-Git-Refname: refs/heads/master X-Git-Oldrev: 3d3b561fc3aaceb682ade756c3bb1ebb3f495231 X-Git-Newrev: f0d3b6e384a68f8b58bc750f240a15cad92600cd Message-Id: <20221121092116.ECB5D3858417@sourceware.org> Date: Mon, 21 Nov 2022 09:21:16 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f0d3b6e384a68f8b58bc750f240a15cad92600cd commit r13-4186-gf0d3b6e384a68f8b58bc750f240a15cad92600cd Author: Christophe Lyon Date: Thu Oct 27 08:50:53 2022 +0000 genmultilib: Add sanity check When a list of dirnames is provided to genmultilib, its length is expected to match the number of options. If this is not the case, the build fails later for reasons not obviously related to this mistake. This patch adds a sanity check to help diagnose such cases. Tested by adding an option to t-aarch64 and no corresponding dirname, with both bash and dash. v2: do not use arrays (bash feature). OK for trunk? gcc/ChangeLog: * genmultilib: Add sanity check. Diff: --- gcc/genmultilib | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gcc/genmultilib b/gcc/genmultilib index 1e387fb1589..b5f372c8358 100644 --- a/gcc/genmultilib +++ b/gcc/genmultilib @@ -141,6 +141,20 @@ multiarch=$9 multilib_reuse=${10} enable_multilib=${11} +# Sanity check: make sure we have as many dirnames as options +if [ -n "${dirnames}" ]; then + set x $options + nboptions=$# + set x $dirnames + nbdirnames=$# + if [ $nbdirnames -ne $nboptions ]; then + echo 1>&2 "Error calling $0: Number of dirnames ($nbdirnames) does not match number of options ($nboptions)" + echo 1>&2 "options: ${options}" + echo 1>&2 "dirnames: ${dirnames}" + exit 1 + fi +fi + echo "static const char *const multilib_raw[] = {" mkdir tmpmultilib.$$ || exit 1