ports/121363: Be causious compiling with -O2 (use -fno-strict-aliasing) Redux

David O'Brien obrien at FreeBSD.org
Tue Mar 4 19:50:01 UTC 2008

>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
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 04 19:50:01 UTC 2008
>Originator:     David O'Brien
>Release:        FreeBSD 8.0-CURRENT i386
System: FreeBSD dragon.NUXI.org 8.0-CURRENT FreeBSD 8.0-CURRENT #592: Sat Feb 16 21:08:06 PST 2008 rootk at dragon.NUXI.org:/src/fbsd/sys/i386/compile/DRAGON i386


	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"

	"-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.


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


	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.

	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)
	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} \
+. if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
+CFLAGS+=	-fno-strict-aliasing
+. endif
 PTHREAD_LIBS?=		-pthread

More information about the freebsd-ports-bugs mailing list