git: 9374af1b21e2 - stable/13 - Update -ftrivial-auto-var-init flags for clang >= 16
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 26 May 2023 08:48:08 UTC
The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=9374af1b21e2b87e44050569ad9779d7146467ce commit 9374af1b21e2b87e44050569ad9779d7146467ce Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2023-05-23 17:40:36 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2023-05-26 08:42:24 +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 (cherry picked from commit 3006f6df025f3afd0fb3cca1b820cdac1f1ed4c9) --- 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 684a3df108fa..5cd5663e1ca7 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -95,19 +95,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 a55c2fd103fd..3b9b3277a241 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -70,19 +70,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 25c6ad8d87ac..a79cc5a5ed60 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -266,8 +266,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