]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
genmultilib: Fix sanity check
authorChristophe Lyon <christophe.lyon@arm.com>
Mon, 21 Nov 2022 11:12:14 +0000 (12:12 +0100)
committerChristophe Lyon <christophe.lyon@arm.com>
Mon, 21 Nov 2022 12:19:53 +0000 (13:19 +0100)
My previous patch to add a sanity check to genmultilib actually
checked the number of dirnames with the number of "sets of options"
rather than the number of options, thus breaking the build on some
targets.

To avoid duplicating once more the loop that constructs the sed
patterns, this patch checks that the current dirname/osdirname is not
empty in the existing loops.

Are there targets where:
if [ "$1" != "${opt}" ]; then
is "legally" executed with an empty $1? (and thus where this patch
would incorrectly trigger an error?)

Sorry for the breakage. Tested on aarch64 by adding an option to
t-aarch64 and no corresponding dirname, and on x86_64.

gcc/ChangeLog:

* genmultilib: Fix options and dirnames/osdirnames sanity check.

gcc/genmultilib

index b5f372c83581faa8a8f623c65febc7d7e71f0dd9..c0c271eddd60acab548d017a393a6a3e072b073b 100644 (file)
@@ -141,20 +141,6 @@ 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
@@ -264,6 +250,10 @@ if [ -n "${dirnames}" ]; then
     for opts in `echo ${set} | sed -e 's|/| |'g`; do
       patt="/"
       for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
+       if [ -z "$1" ]; then
+         echo 1>&2 "Error calling $0: No dirname for option: $opt"
+         exit 1
+       fi
         if [ "$1" != "${opt}" ]; then
           todirnames="${todirnames} -e s|/${opt}/|/${1}/|g"
          patt="${patt}${1}/"
@@ -320,6 +310,10 @@ if [ -n "${osdirnames}" ]; then
       for opts in `echo ${set} | sed -e 's|/| |'g`; do
         patt="/"
         for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
+       if [ -z "$1" ]; then
+         echo 1>&2 "Error calling $0: No osdirname for option: $opt"
+         exit 1
+       fi
           if [ "$1" != "${opt}" ]; then
             toosdirnames="${toosdirnames} -e s|/${opt}/|/${1}/|g"
            patt="${patt}${1}/"