Page MenuHomePhabricator

Allow overriding default flags
ClosedPublic

Authored by Fabien on Jun 1 2020, 11:39.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Commits
rABCe1a3a76d286f: 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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Jun 1 2020, 11:39

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

This revision is now accepted and ready to land.Jun 1 2020, 21:58
This revision was automatically updated to reflect the committed changes.