From 613c34cd869e56dee2ea5fb701f05b07da7069c8 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Tue, 17 Dec 2019 12:34:26 +0000 Subject: [PATCH 1/4] Remove test in configure.ac because it doesn't have an effect --- configure.ac | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configure.ac b/configure.ac index 2a8db0a51c607..0a94f15501873 100644 --- a/configure.ac +++ b/configure.ac @@ -19,10 +19,6 @@ AC_PATH_TOOL(RANLIB, ranlib) AC_PATH_TOOL(STRIP, strip) AX_PROG_CC_FOR_BUILD -if test "x$CFLAGS" = "x"; then - CFLAGS="-g" -fi - AM_PROG_CC_C_O AC_PROG_CC_C89 From ecba8138ec163f5ad4c303df9f8744810a3dfc03 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Tue, 17 Dec 2019 12:37:48 +0000 Subject: [PATCH 2/4] Append instead of Prepend user-CFLAGS to default CFLAGS allowing the user to override default variables --- configure.ac | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 0a94f15501873..424f6efb20f6b 100644 --- a/configure.ac +++ b/configure.ac @@ -59,11 +59,11 @@ case $host_os in ;; esac -CFLAGS="$CFLAGS -W" +CFLAGS="-W $CFLAGS" warn_CFLAGS="-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings" saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $warn_CFLAGS" +CFLAGS="$warn_CFLAGS $CFLAGS" AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], [ AC_MSG_RESULT([yes]) ], @@ -72,7 +72,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], ]) saved_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS -fvisibility=hidden" +CFLAGS="-fvisibility=hidden $CFLAGS" AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], [ AC_MSG_RESULT([yes]) ], @@ -173,10 +173,10 @@ AC_CHECK_TYPES([__int128]) if test x"$enable_coverage" = x"yes"; then AC_DEFINE(COVERAGE, 1, [Define this symbol to compile out all VERIFY code]) - CFLAGS="$CFLAGS -O0 --coverage" - LDFLAGS="$LDFLAGS --coverage" + CFLAGS="-O0 --coverage $CFLAGS" + LDFLAGS="--coverage $LDFLAGS" else - CFLAGS="$CFLAGS -O3" + CFLAGS="-O3 $CFLAGS" fi if test x"$use_ecmult_static_precomputation" != x"no"; then @@ -194,7 +194,7 @@ if test x"$use_ecmult_static_precomputation" != x"no"; then warn_CFLAGS_FOR_BUILD="-Wall -Wextra -Wno-unused-function" saved_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $warn_CFLAGS_FOR_BUILD" + CFLAGS="$warn_CFLAGS_FOR_BUILD $CFLAGS" AC_MSG_CHECKING([if native ${CC_FOR_BUILD} supports ${warn_CFLAGS_FOR_BUILD}]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], [ AC_MSG_RESULT([yes]) ], From 83fb1bcef49b1c12ef349f62d90bfcc83f0f7398 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Tue, 17 Dec 2019 12:41:44 +0000 Subject: [PATCH 3/4] Remove -O2 from default CFLAGS because this would override the -O3 flag (see AC_PROG_CC in the Autoconf manual) --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index 424f6efb20f6b..a68ef9586951b 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,10 @@ AH_TOP([#ifndef LIBSECP256K1_CONFIG_H]) AH_TOP([#define LIBSECP256K1_CONFIG_H]) AH_BOTTOM([#endif /*LIBSECP256K1_CONFIG_H*/]) AM_INIT_AUTOMAKE([foreign subdir-objects]) + +# Set -g (but not -O2 because this would override -O3 which we're adding later) +# if CFLAGS are not already set (see PROG_CC in the Autoconf manual) +: ${CFLAGS="-g"} LT_INIT dnl make the compilation flags quiet unless V=1 is used From ca739cba238cdd7c513abfc719b0b0eb957c9458 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Wed, 19 Feb 2020 14:07:54 +0000 Subject: [PATCH 4/4] Compile with optimization flag -O2 by default instead of -O3 --- configure.ac | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index a68ef9586951b..1272262ad4261 100644 --- a/configure.ac +++ b/configure.ac @@ -8,8 +8,9 @@ AH_TOP([#define LIBSECP256K1_CONFIG_H]) AH_BOTTOM([#endif /*LIBSECP256K1_CONFIG_H*/]) AM_INIT_AUTOMAKE([foreign subdir-objects]) -# Set -g (but not -O2 because this would override -O3 which we're adding later) -# if CFLAGS are not already set (see PROG_CC in the Autoconf manual) +# Set -g if CFLAGS are not already set, which matches the default autoconf +# behavior (see PROG_CC in the Autoconf manual) with the exception that we don't +# set -O2 here because we set it in any case (see further down). : ${CFLAGS="-g"} LT_INIT @@ -180,7 +181,7 @@ if test x"$enable_coverage" = x"yes"; then CFLAGS="-O0 --coverage $CFLAGS" LDFLAGS="--coverage $LDFLAGS" else - CFLAGS="-O3 $CFLAGS" + CFLAGS="-O2 $CFLAGS" fi if test x"$use_ecmult_static_precomputation" != x"no"; then