git: 3006f6df025f - main - Update -ftrivial-auto-var-init flags for clang >= 16

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Tue, 23 May 2023 17:49:00 UTC
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=3006f6df025f3afd0fb3cca1b820cdac1f1ed4c9

commit 3006f6df025f3afd0fb3cca1b820cdac1f1ed4c9
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-05-23 17:40:36 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-05-23 17:44:45 +0000

    Update -ftrivial-auto-var-init flags for clang >= 16
    
    As of clang 16, the -ftrivial-auto-var-init=zero option no longer needs
    -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
    to enable the option. Only add it for older clang versions.
    
    PR:             271047
    Reviewed by:    emaste
    MFC after:      3 days
    Differential Revision: https://reviews.freebsd.org/D40208
---
 share/mk/bsd.lib.mk  | 14 ++++++++------
 share/mk/bsd.prog.mk | 14 ++++++++------
 sys/conf/kern.mk     |  6 ++++--
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 8e5035f6db41..9a947b85bfe2 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -99,19 +99,21 @@ LDFLAGS+= -Wl,-zretpolineplt
 # Initialize stack variables on function entry
 .if ${MK_INIT_ALL_ZERO} == "yes"
 .if ${COMPILER_FEATURES:Minit-all}
-CFLAGS+= -ftrivial-auto-var-init=zero \
-    -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
-CXXFLAGS+= -ftrivial-auto-var-init=zero \
-    -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+CFLAGS+= -ftrivial-auto-var-init=zero
+CXXFLAGS+= -ftrivial-auto-var-init=zero
+.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 160000
+CFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+CXXFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+.endif
 .else
-.warning InitAll (zeros) requested but not support by compiler
+.warning InitAll (zeros) requested but not supported by compiler
 .endif
 .elif ${MK_INIT_ALL_PATTERN} == "yes"
 .if ${COMPILER_FEATURES:Minit-all}
 CFLAGS+= -ftrivial-auto-var-init=pattern
 CXXFLAGS+= -ftrivial-auto-var-init=pattern
 .else
-.warning InitAll (pattern) requested but not support by compiler
+.warning InitAll (pattern) requested but not supported by compiler
 .endif
 .endif
 
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
index de453564579d..6f1079944914 100644
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -72,19 +72,21 @@ LDFLAGS+= -Wl,-zretpolineplt
 # Initialize stack variables on function entry
 .if ${MK_INIT_ALL_ZERO} == "yes"
 .if ${COMPILER_FEATURES:Minit-all}
-CFLAGS+= -ftrivial-auto-var-init=zero \
-    -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
-CXXFLAGS+= -ftrivial-auto-var-init=zero \
-    -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+CFLAGS+= -ftrivial-auto-var-init=zero
+CXXFLAGS+= -ftrivial-auto-var-init=zero
+.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 160000
+CFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+CXXFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+.endif
 .else
-.warning InitAll (zeros) requested but not support by compiler
+.warning InitAll (zeros) requested but not supported by compiler
 .endif
 .elif ${MK_INIT_ALL_PATTERN} == "yes"
 .if ${COMPILER_FEATURES:Minit-all}
 CFLAGS+= -ftrivial-auto-var-init=pattern
 CXXFLAGS+= -ftrivial-auto-var-init=pattern
 .else
-.warning InitAll (pattern) requested but not support by compiler
+.warning InitAll (pattern) requested but not supported by compiler
 .endif
 .endif
 
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
index 245f81e6ed71..b6646f6c35ca 100644
--- a/sys/conf/kern.mk
+++ b/sys/conf/kern.mk
@@ -252,8 +252,10 @@ CFLAGS+=	-mretpoline
 #
 .if ${MK_INIT_ALL_ZERO} == "yes"
 .if ${COMPILER_FEATURES:Minit-all}
-CFLAGS+= -ftrivial-auto-var-init=zero \
-    -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+CFLAGS+= -ftrivial-auto-var-init=zero
+.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 160000
+CFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
+.endif
 .else
 .warning InitAll (zeros) requested but not support by compiler
 .endif