gcc/configure: Properly remove -O flags from C[XX]FLAGS

PR bootstrap/117893
	* configure.ac: Use shell loop to remove -O flags.
	* configure: Regenerate.
This commit is contained in:
Andreas Schwab 2024-12-04 10:59:38 +01:00
parent 72a2380a30
commit 1783b20309
2 changed files with 40 additions and 8 deletions

26
gcc/configure vendored
View file

@ -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

View 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)