]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PATCH] gcc: configure: Fix the optimization flags cleanup
authorSlava Barinov <v.barinov@samsung.com>
Sun, 1 Dec 2024 18:59:13 +0000 (11:59 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Sun, 1 Dec 2024 18:59:13 +0000 (11:59 -0700)
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

gcc/configure
gcc/configure.ac

index d21b33e2b6c0a910bc70efadfd037bb85a6587a9..e7f85b78ad992ed457370accfe92ff4ca244b71f 100755 (executable)
@@ -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
 
 
index b1b21cf4d7b2ce9d6412714e675589fab11b44fd..a6c650c8f3a9a52f68930b55e9a16436d558dd3d 100644 (file)
@@ -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)