]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/configure: Properly remove -O flags from C[XX]FLAGS
authorAndreas Schwab <schwab@suse.de>
Wed, 4 Dec 2024 09:59:38 +0000 (10:59 +0100)
committerAndreas Schwab <schwab@suse.de>
Wed, 4 Dec 2024 11:13:52 +0000 (12:13 +0100)
PR bootstrap/117893
* configure.ac: Use shell loop to remove -O flags.
* configure: Regenerate.

gcc/configure
gcc/configure.ac

index e7f85b78ad992ed457370accfe92ff4ca244b71f..2754293d661ce0846d5bcb89381993ca691815b4 100755 (executable)
@@ -5473,12 +5473,28 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
 
-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+# Remove all -O flags: for historical reasons, unless bootstrapping we prefer
 # optimizations to be activated explicitly by the toplevel.
 case "$CC" in
   */prev-gcc/xgcc*) ;;
-  *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[       ]//" -e "s/-O[gs][      ]//" -e "s/[^,]-O[0-9]*[        ]//" `
-     CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[   ]//" -e "s/-O[gs][      ]//" -e "s/[^,]-O[0-9]*[        ]//" ` ;;
+  *)
+    new_CFLAGS=
+    for flag in $CFLAGS; do
+      case $flag in
+       -O*) ;;
+       *) new_CFLAGS="$new_CFLAGS $flag" ;;
+      esac
+    done
+    CFLAGS=$new_CFLAGS
+    new_CXXFLAGS=
+    for flag in $CXXFLAGS; do
+      case $flag in
+       -O*) ;;
+       *) new_CXXFLAGS="$new_CXXFLAGS $flag" ;;
+      esac
+    done
+    CXXFLAGS=$new_CXXFLAGS
+    ;;
 esac
 
 
@@ -21461,7 +21477,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21464 "configure"
+#line 21480 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21567,7 +21583,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21570 "configure"
+#line 21586 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
index e9bddc6db21f2db52c457bed74de2253b99c614a..ed8d9596668bb6ef711b50eaf1176a003294ca79 100644 (file)
@@ -463,12 +463,28 @@ ACX_PROG_GDC([-I"$srcdir"/d])
 # Do configure tests with the C++ compiler, since that's what we build with.
 AC_LANG(C++)
 
-# Remove the -O2: for historical reasons, unless bootstrapping we prefer
+# Remove all -O flags: for historical reasons, unless bootstrapping we prefer
 # optimizations to be activated explicitly by the toplevel.
 case "$CC" in
   */prev-gcc/xgcc*) ;;
-  *) CFLAGS=`echo "$CFLAGS " | sed -e "s/-Ofast[[      ]]//" -e "s/-O[[gs]][[  ]]//" -e "s/[[^,]]-O[[0-9]]*[[  ]]//" `
-     CXXFLAGS=`echo "$CXXFLAGS " | sed -e "s/-Ofast[[  ]]//" -e "s/-O[[gs]][[  ]]//" -e "s/[[^,]]-O[[0-9]]*[[  ]]//" ` ;;
+  *)
+    new_CFLAGS=
+    for flag in $CFLAGS; do
+      case $flag in
+       -O*) ;;
+       *) new_CFLAGS="$new_CFLAGS $flag" ;;
+      esac
+    done
+    CFLAGS=$new_CFLAGS
+    new_CXXFLAGS=
+    for flag in $CXXFLAGS; do
+      case $flag in
+       -O*) ;;
+       *) new_CXXFLAGS="$new_CXXFLAGS $flag" ;;
+      esac
+    done
+    CXXFLAGS=$new_CXXFLAGS
+    ;;
 esac
 AC_SUBST(CFLAGS)
 AC_SUBST(CXXFLAGS)