From: Slava Barinov Date: Sun, 1 Dec 2024 18:59:13 +0000 (-0700) Subject: [PATCH] gcc: configure: Fix the optimization flags cleanup X-Git-Tag: basepoints/gcc-16~3700 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=721a38add973a937b4b60f05cfa17958e892ad27;p=thirdparty%2Fgcc.git [PATCH] gcc: configure: Fix the optimization flags cleanup Currently sed command in flag cleanup removes all the -O[0-9] flags, ignoring the context. This leads to issues when the optimization flags is passed to linker: CFLAGS="-Os -Wl,-O1 -Wl,--hash-style=gnu" is converted into CFLAGS="-Os -Wl,-Wl,--hash-style=gnu" Which leads to configure failure with ld: unrecognized option '-Wl,-Wl'. gcc/ * configure.ac: Only remove -O[0-9] if not preceded with comma * configure: Regenerated --- diff --git a/gcc/configure b/gcc/configure index d21b33e2b6c0..e7f85b78ad99 100755 --- a/gcc/configure +++ b/gcc/configure @@ -5477,8 +5477,8 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # 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]*[ ]//" ` ;; + *) 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]*[ ]//" ` ;; esac diff --git a/gcc/configure.ac b/gcc/configure.ac index b1b21cf4d7b2..a6c650c8f3a9 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -467,8 +467,8 @@ AC_LANG(C++) # 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]]*[[ ]]//" ` ;; + *) 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]]*[[ ]]//" ` ;; esac AC_SUBST(CFLAGS) AC_SUBST(CXXFLAGS)