From ca4eddea97c54a567c25e0fcf4641a6885f33bdf Mon Sep 17 00:00:00 2001 From: Minsoo Choo Date: Thu, 9 Jan 2025 11:13:06 -0500 Subject: [PATCH] src: Use gnu17 as the default C standard for userland instead of gnu99 Tracking newer versions of C (and C++) permits assuming newer language features in the base system. Some C11 extensions are already used in the base system but implemented on top of GNU C extensions such as _Alignas and _Static_assert. In some cases the fallback versions in cdefs.h are more limited than the native C11 extensions. Even though C11 is the next major version of C, C17 is chosen instead since C17 does not add new features to C but merely fixes defects in C11. It is also well supported by a wide range of clang (7.0.0+) and GCC (8.1+) versions. Along with changing the default, this change also removes explicit requests for c11 via the CSTD variable in various Makefiles. Libraries and binaries for ZFS continue to use c99. PR: 284039 (exp-run) Reviewed by: imp, arichardson, emaste Differential Revision: https://reviews.freebsd.org/D43237 --- libexec/tftpd/tests/Makefile | 1 - sbin/newfs_msdos/Makefile | 1 - share/mk/bsd.sys.mk | 3 +-- usr.bin/sort/Makefile | 1 - usr.bin/zstd/Makefile | 1 - usr.sbin/makefs/Makefile | 1 - 6 files changed, 1 insertion(+), 7 deletions(-) diff --git a/libexec/tftpd/tests/Makefile b/libexec/tftpd/tests/Makefile index 661120335ac..d1faca03331 100644 --- a/libexec/tftpd/tests/Makefile +++ b/libexec/tftpd/tests/Makefile @@ -4,6 +4,5 @@ ATF_TESTS_C= functional TEST_METADATA.functional+= timeout=15 LIBADD= util -CSTD= c11 .include diff --git a/sbin/newfs_msdos/Makefile b/sbin/newfs_msdos/Makefile index a3ea6a6a675..bd5b3486b6b 100644 --- a/sbin/newfs_msdos/Makefile +++ b/sbin/newfs_msdos/Makefile @@ -9,7 +9,6 @@ SRCS= newfs_msdos.c mkfs_msdos.c .if ${MACHINE_CPUARCH} == "arm" WARNS?= 3 .endif -CSTD= c11 HAS_TESTS= SUBDIR.${MK_TESTS}+= tests diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index c136bf1e1af..63496e9b8cc 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -10,8 +10,7 @@ .include -# the default is gnu99 for now -CSTD?= gnu99 +CSTD?= gnu17 .if ${CSTD} == "c89" || ${CSTD} == "c90" CFLAGS+= -std=iso9899:1990 diff --git a/usr.bin/sort/Makefile b/usr.bin/sort/Makefile index 561af217af7..46cc431edd3 100644 --- a/usr.bin/sort/Makefile +++ b/usr.bin/sort/Makefile @@ -3,7 +3,6 @@ PACKAGE= runtime PROG= sort SRCS= bwstring.c coll.c file.c mem.c radixsort.c sort.c vsort.c -CSTD= c11 sort.1: sort.1.in sed ${MAN_SUB} ${.ALLSRC} >${.TARGET} diff --git a/usr.bin/zstd/Makefile b/usr.bin/zstd/Makefile index dd54acbf83c..0e73e2eb0dd 100644 --- a/usr.bin/zstd/Makefile +++ b/usr.bin/zstd/Makefile @@ -25,7 +25,6 @@ MLINKS= zstd.1 unzstd.1 \ zstd.1 zstdcat.1 \ zstd.1 zstdmt.1 -CSTD=c11 WARNS?= 2 LIBADD= zstd .PATH: ${SRCTOP}/sys/contrib/zstd/programs diff --git a/usr.sbin/makefs/Makefile b/usr.sbin/makefs/Makefile index 75733714fcc..47a41cfac81 100644 --- a/usr.sbin/makefs/Makefile +++ b/usr.sbin/makefs/Makefile @@ -15,7 +15,6 @@ SRCS= cd9660.c \ MAN= makefs.8 NO_WCAST_ALIGN= -CSTD= c11 .if ${MK_ZFS} != "no" SRCS+= zfs.c