From 0cb88d62604202cdeea6a2ed1b36b84b7fdd4bbf Mon Sep 17 00:00:00 2001 From: Lukas Sismis Date: Sat, 7 Mar 2026 17:07:24 +0100 Subject: [PATCH] configure: move -march=native flag insertion at the end When libraries add their own -march flags to CFLAGS, let them. But if -march=native should be added (it should by default), add it as the last -march flag to "win". This ensures, that even if a library brings their own minimal -march, it will not downgrade the instruction set for the whole Suricata. This happened with DPDK which, when enabled, downgraded the instruction set to -march=corei7 or -march=haswell. When building packages with --disable-gccmarch-native, the instruction set is auto-upgraded to instruction set requested by libraries. E.g. from RPM builds: `CFLAGS="-march=x86_64" ./configure --enable-dpdk` upgrades instruction set to DPDK's corei7 architecture. Ticket: 8169 --- configure.ac | 55 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/configure.ac b/configure.ac index 899f93181e..8ee06225dd 100644 --- a/configure.ac +++ b/configure.ac @@ -439,33 +439,6 @@ CFLAGS="${CFLAGS} -pg" ]) - #enable gcc march=native gcc 4.2 or later - AC_ARG_ENABLE(gccmarch_native, - AS_HELP_STRING([--enable-gccmarch-native], [Enable gcc march=native gcc 4.2 and later only]),[enable_gccmarch_native=$enableval],[enable_gccmarch_native=yes]) - AS_IF([test "x$enable_gccmarch_native" = "xyes"], [ - case "$host" in - *powerpc*) - ;; - *) - OFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -march=native" - AC_MSG_CHECKING([checking if $CC supports -march=native]) - AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include ]])], - [ - AC_MSG_RESULT([yes]) - OPTIMIZATION_CFLAGS="-march=native" - AC_SUBST(OPTIMIZATION_CFLAGS) - ], - [ - AC_MSG_RESULT([no]) - CFLAGS="$OFLAGS" - enable_gccmarch_native=no - ] - ) - ;; - esac - ]) - # options @@ -2425,6 +2398,34 @@ return 0; AM_CONDITIONAL([HAS_FUZZLDFLAGS], [test "x$has_sanitizefuzzer" = "xyes"]) +#enable gcc march=native gcc 4.2 or later + AC_ARG_ENABLE(gccmarch_native, + AS_HELP_STRING([--enable-gccmarch-native], [Enable gcc march=native gcc 4.2 and later only]),[enable_gccmarch_native=$enableval],[enable_gccmarch_native=yes]) + AS_IF([test "x$enable_gccmarch_native" = "xyes"], [ + case "$host" in + *powerpc*) + ;; + *) + OFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -march=native" + AC_MSG_CHECKING([checking if $CC supports -march=native]) + AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include ]])], + [ + AC_MSG_RESULT([yes]) + OPTIMIZATION_CFLAGS="-march=native" + AC_SUBST(OPTIMIZATION_CFLAGS) + ], + [ + AC_MSG_RESULT([no]) + CFLAGS="$OFLAGS" + enable_gccmarch_native=no + ] + ) + ;; + esac + ]) + + # get git revision and last commit date AC_PATH_PROG(HAVE_GIT_CMD, git, "no") if test "$HAVE_GIT_CMD" != "no"; then