Merge #13005: Make --enable-debug to pick better options

9e49db2 Make --enable-debug to pick better options (Evan Klitzke)

Pull request description:

  Cherry-picked (and rebased) 94189645e67f364c4445d62e2b00c282d885cbbf from the "up for grabs" PR: "[build] Make --enable-debug pick better options" (#12695).

  See previous review in #12695.

Tree-SHA512: a93cdadcf13e2ef8519acb1ce4f41ce95057a388347bb0a86a5c164dc7d0b0d14d4bb2a466082d5a100b8d50de65c605c40abaed555e8ea77c99e28800a34439
This commit is contained in:
Wladimir J. van der Laan 2018-05-14 15:27:46 +02:00
commit cb088b1461
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D
2 changed files with 22 additions and 12 deletions

View file

@ -243,14 +243,22 @@ AC_LANG_PUSH([C++])
AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""]) AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""])
if test "x$enable_debug" = xyes; then if test "x$enable_debug" = xyes; then
CPPFLAGS="$CPPFLAGS -DDEBUG -DDEBUG_LOCKORDER" # Prefer -Og, fall back to -O0 if that is unavailable.
if test "x$GCC" = xyes; then AX_CHECK_COMPILE_FLAG(
CFLAGS="$CFLAGS -g3 -O0" [-Og],
fi [[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -Og"]],
[AX_CHECK_COMPILE_FLAG([-O0],[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -O0"]],,[[$CXXFLAG_WERROR]])],
[[$CXXFLAG_WERROR]])
if test "x$GXX" = xyes; then # Prefer -g3, fall back to -g if that is unavailable.
CXXFLAGS="$CXXFLAGS -g3 -O0" AX_CHECK_COMPILE_FLAG(
fi [-g3],
[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g3"]],
[AX_CHECK_COMPILE_FLAG([-g],[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g"]],,[[$CXXFLAG_WERROR]])],
[[$CXXFLAG_WERROR]])
AX_CHECK_PREPROC_FLAG([-DDEBUG],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG"]],,[[$CXXFLAG_WERROR]])
AX_CHECK_PREPROC_FLAG([-DDEBUG_LOCKORDER],[[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DDEBUG_LOCKORDER"]],,[[$CXXFLAG_WERROR]])
fi fi
if test x$use_sanitizers != x; then if test x$use_sanitizers != x; then
@ -1272,6 +1280,8 @@ AC_SUBST(BITCOIN_CLI_NAME)
AC_SUBST(BITCOIN_TX_NAME) AC_SUBST(BITCOIN_TX_NAME)
AC_SUBST(RELDFLAGS) AC_SUBST(RELDFLAGS)
AC_SUBST(DEBUG_CPPFLAGS)
AC_SUBST(DEBUG_CXXFLAGS)
AC_SUBST(ERROR_CXXFLAGS) AC_SUBST(ERROR_CXXFLAGS)
AC_SUBST(GPROF_CXXFLAGS) AC_SUBST(GPROF_CXXFLAGS)
AC_SUBST(GPROF_LDFLAGS) AC_SUBST(GPROF_LDFLAGS)
@ -1380,9 +1390,9 @@ echo " build os = $BUILD_OS"
echo echo
echo " CC = $CC" echo " CC = $CC"
echo " CFLAGS = $CFLAGS" echo " CFLAGS = $CFLAGS"
echo " CPPFLAGS = $CPPFLAGS" echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS"
echo " CXX = $CXX" echo " CXX = $CXX"
echo " CXXFLAGS = $CXXFLAGS" echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS"
echo " LDFLAGS = $LDFLAGS" echo " LDFLAGS = $PTHREAD_CFLAGS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS"
echo " ARFLAGS = $ARFLAGS" echo " ARFLAGS = $ARFLAGS"
echo echo

View file

@ -5,8 +5,8 @@
DIST_SUBDIRS = secp256k1 univalue DIST_SUBDIRS = secp256k1 univalue
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS)
AM_CXXFLAGS = $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS)
AM_CPPFLAGS = $(HARDENED_CPPFLAGS) AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS)
AM_LIBTOOLFLAGS = --preserve-dup-deps AM_LIBTOOLFLAGS = --preserve-dup-deps
EXTRA_LIBRARIES = EXTRA_LIBRARIES =