The _FORTIFY_SOURCE macro is enabled by default when hardening is enabled, but it requires optimization in order to be used. Since we disable all optimization with --enable-debug, this macro doesn't actually do anything and instead just causes a lot of warnings to be printed. This PR explicitly disables _FORTIFY_SOURCE so that these useless warnings aren't printed.
Disable _FORTIFY_SOURCE when enable-debug #17033
pull achow101 wants to merge 1 commits into bitcoin:master from achow101:fix-fortify changing 1 files +10 −5-
achow101 commented at 11:58 PM on October 2, 2019: member
- fanquake added the label Build system on Oct 3, 2019
-
laanwj commented at 3:00 AM on October 3, 2019: member
I disagree with this, hardening should never be automatically disabled. Things such as stack cookies do not interfere with debugging at all, and if they do that's a bug that needs to be solved, it should be the default to debug as closely to the original code as possible.
If this particular hardening feature really interferes with debugging then disable that, not all hardening features.
- achow101 force-pushed on Oct 3, 2019
- achow101 renamed this:
Disable hardening when enable-debug
Disable _FORTIFY_SOURCE when enable-debug
on Oct 3, 2019 -
achow101 commented at 4:16 PM on October 3, 2019: member
I've changed this to just disable
_FORTIFY_SOURCEwhen--enable-debug. It appears that it doesn't do anything with optimization level 0 (as we do for--enable-debug) except print that warning. -
in configure.ac:755 in 637df834b8 outdated
748 | @@ -749,12 +749,14 @@ if test x$use_hardening != xno; then 749 | AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"]) 750 | AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"]) 751 | 752 | - AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[ 753 | - AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[ 754 | - HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE" 755 | + if test x$enable_debug != xyes; then
laanwj commented at 5:38 AM on October 4, 2019:Maybe add a comment here (to explain the problem with debug here)
achow101 commented at 6:22 PM on October 7, 2019:Done
44f7a8d7a7Disable _FORTIFY_SOURCE when enable-debug
Since enable-debug disables optimization entirely, _FORTIFY_SOURCE does nothing as it requires some kind of optimization enabled. It instead produces a bunch of useless warnings. So explicitly disable it when enable-debug so that those warnings are not produced.
achow101 force-pushed on Oct 7, 2019laanwj commented at 8:27 AM on October 8, 2019: memberThanks. ACK 44f7a8d7a774f82417106c452d793e6f091bc23e
laanwj requested review from dongcarl on Oct 8, 2019laanwj requested review from theuni on Oct 8, 2019laanwj referenced this in commit ee47461ea5 on Oct 15, 2019laanwj merged this on Oct 15, 2019laanwj closed this on Oct 15, 2019sidhujag referenced this in commit 82b285b411 on Oct 16, 2019luke-jr commented at 2:03 PM on November 4, 2019: memberPosthumourous Concept NACK: --enable-debug can be used with explicitly-specified
-Onoptions, and that_FORTIFY_SOURCEcurrently does nothing for-O0is a compiler detail, not inherent.MarkLTZ referenced this in commit 3b69b903d9 on Apr 6, 2020deadalnix referenced this in commit fc846cd036 on May 25, 2020PastaPastaPasta referenced this in commit ef2c36a0d8 on Jun 27, 2021PastaPastaPasta referenced this in commit 377a7b72fd on Jun 28, 2021PastaPastaPasta referenced this in commit 0fb153c3a0 on Jun 29, 2021PastaPastaPasta referenced this in commit 90b5c9cf54 on Jul 1, 2021PastaPastaPasta referenced this in commit e9615df7bc on Jul 1, 2021PastaPastaPasta referenced this in commit 4065f1cf68 on Jul 12, 2021PastaPastaPasta referenced this in commit a5779c2f8f on Jul 13, 2021PastaPastaPasta referenced this in commit a5d5bc5ecf on Jul 13, 2021MarcoFalke locked this on Dec 16, 2021
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 00:14 UTC
More mirrored repositories can be found on mirror.b10c.me