Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 May 2009 23:33:26 +0200 (CEST)
From:      Ed Schouten <ed@80386.nl>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/135083: [Patch] Support for USE_CSTD, override C language standard
Message-ID:  <20090530213326.3E6441CE50@palm.hoeg.nl>
Resent-Message-ID: <200905302140.n4ULe1oW017081@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         135083
>Category:       ports
>Synopsis:       [Patch] Support for USE_CSTD, override C language standard
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 30 21:40:01 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Ed Schouten
>Release:        FreeBSD 6.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD palm.hoeg.nl 6.4-STABLE FreeBSD 6.4-STABLE #0 r192147: Fri May 15 22:42:58 CEST 2009 ed@palm.hoeg.nl:/usr/obj/usr/src/sys/PALM i386
>Description:
The version of GCC that's being shipped with all supported versions of
FreeBSD uses C89 with GNU extensions by default (called gnu89). The
problem is that this behaviour may change in future versions of GCC, but
also when using different a different compiler, like Clang.

This is why I propose this small change to bsd.port.mk, which allows us
to override the C standard per port. When committed, we (the
FreeBSD/Clang team) can start submitting patches to the individual port
maintainers.

This has the following advantages:

- We can submit more bug reports to the Clang developers, because we can
  guarantee better coverage of the Ports tree.

- If/when GCC in the base system will get updated to a version that uses
  C99 by default or if GCC ever gets replaced with Clang, less work will
  be required to keep the ports working.
>How-To-Repeat:
Build high profile ports like libiconv with CC=clang. It won't build.
This means it's hard to get good support for Clang.
>Fix:
--- bsd.port.mk
+++ bsd.port.mk
@@ -308,6 +308,7 @@
 #				  the regular expression.
 # USE_GCC		- If set, this port requires this version of gcc, either in
 #				  the system or installed from a port.
+# USE_CSTD		- Override the default C language standard (gnu89, gnu99)
 # USE_GMAKE		- If set, this port uses gmake.
 # GMAKE			- Set to path of GNU make if not in $PATH.
 #				  Default: gmake
@@ -2180,6 +2181,10 @@
 .endif
 .endif
 
+.if defined(USE_CSTD)
+CFLAGS:=	${CFLAGS:N-std=*} -std=${USE_CSTD}
+.endif
+
 # Multiple make jobs support
 .if defined(DISABLE_MAKE_JOBS) || defined(MAKE_JOBS_UNSAFE)
 _MAKE_JOBS=		#
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090530213326.3E6441CE50>