@@ -143,9 +143,9 @@ AC_ARG_WITH([qrencode],
143
143
144
144
AC_ARG_ENABLE ( [ hardening] ,
145
145
[ AS_HELP_STRING ( [ --disable-hardening] ,
146
- [ do not attempt to harden the resulting executables (default is to harden)] ) ] ,
146
+ [ do not attempt to harden the resulting executables (default is to harden when possible )] ) ] ,
147
147
[ use_hardening=$enableval] ,
148
- [ use_hardening=yes ] )
148
+ [ use_hardening=auto ] )
149
149
150
150
AC_ARG_ENABLE ( [ reduce-exports] ,
151
151
[ AS_HELP_STRING ( [ --enable-reduce-exports] ,
@@ -214,6 +214,13 @@ AC_ARG_ENABLE([debug],
214
214
[ enable_debug=$enableval] ,
215
215
[ enable_debug=no] )
216
216
217
+ # Enable gprof profiling
218
+ AC_ARG_ENABLE ( [ gprof] ,
219
+ [ AS_HELP_STRING ( [ --enable-gprof] ,
220
+ [ use gprof profiling compiler flags (default is no)] ) ] ,
221
+ [ enable_gprof=$enableval] ,
222
+ [ enable_gprof=no] )
223
+
217
224
# Turn warnings into errors
218
225
AC_ARG_ENABLE ( [ werror] ,
219
226
[ AS_HELP_STRING ( [ --enable-werror] ,
@@ -553,12 +560,30 @@ else
553
560
AC_SEARCH_LIBS ( [ clock_gettime] ,[ rt] )
554
561
fi
555
562
563
+ if test "x$enable_gprof" = xyes; then
564
+ dnl -pg is incompatible with -pie. Since hardening and profiling together doesn't make sense,
565
+ dnl we simply make them mutually exclusive here. Additionally, hardened toolchains may force
566
+ dnl -pie by default, in which case it needs to be turned off with -no-pie.
567
+
568
+ if test x$use_hardening = xyes; then
569
+ AC_MSG_ERROR ( gprof profiling is not compatible with hardening. Reconfigure with -- disable-hardening or -- disable-gprof )
570
+ fi
571
+ use_hardening=no
572
+ AX_CHECK_COMPILE_FLAG ( [ -pg] ,[ GPROF_CXXFLAGS="-pg"] ,
573
+ [ AC_MSG_ERROR ( gprof profiling requested but not available ) ] , [ [ $CXXFLAG_WERROR] ] )
574
+
575
+ AX_CHECK_LINK_FLAG ( [ [ -no-pie] ] , [ GPROF_LDFLAGS="-no-pie"] )
576
+ AX_CHECK_LINK_FLAG ( [ [ -pg] ] ,[ GPROF_LDFLAGS="$GPROF_LDFLAGS -pg"] ,
577
+ [ AC_MSG_ERROR ( gprof profiling requested but not available ) ] , [ [ $GPROF_LDFLAGS] ] )
578
+ fi
579
+
556
580
if test x$TARGET_OS != xwindows; then
557
581
# All windows code is PIC, forcing it on just adds useless compile warnings
558
582
AX_CHECK_COMPILE_FLAG ( [ -fPIC] ,[ PIC_FLAGS="-fPIC"] )
559
583
fi
560
584
561
585
if test x$use_hardening != xno; then
586
+ use_hardening=yes
562
587
AX_CHECK_COMPILE_FLAG ( [ -Wstack-protector] ,[ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"] )
563
588
AX_CHECK_COMPILE_FLAG ( [ -fstack-protector-all] ,[ HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"] )
564
589
@@ -1237,6 +1262,8 @@ AC_SUBST(BITCOIN_TX_NAME)
1237
1262
1238
1263
AC_SUBST ( RELDFLAGS )
1239
1264
AC_SUBST ( ERROR_CXXFLAGS )
1265
+ AC_SUBST ( GPROF_CXXFLAGS )
1266
+ AC_SUBST ( GPROF_LDFLAGS )
1240
1267
AC_SUBST ( HARDENED_CXXFLAGS )
1241
1268
AC_SUBST ( HARDENED_CPPFLAGS )
1242
1269
AC_SUBST ( HARDENED_LDFLAGS )
@@ -1330,6 +1357,7 @@ echo " with bench = $use_bench"
1330
1357
echo " with upnp = $use_upnp"
1331
1358
echo " use asm = $use_asm"
1332
1359
echo " debug enabled = $enable_debug"
1360
+ echo " gprof enabled = $enable_gprof"
1333
1361
echo " werror = $enable_werror"
1334
1362
echo
1335
1363
echo " target os = $TARGET_OS"
0 commit comments