From 6e98d6bf135f0fa29534428a296ea52d664ce4b2 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 19 Jun 2023 15:22:52 -0500 Subject: [PATCH] build: Make sure --disable-optimization works acinclude.m4 still adds -O2 and various FORTIFY_SOURCE flags, even if --disable-optimization is used during configure. Fix that. --- acinclude.m4 | 3 +-- configure.ac | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 77bf110a..5350d315 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -48,8 +48,7 @@ AC_DEFUN([AC_PROG_CC_UBSAN], [ AC_DEFUN([COMPILER_FLAGS], [ if (test "${CFLAGS}" = ""); then - CFLAGS="-Wall -O2 -fsigned-char -fno-exceptions" - CFLAGS+=" -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" + CFLAGS="-Wall -fsigned-char -fno-exceptions" fi if (test "$USE_MAINTAINER_MODE" = "yes"); then CFLAGS+=" -Werror -Wextra" diff --git a/configure.ac b/configure.ac index cb576a62..1d10f9df 100644 --- a/configure.ac +++ b/configure.ac @@ -37,10 +37,15 @@ LT_INIT([disable-static]) AC_ARG_ENABLE(optimization, AS_HELP_STRING([--disable-optimization], [disable code optimization through compiler]), [ if (test "${enableval}" = "no"); then - CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -O0" + CFLAGS="$CFLAGS -O0" fi ]) +if (test "${enable_optimization}" != "no"); then + CFLAGS="$CFLAGS -O2" + CFLAGS+=" -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" +fi + AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [enable compiling with debugging information]), [ if (test "${enableval}" = "yes" &&