* Makefile (GCC_INSTRUMENT): Since GCC 4.9 (2014), one can use both -fsanitize=undefined and -fsanitize=address. So replace -fsanitize-address-use-after-scope with -fsanitize=address. Replace -fstack-protector with -fstack-protector-strong, also introduced in GCC 4.9. Add -fsanitize=bounds-strict (GCC 6, 2016), -fstack-clash-protection (GCC 8, 2018), -fstrict-flex-arrays=3 (GCC 13, 2023), and -ftrivial-auto-var-init=pattern (GCC 12, 2022). Do not add -fhardened as it can fight against debugging. (GCC_DEBUG_FLAGS): Add -D_FORTIFY_SOURCE=3, introduced in GCC 12 (2022) + glibc 2.34 (2021). --- Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile index 63e901f5..ddbf8786 100644 --- a/Makefile +++ b/Makefile @@ -372,11 +372,14 @@ LDLIBS= # and POSIX.1-2024 or later (say in the year 2034). # # Select instrumentation via "make GCC_INSTRUMENT='whatever'". +# The default GCC_INSTRUMENT omits -fanalyzer, as it is quite slow +# and has too many false positives, e.g., GCC bugs 128788 and 128831. GCC_INSTRUMENT = \ - -fsanitize=undefined -fsanitize-address-use-after-scope \ - -fsanitize-trap=all -fstack-protector -# Omit -fanalyzer from GCC_DEBUG_FLAGS, as it makes GCC too slow. -GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 \ + -fsanitize=address -fsanitize=bounds-strict \ + -fsanitize=undefined -fsanitize-trap=all \ + -fstack-clash-protection -fstack-protector-strong \ + -fstrict-flex-arrays=3 -ftrivial-auto-var-init=pattern +GCC_DEBUG_FLAGS = -D_FORTIFY_SOURCE=3 -DGCC_LINT -g3 -O3 \ $(GCC_INSTRUMENT) \ -Wall -Wextra \ -Walloc-size-larger-than=100000 -Warray-bounds=2 \ -- 2.56.1
