HomePhabricator

Allow overriding default flags

Description

Allow overriding default flags

Summary:

Right now, it's not easy to reduce the optimization level with CFLAGS
because configure overwrites any optimization flag with -O3. The
automake documentation states that:

    The reason ‘$(CPPFLAGS)’ appears after ‘$(AM_CPPFLAGS)’ or
‘$(mumble_CPPFLAGS)’ in the compile command is that users should always
have the last say.

and also that it's incorrect to redefine CFLAGS in the first place

    You should never redefine a user variable such as CPPFLAGS in
Makefile.am. [...] You should not add options to these user variables
within configure either, for the same reason

With this PR CFLAGS is still redefined, but user-provided flags appear
after the default CFLAGS which means that they override the default
flags (at least in clang and gcc). Otherwise, the default configuration
is not changed. This also means that if CFLAGS are defined by the user,
then -g is not added (which does not seem to make much sense). In order
to keep the -O3 despite the reordering we need to explicitly tell
autoconf to not append -O2 by setting the default to -g with :
${CFLAGS="-g"} as per the manual

Backport of secp256k1 PR700.

Test Plan:

make check
ninja check-secp256k1

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6309

Details

Provenance
Jonas Nick <jonasd.nick@gmail.com>Authored on Dec 17 2019, 12:34
FabienCommitted on Jun 2 2020, 08:34
FabienPushed on Jun 2 2020, 08:34
Reviewer
Restricted Project
Differential Revision
D6309: Allow overriding default flags
Parents
rABCb2531ebe4c9c: [CMAKE] Rename secp256k1 test targets
Branches
Unknown
Tags
Unknown