Print this page
5196 The cw wrapper restricts gcc to -O2

@@ -21,10 +21,11 @@
 
 #
 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright (c) 2012 by Delphix. All rights reserved.
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2014 Gary Mills
 #
 
 #
 # Makefile.master, global definitions for system source
 #

@@ -412,19 +413,38 @@
 sparc_ASFLAGS=  $(sparc_AS_XARCH)
 sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
 i386_ASFLAGS=   $(i386_AS_XARCH)
 amd64_ASFLAGS=  $(amd64_AS_XARCH)
 
+# Default adjustments to specified gcc optimization level
 #
-sparc_COPTFLAG=         -xO3
-sparcv9_COPTFLAG=       -xO3
-i386_COPTFLAG=          -O
-amd64_COPTFLAG=         -xO3
+# For -O and -O1
+ADJUST_OPT1=
+# For -O2
+ADJUST_OPT2=            -_gcc=-fno-strict-aliasing \
+                        -_gcc=-fno-unit-at-a-time \
+                        -_gcc=-fno-optimize-sibling-calls
 
-COPTFLAG= $($(MACH)_COPTFLAG)
-COPTFLAG64= $($(MACH64)_COPTFLAG)
+sparc_ADJCOPT=          $(ADJUST_OPT2)
+sparcv9_ADJCOPT=        $(ADJUST_OPT2)
+i386_ADJCOPT=           $(ADJUST_OPT1)
+amd64_ADJCOPT=          $(ADJUST_OPT2)
 
+# Symbols that can be redefined in individual Makefiles
+ADJCOPT= $($(MACH)_ADJCOPT)
+ADJCOPT64= $($(MACH64)_ADJCOPT)
+
+# These symbols are sometimes redefined in individual Makefiles
+sparc_COPTFLAG=         -_cc=-xO3 -_gcc=-O2
+sparcv9_COPTFLAG=       -_cc=-xO3 -_gcc=-O2
+i386_COPTFLAG=          -_cc=-O -_gcc=-O
+amd64_COPTFLAG=         -_cc=-xO3 -_gcc=-O2
+
+# Documented symbols that can be redefined in individual Makefiles
+COPTFLAG= $(ADJCOPT) $($(MACH)_COPTFLAG)
+COPTFLAG64= $(ADJCOPT64) $($(MACH64)_COPTFLAG)
+
 # When -g is used, the compiler globalizes static objects
 # (gives them a unique prefix). Disable that.
 CNOGLOBAL= -W0,-noglobal
 
 # Direct the Sun Studio compiler to use a static globalization prefix based on the

@@ -601,22 +621,25 @@
 amd64_CCFLAGS=          $(amd64_XARCH) -compat=5 \
                         -Qoption ccfe -messages=no%anachronism \
                         -Qoption ccfe -features=no%conststrings \
                         $(CCERRWARN)
 
-sparc_CCOPTFLAG=        -O
-sparcv9_CCOPTFLAG=      -O
-i386_CCOPTFLAG=         -O
-amd64_CCOPTFLAG=        -O
+sparc_CCOPTFLAG=        -_CC=-O -_g++=-O
+sparcv9_CCOPTFLAG=      -_CC=-O -_g++=-O
+i386_CCOPTFLAG=         -_CC=-O -_g++=-O
+amd64_CCOPTFLAG=        -_CC=-O -_g++=-O
 
-CCOPTFLAG=      $($(MACH)_CCOPTFLAG)
-CCOPTFLAG64=    $($(MACH64)_CCOPTFLAG)
-CCFLAGS=        $(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
-                $(CCUSERFLAGS)
-CCFLAGS64=      $(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
-                $(CCUSERFLAGS64)
+ADJCCOPT=       $(ADJUST_OPT1)
+ADJCCOPT64=     $(ADJUST_OPT1)
 
+CCOPTFLAG=      $(ADJCCOPT) $($(MACH)_CCOPTFLAG)
+CCOPTFLAG64=    $(ADJCCOPT) $($(MACH64)_CCOPTFLAG)
+CCFLAGS=        $(CCOPTFLAG) $($(MACH)_CCFLAGS) \
+                $(CCSOURCEDEBUGFLAGS) $(CCUSERFLAGS)
+CCFLAGS64=      $(CCOPTFLAG64) $($(MACH64)_CCFLAGS) \
+                $(CCSOURCEDEBUGFLAGS) $(CCUSERFLAGS64)
+
 #
 #
 #
 ELFWRAP_FLAGS   =
 ELFWRAP_FLAGS64 =       -64