Skip to content

Commit b924e1e

Browse files
build: Ensure that configure's compile checks default to -O2
Fixes #896.
1 parent 7939cd5 commit b924e1e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ aclocal.m4
2323
autom4te.cache/
2424
config.log
2525
config.status
26+
conftest*
2627
*.tar.gz
2728
*.la
2829
libtool

configure.ac

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ AH_TOP([#define LIBSECP256K1_CONFIG_H])
88
AH_BOTTOM([#endif /*LIBSECP256K1_CONFIG_H*/])
99
AM_INIT_AUTOMAKE([foreign subdir-objects])
1010

11-
# Set -g if CFLAGS are not already set, which matches the default autoconf
12-
# behavior (see PROG_CC in the Autoconf manual) with the exception that we don't
13-
# set -O2 here because we set it in any case (see further down).
14-
: ${CFLAGS="-g"}
1511
LT_INIT
1612

1713
# Make the compilation flags quiet unless V=1 is used.
@@ -84,7 +80,6 @@ esac
8480
# These executables are compiled from C source file for which our flags may not be appropriate,
8581
# e.g., -std=c89 flag has lead to undesirable warnings in the past.
8682
#
87-
# TODO We still touch the CFLAGS for --coverage and -O0/-O2.
8883
# TODO We should analogously not touch CPPFLAGS and LDFLAGS but currently there are no issues.
8984
AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
9085
# Try to append -Werror=unknown-warning-option to CFLAGS temporarily. Otherwise clang will
@@ -220,10 +215,14 @@ AM_CONDITIONAL([VALGRIND_ENABLED],[test "$enable_valgrind" = "yes"])
220215

221216
if test x"$enable_coverage" = x"yes"; then
222217
AC_DEFINE(COVERAGE, 1, [Define this symbol to compile out all VERIFY code])
223-
CFLAGS="-O0 --coverage $CFLAGS"
218+
SECP_CFLAGS="-O0 --coverage $SECP_CFLAGS"
224219
LDFLAGS="--coverage $LDFLAGS"
225220
else
226-
CFLAGS="-O2 $CFLAGS"
221+
# Most likely the CFLAGS already contain -O2 because that is autoconf's default.
222+
# We still add it here because passing it twice is not an issue, and handling
223+
# this case would just add unnecessary complexity (see #896).
224+
SECP_CFLAGS="-O2 $SECP_CFLAGS"
225+
SECP_CFLAGS_FOR_BUILD="-O2 $SECP_CFLAGS_FOR_BUILD"
227226
fi
228227

229228
if test x"$req_asm" = x"auto"; then

0 commit comments

Comments
 (0)