git: 773bb4c45cac - stable/13 - Use __freebsd_kprintf__ with GCC 12+ similar to clang.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 03 May 2023 00:29:26 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=773bb4c45cacfb2bd654cf3896f7875c5ee3f62c

commit 773bb4c45cacfb2bd654cf3896f7875c5ee3f62c
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-11-22 16:36:12 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-05-02 23:41:50 +0000

    Use __freebsd_kprintf__ with GCC 12+ similar to clang.
    
    (cherry picked from commit 5115511ed4941684bc82b8a3c4b95e9a8931b940)
---
 share/mk/bsd.sys.mk | 3 ++-
 sys/conf/kern.mk    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index cb4399610d0e..ad359727c32f 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -238,7 +238,8 @@ CWARNFLAGS+=	-Wno-system-headers
 .endif	# gcc
 
 # How to handle FreeBSD custom printf format specifiers.
-.if ${COMPILER_TYPE} == "clang"
+.if ${COMPILER_TYPE} == "clang" || \
+    (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120100)
 FORMAT_EXTENSIONS=	-D__printf__=__freebsd_kprintf__
 .else
 FORMAT_EXTENSIONS=	-fformat-extensions
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
index 87e788666efb..53eb49c95c4b 100644
--- a/sys/conf/kern.mk
+++ b/sys/conf/kern.mk
@@ -101,7 +101,8 @@ CWARNFLAGS+=	-Wno-format-zero-length
 # to be disabled.  WARNING: format checking is disabled in this case.
 .if ${MK_FORMAT_EXTENSIONS} == "no"
 FORMAT_EXTENSIONS=	-Wno-format
-.elif ${COMPILER_TYPE} == "clang"
+.elif ${COMPILER_TYPE} == "clang" || \
+    (${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120100)
 FORMAT_EXTENSIONS=	-D__printf__=__freebsd_kprintf__
 .else
 FORMAT_EXTENSIONS=	-fformat-extensions