Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Mar 2008 11:46:30 -0800 (PST)
From:      "David O'Brien" <obrien@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/121363: Be causious compiling with -O2 (use -fno-strict-aliasing) Redux
Message-ID:  <200803041946.m24JkUh8094515@dragon.nuxi.org>
Resent-Message-ID: <200803041950.m24Jo1Gi083929@freefall.freebsd.org>

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

>Number:         121363
>Category:       ports
>Synopsis:       Be causious compiling with -O2 (use -fno-strict-aliasing) Redux
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 04 19:50:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     David O'Brien
>Release:        FreeBSD 8.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD dragon.NUXI.org 8.0-CURRENT FreeBSD 8.0-CURRENT #592: Sat Feb 16 21:08:06 PST 2008 rootk@dragon.NUXI.org:/src/fbsd/sys/i386/compile/DRAGON i386

	
>Description:

	Some (much?) 3rd party software does not realize that GCC 4's -O2
	and -O3 implies -fstrict-aliasing.  Some of this 3rd party code
	has bugs that are tripped over when building with -fstrict-aliasing.

	src/share/mk/sys.mk is moving to not adding "-fno-strict-aliasing"
	to CFLAGS.

	"-fno-strict-aliasing" hides real bugs and we need the warnings
	generated from "-fstrict-aliasing" to find them.  We also want
	/usr/src to be compiled in a manner that matches the tenderbox
	builds.  See src/share/mk/sys.mk rev 1.96 commit log.

>How-To-Repeat:

	Build Firefox and other ports with -O2 (or -O3).

>Fix:

	Of course I expect that Portmgr can come up with tweaks to this patch
	to acheive the goal of compiling ports with -fno-strict-aliasing.

	http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/73797
	was closed with a flippent answer and that is not acceptable this
	time around.

	We may also be able to use the GCC_OPTIONS environmental variable
	to pass this option to GCC down thru configure steps, etc...
	(untested if setting GCC_OPTIONS=-fno-strict-aliasing and specifing
	 -O2 on the command line reenables strict aliasing)
		_GCC_OPTIONS=-fno-strict-aliasing
		MAKE_ENV+=	GCC_OPTIONS="${GCC_OPTIONS} ${_GCC_OPTIONS}"
	is an example of how this may be used.


Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.589
diff -u -p -r1.589 bsd.port.mk
--- bsd.port.mk	17 Oct 2007 10:12:24 -0000	1.589
+++ bsd.port.mk	4 Mar 2008 19:35:54 -0000
@@ -2148,6 +2164,12 @@ MAKE_ENV+=		PREFIX=${PREFIX} \
 			MOTIFLIB="${MOTIFLIB}" LIBDIR="${LIBDIR}" CFLAGS="${CFLAGS}" \
 			CXXFLAGS="${CXXFLAGS}" MANPREFIX="${MANPREFIX}"
 
+.if !defined(WITHOUT_NO_STRICT_ALIASING)
+. if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
+CFLAGS+=	-fno-strict-aliasing
+. endif
+.endif
+
 PTHREAD_CFLAGS?=
 PTHREAD_LIBS?=		-pthread
 
>Release-Note:
>Audit-Trail:
>Unformatted:



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