aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorEvan Klitzke <evan@eklitzke.org>2018-03-15 05:05:48 -0700
committerpracticalswift <practicalswift@users.noreply.github.com>2018-04-17 10:37:43 +0200
commit9e49db2426cd4508d9dd95c7461e107bab7fd7de (patch)
tree293a8b4baabcb34b6c6c36295598bf6bf2123b1f /configure.ac
parent07825088f9cfd8abece774b9d978c36ab90ce3d1 (diff)
Make --enable-debug to pick better options
Various changes: * Don't check $GCC and $GXX * Prefer -Og instead of -O0 * If -g3 isn't available, use -g This also incidentally fixes compiler warnings with GCC and glibc when using --enable-debug, as the old default values mixed poorly with the hardening flags.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac30
1 files changed, 20 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index b38e480f27..03e024128a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -243,14 +243,22 @@ AC_LANG_PUSH([C++])
AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""])
if test "x$enable_debug" = xyes; then
- CPPFLAGS="$CPPFLAGS -DDEBUG -DDEBUG_LOCKORDER"
- if test "x$GCC" = xyes; then
- CFLAGS="$CFLAGS -g3 -O0"
- fi
+ # Prefer -Og, fall back to -O0 if that is unavailable.
+ AX_CHECK_COMPILE_FLAG(
+ [-Og],
+ [[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
- CXXFLAGS="$CXXFLAGS -g3 -O0"
- fi
+ # Prefer -g3, fall back to -g if that is unavailable.
+ AX_CHECK_COMPILE_FLAG(
+ [-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
if test x$use_sanitizers != x; then
@@ -1276,6 +1284,8 @@ AC_SUBST(BITCOIN_CLI_NAME)
AC_SUBST(BITCOIN_TX_NAME)
AC_SUBST(RELDFLAGS)
+AC_SUBST(DEBUG_CPPFLAGS)
+AC_SUBST(DEBUG_CXXFLAGS)
AC_SUBST(ERROR_CXXFLAGS)
AC_SUBST(GPROF_CXXFLAGS)
AC_SUBST(GPROF_LDFLAGS)
@@ -1383,9 +1393,9 @@ echo " build os = $BUILD_OS"
echo
echo " CC = $CC"
echo " CFLAGS = $CFLAGS"
-echo " CPPFLAGS = $CPPFLAGS"
+echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS"
echo " CXX = $CXX"
-echo " CXXFLAGS = $CXXFLAGS"
-echo " LDFLAGS = $LDFLAGS"
+echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS"
+echo " LDFLAGS = $PTHREAD_CFLAGS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS"
echo " ARFLAGS = $ARFLAGS"
echo