Add build support for 'gprof' profiling.
This commit is contained in:
parent
d32528e733
commit
cfaac2a60f
3 changed files with 36 additions and 4 deletions
32
configure.ac
32
configure.ac
|
@ -143,9 +143,9 @@ AC_ARG_WITH([qrencode],
|
||||||
|
|
||||||
AC_ARG_ENABLE([hardening],
|
AC_ARG_ENABLE([hardening],
|
||||||
[AS_HELP_STRING([--disable-hardening],
|
[AS_HELP_STRING([--disable-hardening],
|
||||||
[do not attempt to harden the resulting executables (default is to harden)])],
|
[do not attempt to harden the resulting executables (default is to harden when possible)])],
|
||||||
[use_hardening=$enableval],
|
[use_hardening=$enableval],
|
||||||
[use_hardening=yes])
|
[use_hardening=auto])
|
||||||
|
|
||||||
AC_ARG_ENABLE([reduce-exports],
|
AC_ARG_ENABLE([reduce-exports],
|
||||||
[AS_HELP_STRING([--enable-reduce-exports],
|
[AS_HELP_STRING([--enable-reduce-exports],
|
||||||
|
@ -214,6 +214,13 @@ AC_ARG_ENABLE([debug],
|
||||||
[enable_debug=$enableval],
|
[enable_debug=$enableval],
|
||||||
[enable_debug=no])
|
[enable_debug=no])
|
||||||
|
|
||||||
|
# Enable gprof profiling
|
||||||
|
AC_ARG_ENABLE([gprof],
|
||||||
|
[AS_HELP_STRING([--enable-gprof],
|
||||||
|
[use gprof profiling compiler flags (default is no)])],
|
||||||
|
[enable_gprof=$enableval],
|
||||||
|
[enable_gprof=no])
|
||||||
|
|
||||||
# Turn warnings into errors
|
# Turn warnings into errors
|
||||||
AC_ARG_ENABLE([werror],
|
AC_ARG_ENABLE([werror],
|
||||||
[AS_HELP_STRING([--enable-werror],
|
[AS_HELP_STRING([--enable-werror],
|
||||||
|
@ -553,12 +560,30 @@ else
|
||||||
AC_SEARCH_LIBS([clock_gettime],[rt])
|
AC_SEARCH_LIBS([clock_gettime],[rt])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "x$enable_gprof" = xyes; then
|
||||||
|
dnl -pg is incompatible with -pie. Since hardening and profiling together doesn't make sense,
|
||||||
|
dnl we simply make them mutually exclusive here. Additionally, hardened toolchains may force
|
||||||
|
dnl -pie by default, in which case it needs to be turned off with -no-pie.
|
||||||
|
|
||||||
|
if test x$use_hardening = xyes; then
|
||||||
|
AC_MSG_ERROR(gprof profiling is not compatible with hardening. Reconfigure with --disable-hardening or --disable-gprof)
|
||||||
|
fi
|
||||||
|
use_hardening=no
|
||||||
|
AX_CHECK_COMPILE_FLAG([-pg],[GPROF_CXXFLAGS="-pg"],
|
||||||
|
[AC_MSG_ERROR(gprof profiling requested but not available)], [[$CXXFLAG_WERROR]])
|
||||||
|
|
||||||
|
AX_CHECK_LINK_FLAG([[-no-pie]], [GPROF_LDFLAGS="-no-pie"])
|
||||||
|
AX_CHECK_LINK_FLAG([[-pg]],[GPROF_LDFLAGS="$GPROF_LDFLAGS -pg"],
|
||||||
|
[AC_MSG_ERROR(gprof profiling requested but not available)], [[$GPROF_LDFLAGS]])
|
||||||
|
fi
|
||||||
|
|
||||||
if test x$TARGET_OS != xwindows; then
|
if test x$TARGET_OS != xwindows; then
|
||||||
# All windows code is PIC, forcing it on just adds useless compile warnings
|
# All windows code is PIC, forcing it on just adds useless compile warnings
|
||||||
AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
|
AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$use_hardening != xno; then
|
if test x$use_hardening != xno; then
|
||||||
|
use_hardening=yes
|
||||||
AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
|
AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
|
||||||
AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
|
AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
|
||||||
|
|
||||||
|
@ -1237,6 +1262,8 @@ AC_SUBST(BITCOIN_TX_NAME)
|
||||||
|
|
||||||
AC_SUBST(RELDFLAGS)
|
AC_SUBST(RELDFLAGS)
|
||||||
AC_SUBST(ERROR_CXXFLAGS)
|
AC_SUBST(ERROR_CXXFLAGS)
|
||||||
|
AC_SUBST(GPROF_CXXFLAGS)
|
||||||
|
AC_SUBST(GPROF_LDFLAGS)
|
||||||
AC_SUBST(HARDENED_CXXFLAGS)
|
AC_SUBST(HARDENED_CXXFLAGS)
|
||||||
AC_SUBST(HARDENED_CPPFLAGS)
|
AC_SUBST(HARDENED_CPPFLAGS)
|
||||||
AC_SUBST(HARDENED_LDFLAGS)
|
AC_SUBST(HARDENED_LDFLAGS)
|
||||||
|
@ -1330,6 +1357,7 @@ echo " with bench = $use_bench"
|
||||||
echo " with upnp = $use_upnp"
|
echo " with upnp = $use_upnp"
|
||||||
echo " use asm = $use_asm"
|
echo " use asm = $use_asm"
|
||||||
echo " debug enabled = $enable_debug"
|
echo " debug enabled = $enable_debug"
|
||||||
|
echo " gprof enabled = $enable_gprof"
|
||||||
echo " werror = $enable_werror"
|
echo " werror = $enable_werror"
|
||||||
echo
|
echo
|
||||||
echo " target os = $TARGET_OS"
|
echo " target os = $TARGET_OS"
|
||||||
|
|
|
@ -140,6 +140,10 @@ Development tips and tricks
|
||||||
Run configure with the --enable-debug option, then make. Or run configure with
|
Run configure with the --enable-debug option, then make. Or run configure with
|
||||||
CXXFLAGS="-g -ggdb -O0" or whatever debug flags you need.
|
CXXFLAGS="-g -ggdb -O0" or whatever debug flags you need.
|
||||||
|
|
||||||
|
**compiling for gprof profiling**
|
||||||
|
|
||||||
|
Run configure with the --enable-gprof option, then make.
|
||||||
|
|
||||||
**debug.log**
|
**debug.log**
|
||||||
|
|
||||||
If the code is behaving strangely, take a look in the debug.log file in the data directory;
|
If the code is behaving strangely, take a look in the debug.log file in the data directory;
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
DIST_SUBDIRS = secp256k1 univalue
|
DIST_SUBDIRS = secp256k1 univalue
|
||||||
|
|
||||||
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS)
|
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS)
|
||||||
AM_CXXFLAGS = $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS)
|
AM_CXXFLAGS = $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS)
|
||||||
AM_CPPFLAGS = $(HARDENED_CPPFLAGS)
|
AM_CPPFLAGS = $(HARDENED_CPPFLAGS)
|
||||||
EXTRA_LIBRARIES =
|
EXTRA_LIBRARIES =
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue