At Sun, 08 Sep 2024 17:48:41 -0400, Greg Troxel <gdt%lexort.com@localhost> wrote: Subject: Re: GNU make 3.81 with GCC 14 > > Lloyd Parkes <lloyd%must-have-coffee.gen.nz@localhost> writes: > > > Does the following look like a good idea to add to > > tools/gmake/Makefile? I can create a PR for it easily enough. > > > > .if ${HAVE_GCC} > 13 > > HOST_CFLAGS+= -std=gnu89 > > .endif > > My quick reaction is that in theory, each program is written in a > specific language family member (LFM, that I'd call a "language" but > others disagree), such as C89 or C89-with-gnu-stuff. > > Additionally, compilers support multiple LFMs, and unhelpfully default > to newer ones, rater than enforcing that programs in newfangled LFMs > have to pass --std. > > So if make that we have is documented to build with gnu89, we should > just set --std=gnu89 always. > > Or is it c99-almost, and this is a kludge? Well technically it might be true that each program is written in a specific LFM, we have in fact been compiling the tools by default (natively) with a compiler (GCC-9) that defaults to "-std=gnu11", so in practice the tools are well ready to be compiled by any compiler that implements "gnu11", which as I said earlier is, practically speaking, all of them (all of the usable ones anyway). On the other hand I expect all the tools code is only really using gnu99 features at most, so -std=gnu99 is maybe even safer (as in more widely accepted by other vendor compilers) for now. > What is gcc14 defaulting to > for a c std? Is it really anything newer than c99? Well right from the fine GCC-14.2 manual it says: The default, if no C language dialect options are given, is -std=gnu17. So I just started a build (of a slightly older NetBSD source tree) on a FreeBSD-14 host with Clang-16, and I found I needed "-Wno-everything" as well (for tools/mtree!), and I also found that GCC, even back as far as 9.3, happily accepts the same option, so I would propose the following for a good start on supporting modern compilers. If or when someone encounters a compiler that doesn't support the "-Wno-everything" option, and/or needs something different, then that can be conditioned later, but for now covering GCC and Clang probably covers 99% of the world of systems NetBSD can be built on. Index: bsd.host.mk =================================================================== RCS file: /cvs/master/m-NetBSD/main/src/share/mk/bsd.host.mk,v retrieving revision 1.5 diff -u -u -r1.5 bsd.host.mk --- bsd.host.mk 9 Aug 2020 21:13:38 -0000 1.5 +++ bsd.host.mk 8 Sep 2024 21:10:45 -0000 @@ -16,14 +16,14 @@ # Helpers for cross-compiling HOST_CC?= cc -HOST_CFLAGS?= ${HOST_DBG} +HOST_CFLAGS?= ${HOST_DBG} -std=gnu99 -Wno-everything HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_DTRACE_OPTS} ${HOST_CPPFLAGS} -c HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_DTRACE_OPTS} ${HOST_CPPFLAGS} -c HOST_LINK.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} .if defined(HOSTPROG_CXX) HOST_LINK.c?= ${HOST_LINK.cc} .else -HOST_LINK.c?= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} +HOST_LINK.c?= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDSTATIC} ${HOST_LDFLAGS} .endif HOST_CXX?= c++ oh, that last change is because tools should be static too, in my world. -- Greg A. Woods <gwoods%acm.org@localhost> Kelowna, BC +1 250 762-7675 RoboHack <woods%robohack.ca@localhost> Planix, Inc. <woods%planix.com@localhost> Avoncote Farms <woods%avoncote.ca@localhost>
Attachment:
pgpjl4NLxoPcE.pgp
Description: OpenPGP Digital Signature