aboutsummaryrefslogtreecommitdiff
path: root/gcc/config.gcc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2019-07-26 13:13:48 +0000
committerTamar Christina <tnfchris@gcc.gnu.org>2019-07-26 13:13:48 +0000
commit3644cadf6a9d5a5cd8e83b0123316cf184fa4e3e (patch)
tree16d58da2e9d42bb99ef86c2625cdcf4161f5f0cb /gcc/config.gcc
parent8f5331b25250d488910f62120f6b268486e99fbf (diff)
downloadgcc-3644cadf6a9d5a5cd8e83b0123316cf184fa4e3e.zip
gcc-3644cadf6a9d5a5cd8e83b0123316cf184fa4e3e.tar.gz
gcc-3644cadf6a9d5a5cd8e83b0123316cf184fa4e3e.tar.bz2
AArch64: Make processing less fragile in config.gcc
Due to config.gcc all the options need to be on one line because of the grep lines which would select only the first line of the option. This causes it not to select the right bits on options that are spread over multiple lines when the --with-arch configure option is used. The issue happens silently and you just get a compiler with an incorrect set of default flags. The current rules are quite rigid: 1) No space between the AARCH64_OPT_EXTENSION and the opening (. 2) No space between the opening ( and the extension name. 3) No space after the extension name before the ,. 4) Spaces are only allowed after a , and around |. This patch makes this a lot less fragile by using the C pre-processor to flatten the list and then provides much more flexible regex using group matching to process the options instead of string replacement. This removes all the restrictions above and makes the code a bit more readable. gcc/ChangeLog: PR target/89517 * config.gcc: Relax parsing of AARCH64_OPT_EXTENSION. * config/aarch64/aarch64-option-extensions.def: Add new comments and restore easier to read options. From-SVN: r273827
Diffstat (limited to 'gcc/config.gcc')
-rw-r--r--gcc/config.gcc46
1 files changed, 27 insertions, 19 deletions
diff --git a/gcc/config.gcc b/gcc/config.gcc
index dfff112..caab0a4 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3902,32 +3902,40 @@ case "${target}" in
sed -e 's/,.*$//'`
fi
+ # Use the pre-processor to strip flatten the options.
+ # This makes the format less rigid than if we use
+ # grep and sed directly here.
+ opt_macro="AARCH64_OPT_EXTENSION(A, B, C, D, E, F)=A, B, C, D, E, F"
+ options_parsed="`$ac_cv_prog_CPP -D"$opt_macro" -x c \
+ ${srcdir}/config/aarch64/aarch64-option-extensions.def`"
+
+ # Match one element inside AARCH64_OPT_EXTENSION, we
+ # consume anything that's not a ,.
+ elem="[ ]*\([^,]\+\)[ ]*"
+
+ # Repeat the pattern for the number of entries in the
+ # AARCH64_OPT_EXTENSION, currently 6 times.
+ sed_patt="^$elem,$elem,$elem,$elem,$elem,$elem"
+
while [ x"$ext_val" != x ]
do
ext_val=`echo $ext_val | sed -e 's/\+//'`
ext=`echo $ext_val | sed -e 's/\+.*//'`
base_ext=`echo $ext | sed -e 's/^no//'`
+ opt_line=`echo -e "$options_parsed" | \
+ grep "^\"$base_ext\""`
if [ x"$base_ext" = x ] \
- || grep "^AARCH64_OPT_EXTENSION(\"$base_ext\"," \
- ${srcdir}/config/aarch64/aarch64-option-extensions.def \
- > /dev/null; then
-
- ext_canon=`grep "^AARCH64_OPT_EXTENSION(\"$base_ext\"," \
- ${srcdir}/config/aarch64/aarch64-option-extensions.def | \
- sed -e 's/^[^,]*,[ ]*//' | \
- sed -e 's/,.*$//'`
- ext_on=`grep "^AARCH64_OPT_EXTENSION(\"$base_ext\"," \
- ${srcdir}/config/aarch64/aarch64-option-extensions.def | \
- sed -e 's/^[^,]*,[ ]*[^,]*,[ ]*//' | \
- sed -e 's/,.*$//' | \
- sed -e 's/).*$//'`
- ext_off=`grep "^AARCH64_OPT_EXTENSION(\"$base_ext\"," \
- ${srcdir}/config/aarch64/aarch64-option-extensions.def | \
- sed -e 's/^[^,]*,[ ]*[^,]*,[ ]*[^,]*,[ ]*//' | \
- sed -e 's/,.*$//' | \
- sed -e 's/).*$//'`
-
+ || [[ -n $opt_line ]]; then
+
+ # These regexp extract the elements based on
+ # their group match index in the regexp.
+ ext_canon=`echo -e "$opt_line" | \
+ sed -e "s/$sed_patt/\2/"`
+ ext_on=`echo -e "$opt_line" | \
+ sed -e "s/$sed_patt/\3/"`
+ ext_off=`echo -e "$opt_line" | \
+ sed -e "s/$sed_patt/\4/"`
if [ $ext = $base_ext ]; then
# Adding extension