diff --git a/gcc/configure b/gcc/configure index e7f85b78ad992ed457370accfe92ff4ca244b71f..2754293d661ce0846d5bcb89381993ca691815b4 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 e9bddc6db21f2db52c457bed74de2253b99c614a..ed8d9596668bb6ef711b50eaf1176a003294ca79 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)