[PATCH]: set C dialect when compiling world

From: Roman Divacky <rdivacky_at_freebsd.org>
Date: Tue, 13 Jan 2009 22:55:20 +0100
hi

in my effort to make world compile in gnu99 mode I'd like this
patch to be commited:

Index: bsd.sys.mk
===================================================================
RCS file: /home/ncvs/src/share/mk/bsd.sys.mk,v
retrieving revision 1.47
diff -u -r1.47 bsd.sys.mk
--- bsd.sys.mk	23 Jul 2008 06:14:21 -0000	1.47
+++ bsd.sys.mk	13 Jan 2009 21:36:04 -0000
_at__at_ -8,8 +8,11 _at__at_
 
 # for GCC:  http://gcc.gnu.org/onlinedocs/gcc-3.0.4/gcc_3.html#IDX143
 
-.if !defined(NO_WARNS) && ${CC} != "icc"
-. if defined(CSTD)
+# the default is gnu89 for now
+. if !defined(CSTD)
+CSTD		= gnu89
+. endif
+
 .  if ${CSTD} == "k&r"
 CFLAGS		+= -traditional
 .  elif ${CSTD} == "c89" || ${CSTD} == "c90"
_at__at_ -23,7 +26,8 _at__at_
 .  endif
 # -pedantic is problematic because it also imposes namespace restrictions
 #CFLAGS		+= -pedantic
-. endif
+
+.if !defined(NO_WARNS) && ${CC} != "icc"
 . if defined(WARNS)
 .  if ${WARNS} >= 1
 CWARNFLAGS	+=	-Wsystem-headers


the rationale behind this:

we set CSTD to gnu89 so typical {library|app|whatever} build gets added 
".... -std=gnu89 ...." to its CFLAGS. the command line looks like this for
example:

cc -O2 -pipe -DMALLOC_PRODUCTION -march=native -I/usr/src/lib/libc/include -I/usr/src/lib/libc/../../include
-I/usr/src/lib/libc/i386 -D__DBINTERFACE_PRIVATE -I/usr/src/lib/libc/../../contrib/gdtoa -DINET6
-I/usr/obj/usr/src/lib/libc -I/usr/src/lib/libc/resolv -DPOSIX_MISTAKE -I/usr/src/lib/libc/locale -DBROKEN_DES
-DPORTMAP -DDES_BUILTIN -I/usr/src/lib/libc/rpc -DYP -DNS_CACHING -DSYMBOL_VERSIONING -std=gnu89 -fstack-protector
-Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -c getppid.S

it's nicely hidden in the 4th line near the end ;)

I want this to be able to easily switch the C dialect used for various parts of
the world. We dont want to mess with expected C dialect of contributed software.
Hence once I switch the default to gnu99 I can just put CSTD=gnu89 to cddl/Makefile
etc. and be fine. 

note that this change is a nop as gcc defaults to gnu89 mode but we need it because
of the intended switch to gnu89.

comments?

	roman

Received on Tue Jan 13 2009 - 20:55:42 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:40 UTC