public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-4186] genmultilib: Add sanity check
@ 2022-11-21  9:21 Christophe Lyon
  0 siblings, 0 replies; only message in thread
From: Christophe Lyon @ 2022-11-21  9:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f0d3b6e384a68f8b58bc750f240a15cad92600cd

commit r13-4186-gf0d3b6e384a68f8b58bc750f240a15cad92600cd
Author: Christophe Lyon <christophe.lyon@arm.com>
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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-21  9:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21  9:21 [gcc r13-4186] genmultilib: Add sanity check Christophe Lyon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).