diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9f7e5931217..fcabe2595f3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-06-27 Joseph Myers + + * genmultilib (combination_space): Remove variable. + Validate reuse rules against regular expression for any sequence + of multilib options in any order. + 2017-06-27 Michael Collison * config/aarch64/aarch64-simd.md (aarch64_combine): Directly diff --git a/gcc/genmultilib b/gcc/genmultilib index c8bcdf3935d..0767e68719e 100644 --- a/gcc/genmultilib +++ b/gcc/genmultilib @@ -186,8 +186,7 @@ fi EOF chmod +x tmpmultilib -combination_space=`initial=/ ./tmpmultilib ${options}` -combinations="$combination_space" +combinations=`initial=/ ./tmpmultilib ${options}` # If there exceptions, weed them out now if [ -n "${exceptions}" ]; then @@ -460,6 +459,15 @@ done echo "NULL" echo "};" +# Generate a regular expression to validate option combinations. +options_re= +for set in ${options}; do + for opt in `echo ${set} | sed -e 's_[/|]_ _g'`; do + options_re="${options_re}${options_re:+|}${opt}" + done +done +options_re="^/((${options_re})/)*\$" + # Output rules used for multilib reuse. echo "" echo "static const char *const multilib_reuse_raw[] = {" @@ -473,7 +481,7 @@ 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 - if expr "${combination_space} " : ".*/${copts}/.*" > /dev/null; then + if echo "/${copts}/" | grep -E "${options_re}" > /dev/null; then combo="/${combo}/" dirout=`./tmpmultilib3 "${combo}" "${todirnames}" "${toosdirnames}" "${enable_multilib}"` copts="/${copts}/"