@@ -148,9 +148,9 @@ AC_ARG_WITH([qrencode],
148
148
149
149
AC_ARG_ENABLE ( [ hardening] ,
150
150
[ AS_HELP_STRING ( [ --disable-hardening] ,
151
- [ do not attempt to harden the resulting executables (default is to harden)] ) ] ,
151
+ [ do not attempt to harden the resulting executables (default is to harden when possible )] ) ] ,
152
152
[ use_hardening=$enableval] ,
153
- [ use_hardening=yes ] )
153
+ [ use_hardening=auto ] )
154
154
155
155
AC_ARG_ENABLE ( [ reduce-exports] ,
156
156
[ AS_HELP_STRING ( [ --enable-reduce-exports] ,
@@ -219,6 +219,13 @@ AC_ARG_ENABLE([debug],
219
219
[ enable_debug=$enableval] ,
220
220
[ enable_debug=no] )
221
221
222
+ # Enable gprof profiling
223
+ AC_ARG_ENABLE ( [ gprof] ,
224
+ [ AS_HELP_STRING ( [ --enable-gprof] ,
225
+ [ use gprof profiling compiler flags (default is no)] ) ] ,
226
+ [ enable_gprof=$enableval] ,
227
+ [ enable_gprof=no] )
228
+
222
229
# Turn warnings into errors
223
230
AC_ARG_ENABLE ( [ werror] ,
224
231
[ AS_HELP_STRING ( [ --enable-werror] ,
@@ -558,12 +565,30 @@ else
558
565
AC_SEARCH_LIBS ( [ clock_gettime] ,[ rt] )
559
566
fi
560
567
568
+ if test "x$enable_gprof" = xyes; then
569
+ dnl -pg is incompatible with -pie. Since hardening and profiling together doesn't make sense,
570
+ dnl we simply make them mutually exclusive here. Additionally, hardened toolchains may force
571
+ dnl -pie by default, in which case it needs to be turned off with -no-pie.
572
+
573
+ if test x$use_hardening = xyes; then
574
+ AC_MSG_ERROR ( gprof profiling is not compatible with hardening. Reconfigure with -- disable-hardening or -- disable-gprof )
575
+ fi
576
+ use_hardening=no
577
+ AX_CHECK_COMPILE_FLAG ( [ -pg] ,[ GPROF_CXXFLAGS="-pg"] ,
578
+ [ AC_MSG_ERROR ( gprof profiling requested but not available ) ] , [ [ $CXXFLAG_WERROR] ] )
579
+
580
+ AX_CHECK_LINK_FLAG ( [ [ -no-pie] ] , [ GPROF_LDFLAGS="-no-pie"] )
581
+ AX_CHECK_LINK_FLAG ( [ [ -pg] ] ,[ GPROF_LDFLAGS="$GPROF_LDFLAGS -pg"] ,
582
+ [ AC_MSG_ERROR ( gprof profiling requested but not available ) ] , [ [ $GPROF_LDFLAGS] ] )
583
+ fi
584
+
561
585
if test x$TARGET_OS != xwindows; then
562
586
# All windows code is PIC, forcing it on just adds useless compile warnings
563
587
AX_CHECK_COMPILE_FLAG ( [ -fPIC] ,[ PIC_FLAGS="-fPIC"] )
564
588
fi
565
589
566
590
if test x$use_hardening != xno; then
591
+ use_hardening=yes
567
592
AX_CHECK_COMPILE_FLAG ( [ -Wstack-protector] ,[ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"] )
568
593
AX_CHECK_COMPILE_FLAG ( [ -fstack-protector-all] ,[ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"] )
569
594
@@ -1242,6 +1267,8 @@ AC_SUBST(BITCOIN_TX_NAME)
1242
1267
1243
1268
AC_SUBST ( RELDFLAGS )
1244
1269
AC_SUBST ( ERROR_CXXFLAGS )
1270
+ AC_SUBST ( GPROF_CXXFLAGS )
1271
+ AC_SUBST ( GPROF_LDFLAGS )
1245
1272
AC_SUBST ( HARDENED_CXXFLAGS )
1246
1273
AC_SUBST ( HARDENED_CPPFLAGS )
1247
1274
AC_SUBST ( HARDENED_LDFLAGS )
@@ -1335,6 +1362,7 @@ echo " with bench = $use_bench"
1335
1362
echo " with upnp = $use_upnp"
1336
1363
echo " use asm = $use_asm"
1337
1364
echo " debug enabled = $enable_debug"
1365
+ echo " gprof enabled = $enable_gprof"
1338
1366
echo " werror = $enable_werror"
1339
1367
echo
1340
1368
echo " target os = $TARGET_OS"
0 commit comments