aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2024-12-04 10:59:38 +0100
committerAndreas Schwab <schwab@suse.de>2024-12-04 12:13:52 +0100
commit1783b2030905567d1b89ccc5e674699619f159e5 (patch)
tree5063409dff520cdc2767467951dac8e897497689 /gcc
parent72a2380a306a1c3883cb7e4f99253522bc265af0 (diff)
downloadgcc-1783b2030905567d1b89ccc5e674699619f159e5.zip
gcc-1783b2030905567d1b89ccc5e674699619f159e5.tar.gz
gcc-1783b2030905567d1b89ccc5e674699619f159e5.tar.bz2
gcc/configure: Properly remove -O flags from C[XX]FLAGS
PR bootstrap/117893 * configure.ac: Use shell loop to remove -O flags. * configure: Regenerate.
Diffstat (limited to 'gcc')
-rwxr-xr-xgcc/configure26
-rw-r--r--gcc/configure.ac22
2 files changed, 40 insertions, 8 deletions
diff --git a/gcc/configure b/gcc/configure
index e7f85b7..2754293 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -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
diff --git a/gcc/configure.ac b/gcc/configure.ac
index e9bddc6..ed8d959 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -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)