https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117893
Bug ID: 117893 Summary: gcc configure failed Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: deminhan at gcc dot gnu.org Target Milestone: --- This commit 721a38add973a937b4b60f05cfa17958e892ad27 results in gcc configure fail. when set CFLAGS="-w -O0 -g3" for example, it's converted to CFLAG="-w-g3" and report unrecognized option. [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'. 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