Module Name:    src
Committed By:   riastradh
Date:           Mon Jan 13 15:40:18 UTC 2025

Modified Files:
        src/share/mk: bsd.sys.mk
        src/sys/conf: Makefile.kern.inc

Log Message:
Switch from -std=gnu99 to -std=gnu11 by default.

This is needed for newer language syntax like u"foo" for UTF-16
string literals in UEFI.

As proposed on tech-kern:

https://mail-index.netbsd.org/tech-kern/2025/01/05/msg029919.html

Some commentators requested -std=c11 instead of -std=gnu11, but that
requires additional work -- some of it is a matter of providing asm
and typeof as aliases for __asm__ and __typeof__, but there's other
issues that need to be resolved too like PR toolchain/58969: use of
alloca is warning, not error, with -std=c11.  This is a smaller
incremental change.

PR toolchain/58962: clang build broken by C11 features with -std=gnu99


To generate a diff of this commit:
cvs rdiff -u -r1.316 -r1.317 src/share/mk/bsd.sys.mk
cvs rdiff -u -r1.301 -r1.302 src/sys/conf/Makefile.kern.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/mk/bsd.sys.mk
diff -u src/share/mk/bsd.sys.mk:1.316 src/share/mk/bsd.sys.mk:1.317
--- src/share/mk/bsd.sys.mk:1.316	Tue Feb 13 16:15:59 2024
+++ src/share/mk/bsd.sys.mk	Mon Jan 13 15:40:18 2025
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.sys.mk,v 1.316 2024/02/13 16:15:59 christos Exp $
+#	$NetBSD: bsd.sys.mk,v 1.317 2025/01/13 15:40:18 riastradh Exp $
 #
 # Build definitions used for NetBSD source tree builds.
 
@@ -56,11 +56,17 @@ CXXFLAGS+=	${REPROFLAGS}
 .endif
 
 # NetBSD sources use C99 style, with some GCC extensions.
-# Coverity does not like -std=gnu99
+# Coverity does not like -std=gnu99 (XXX untested but likely not gnu11 either)
+#
+# XXX Ideally we would not rely on GNU extensions, but currently some
+# code uses alloca(3) which -std=c11 compiles broken-at-runtime.  Until
+# we fix that (PR toolchain/58969: use of alloca is warning, not error,
+# with -std=c11), we have to continue using -std=gnu11 and not
+# -std=c11.
 .if !defined(COVERITY_TOP_CONFIG) && empty(CFLAGS:M*-std=*)
-CFLAGS+=	${${ACTIVE_CC} == "clang":? -std=gnu99 :}
-CFLAGS+=	${${ACTIVE_CC} == "gcc":? -std=gnu99 :}
-CFLAGS+=	${${ACTIVE_CC} == "pcc":? -std=gnu99 :}
+CFLAGS+=	${${ACTIVE_CC} == "clang":? -std=gnu11 :}
+CFLAGS+=	${${ACTIVE_CC} == "gcc":? -std=gnu11 :}
+CFLAGS+=	${${ACTIVE_CC} == "pcc":? -std=gnu11 :}
 .endif
 
 .if defined(WARNS)

Index: src/sys/conf/Makefile.kern.inc
diff -u src/sys/conf/Makefile.kern.inc:1.301 src/sys/conf/Makefile.kern.inc:1.302
--- src/sys/conf/Makefile.kern.inc:1.301	Mon May  6 08:43:36 2024
+++ src/sys/conf/Makefile.kern.inc	Mon Jan 13 15:40:18 2025
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.kern.inc,v 1.301 2024/05/06 08:43:36 mrg Exp $
+#	$NetBSD: Makefile.kern.inc,v 1.302 2025/01/13 15:40:18 riastradh Exp $
 #
 # This file contains common `MI' targets and definitions and it is included
 # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
@@ -66,7 +66,7 @@ INCLUDES?=	-I. ${EXTRA_INCLUDES} -I${S}/
 		-I$S -nostdinc
 CPPFLAGS+=	${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT
 .if !defined(COVERITY_TOP_CONFIG)
-CPPFLAGS+=	-std=gnu99
+CPPFLAGS+=	-std=gnu11
 .endif
 .if ${KERNEL_DIR:Uno} == "yes"
 CPPFLAGS+=	-DKERNEL_DIR

Reply via email to