From a3996fe38c4746a2996854cde7039727bf69a134 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 1 Mar 2026 13:04:27 +0100 Subject: [PATCH] guard some hardening flag for gcc < 12 --- Makefile.defs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile.defs b/Makefile.defs index cffe9eee0..8cfcce10e 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -170,7 +170,18 @@ endif ifneq ($(NOHARDENING),1) # Manual equivalents of -fhardened to avoid g++: warning: linker hardening options not enabled by ‘-fhardened’ because other link options were specified on the command line DEFCFLAGS += \ - -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -ftrivial-auto-var-init=zero + -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong + + ifeq ($(DETECTED_COMPILER), clang) + ifeq ($(shell expr $(CC_VERSION) \>= 16), 1) + DEFCFLAGS += -ftrivial-auto-var-init=zero + endif + else + ifeq ($(shell expr $(CC_VERSION) \>= 12), 1) + DEFCFLAGS += -ftrivial-auto-var-init=zero + endif + endif + ifndef IS_WINDOWS ifndef IS_DARWIN ifeq ($(ARCH),x86_64)