changeset 460:b374f6174534

6729772: 64-bit build with SS12 compiler: SIGSEGV (0xb) at pc=0x0000000000000048, pid=14826, tid=2 Reviewed-by: tbell
author ohair
date Wed, 30 Jul 2008 19:40:57 -0700
parents b7474b739d13
children a140a5aa5f2c
files make/common/Defs-linux.gmk make/common/Defs-solaris.gmk make/common/Defs-windows.gmk make/common/Defs.gmk make/common/Library.gmk make/common/shared/Defs.gmk make/java/fdlibm/Makefile make/java/java_hprof_demo/Makefile make/sun/awt/Makefile make/sun/font/Makefile make/sun/font/t2k/Makefile make/sun/image/generic/Makefile make/sun/image/vis/Makefile make/sun/jpeg/Makefile
diffstat 14 files changed, 243 insertions(+), 221 deletions(-) [+]
line wrap: on
line diff
--- a/make/common/Defs-linux.gmk	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/common/Defs-linux.gmk	Wed Jul 30 19:40:57 2008 -0700
@@ -86,18 +86,22 @@
 #
 # Default optimization
 #
-CC_HIGHEST_OPT = -O3
-CC_HIGHER_OPT  = -O3
-CC_LOWER_OPT   = -O2
-CC_NO_OPT      =
 
-ifeq ($(PRODUCT), java)
-    _OPT = $(CC_HIGHER_OPT)
-else
-    _OPT = $(CC_LOWER_OPT)
-    CPPFLAGS_DBG    += -DLOGGING 
+ifndef OPTIMIZATION_LEVEL
+  ifeq ($(PRODUCT), java)
+    OPTIMIZATION_LEVEL = HIGHER
+  else
+    OPTIMIZATION_LEVEL = LOWER
+  endif
 endif
 
+CC_OPT/NONE     = 
+CC_OPT/LOWER    = -O2
+CC_OPT/HIGHER   = -O3
+CC_OPT/HIGHEST  = -O3
+
+CC_OPT          = $(CC_OPT/$(OPTIMIZATION_LEVEL))
+
 # For all platforms, do not omit the frame pointer register usage. 
 #    We need this frame pointer to make it easy to walk the stacks.
 #    This should be the default on X86, but ia64 and amd64 may not have this
@@ -112,18 +116,6 @@
 CFLAGS_REQUIRED         =  $(CFLAGS_REQUIRED_$(ARCH))
 LDFLAGS_COMMON          += $(LDFLAGS_COMMON_$(ARCH))
 
-# Add in platform specific optimizations for all opt levels
-CC_HIGHEST_OPT += $(_OPT_$(ARCH))
-CC_HIGHER_OPT  += $(_OPT_$(ARCH))
-CC_LOWER_OPT   += $(_OPT_$(ARCH))
-
-# If NO_OPTIMIZATIONS is defined in the environment, turn all optimzations off
-ifdef NO_OPTIMIZATIONS
-  CC_HIGHEST_OPT = $(CC_NO_OPT)
-  CC_HIGHER_OPT  = $(CC_NO_OPT)
-  CC_LOWER_OPT   = $(CC_NO_OPT)
-endif
-
 #
 # Selection of warning messages
 #
@@ -163,19 +155,19 @@
   endif
 endif
 
-CFLAGS_OPT      = $(POPT)
+CFLAGS_OPT      = $(CC_OPT)
 CFLAGS_DBG      = $(DEBUG_FLAG)
 CFLAGS_COMMON += $(CFLAGS_REQUIRED)
 
 CXXFLAGS_COMMON = $(GLOBAL_KPIC) -DCC_NOEX $(GCC_WARNINGS)
-CXXFLAGS_OPT	= $(POPT)
+CXXFLAGS_OPT	= $(CC_OPT)
 CXXFLAGS_DBG	= $(DEBUG_FLAG)
 CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
 
 # FASTDEBUG: Optimize the code in the -g versions, gives us a faster debug java
 ifeq ($(FASTDEBUG), true)
-  CFLAGS_DBG    += $(CC_LOWER_OPT)
-  CXXFLAGS_DBG	+= $(CC_LOWER_OPT)
+  CFLAGS_DBG    += $(CC_OPT/LOWER)
+  CXXFLAGS_DBG	+= $(CC_OPT/LOWER)
 endif
 
 CPPFLAGS_COMMON = -D$(ARCH) -DARCH='"$(ARCH)"' -DLINUX $(VERSION_DEFINES) \
@@ -187,6 +179,9 @@
 
 CPPFLAGS_OPT    = 
 CPPFLAGS_DBG    = -DDEBUG
+ifneq ($(PRODUCT), java)
+  CPPFLAGS_DBG    += -DLOGGING 
+endif
 
 ifdef LIBRARY
   # Libraries need to locate other libraries at runtime, and you can tell
--- a/make/common/Defs-solaris.gmk	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/common/Defs-solaris.gmk	Wed Jul 30 19:40:57 2008 -0700
@@ -83,15 +83,16 @@
 #
 # Java default optimization (-x04/-O2) etc.  Applies to the VM.
 #
-ifeq ($(PRODUCT), java)
-    _OPT = $(CC_HIGHER_OPT)
-else
-    _OPT = $(CC_LOWER_OPT)
-    CPPFLAGS_DBG    += -DLOGGING -DDBINFO
+ifndef OPTIMIZATION_LEVEL
+  ifeq ($(PRODUCT), java)
+    OPTIMIZATION_LEVEL = HIGHER
+  else
+    OPTIMIZATION_LEVEL = LOWER
+  endif
 endif
 
 #
-# If -Xa is in CFLAGS_COMMON it will end up ahead of $(POPT) for the
+# If -Xa is in CFLAGS_COMMON it will end up ahead of $(CC_OPT) for the
 # optimized build, and that ordering of the flags completely freaks
 # out cc.  Hence, -Xa is instead in each CFLAGS variant.
 #
@@ -116,8 +117,8 @@
 #
 # Debug flag for C and C++ compiler
 #
-CFLAGS_DEBUG_OPTION=-g
-CXXFLAGS_DEBUG_OPTION=-g
+CFLAGS_DEBUG_OPTION    = -g $(CC_OPT/NONE)
+CXXFLAGS_DEBUG_OPTION  = -g $(CXX_OPT/NONE)
 
 # Turn off -g if we are doing tcov build
 ifdef TCOV_BUILD
@@ -135,15 +136,14 @@
 #        Performance/size of files should be about the same, maybe smaller.
 #
 ifeq ($(FASTDEBUG), true)
-  CC_FASTDEBUG_OPT       = $(CC_LOWER_OPT)
-  CFLAGS_DEBUG_OPTION    = -g   $(CC_FASTDEBUG_OPT)
-  CXXFLAGS_DEBUG_OPTION  = -g0  $(CC_FASTDEBUG_OPT)
+  CFLAGS_DEBUG_OPTION    = -g  $(CC_OPT/LOWER)
+  CXXFLAGS_DEBUG_OPTION  = -g0 $(CXX_OPT/LOWER)
 endif
 
 CFLAGS_COMMON   = -v -mt -L$(OBJDIR) -xc99=%none
 CFLAGS_COMMON  += -xCC
 CFLAGS_COMMON  += -errshort=tags
-CFLAGS_OPT      = $(POPT)
+CFLAGS_OPT      = $(CC_OPT)
 CFLAGS_DBG      = $(CFLAGS_DEBUG_OPTION)
 CFLAGS_COMMON  +=  -Xa $(CFLAGS_REQUIRED)
 
@@ -171,7 +171,7 @@
   CXXFLAGS_COMMON += -errwarn=%all
 endif
 
-CXXFLAGS_OPT	= $(POPT)
+CXXFLAGS_OPT	= $(CXX_OPT)
 CXXFLAGS_DBG	= $(CXXFLAGS_DEBUG_OPTION)
 CXXFLAGS_COMMON += $(CFLAGS_REQUIRED)
 
@@ -241,6 +241,10 @@
 CPPFLAGS_OPT    = 
 CPPFLAGS_DBG    = -DDEBUG
 
+ifneq ($(PRODUCT), java)
+  CPPFLAGS_DBG    += -DLOGGING -DDBINFO
+endif
+
 ifeq ($(ARCH_FAMILY), i586)
   # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
   #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
@@ -384,63 +388,151 @@
 # Different "levels" of optimization.
 #
 ifeq ($(CC_VERSION),gcc)
-  CC_HIGHEST_OPT = -O3
-  CC_HIGHER_OPT  = -O3
-  CC_LOWER_OPT   = -O2
+  
+  CC_OPT/NONE     =
+  CC_OPT/LOWER    = -O2
+  CC_OPT/HIGHER   = -O3
+  CC_OPT/HIGHEST  = -O3
+
+  CXX_OPT/NONE    =
+  CXX_OPT/LOWER   = -O2
+  CXX_OPT/HIGHER  = -O3
+  CXX_OPT/HIGHEST = -O3
+
   CFLAGS_REQUIRED_i586  += -fno-omit-frame-pointer
   CFLAGS_REQUIRED_amd64 += -fno-omit-frame-pointer
+  
   # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
   #   (See Rules.gmk) May need to wait for gcc 5?
   AUTOMATIC_PCH_OPTION = 
+
 else
+  
   # Highest could be -xO5, but indications are that -xO5 should be reserved
   #    for a per-file use, on sources with known performance impacts.
-  CC_HIGHEST_OPT = -xO4
-  CC_HIGHER_OPT  = -xO4
-  CC_LOWER_OPT   = -xO2
+  OPT_LEVEL/LOWER    = 2
+  OPT_LEVEL/HIGHER   = 4
+  OPT_LEVEL/HIGHEST  = 4
+  
+  CC_OPT/NONE     =
+  CC_OPT/LOWER    = $(OPT_LEVEL/LOWER:%=-xO%)
+  CC_OPT/HIGHER   = $(OPT_LEVEL/HIGHER:%=-xO%)
+  CC_OPT/HIGHEST  = $(OPT_LEVEL/HIGHEST:%=-xO%)
+  
+  CXX_OPT/NONE    =
+  CXX_OPT/LOWER   = $(OPT_LEVEL/LOWER:%=-xO%)
+  CXX_OPT/HIGHER  = $(OPT_LEVEL/HIGHER:%=-xO%)
+  CXX_OPT/HIGHEST = $(OPT_LEVEL/HIGHEST:%=-xO%)
+    
+  # We need stack frames at all times
+  USE_XKEEPFRAME_OPTION = false
+  ifeq ($(USE_XKEEPFRAME_OPTION),true)
+    
+    # Unknown spelling on this option at this time (Maybe in SS13?)
+    CC_XKEEPFRAME_OPTIONS  = -xkeepframe
+    CXX_XKEEPFRAME_OPTIONS = -xkeepframe
+  
+  else
+  
+    # On X86, make sure tail call optimization is off
+    #    The z and y are the tail call optimizations.
+    ifeq ($(ARCH_FAMILY), i586)
+      ifeq ($(shell $(EXPR) $(CC_VER) \> 5.8), 1)
+        # Somehow, tail call optimization is creeping in.
+        #    Make sure it is off.
+	# WARNING: These may cause compiler warnings about duplicate -O options
+        CC_XKEEPFRAME_OPTIONS  += -Wu,-O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
+        CXX_XKEEPFRAME_OPTIONS += -Qoption ube -O$(OPT_LEVEL/$(OPTIMIZATION_LEVEL))~yz
+      endif
+    endif
+  
+    #  On i586 we need to tell the code generator to ALWAYS use a
+    #   frame pointer.
+    ifeq ($(ARCH_FAMILY), i586)
+      # Note that in 5.7, this is done with -xregs=no%frameptr
+      ifeq ($(CC_VER), 5.5)
+        # It's not exactly clear when this optimization kicks in, the
+        #   current assumption is -xO4 or greater and for C++ with
+        #   the -features=no%except option and -xO4 and greater.
+        #   Bottom line is, we ALWAYS want a frame pointer!
+        CC_XKEEPFRAME_OPTIONS  += -Wu,-Z~B
+        CXX_XKEEPFRAME_OPTIONS += -Qoption ube -Z~B
+      endif
+      ifeq ($(shell $(EXPR) $(CC_VER) \> 5.6), 1)
+        # Do NOT use frame pointer register as a general purpose opt register
+        CC_OPT/NONE            += -xregs=no%frameptr
+        CXX_OPT/NONE           += -xregs=no%frameptr
+        CC_XKEEPFRAME_OPTIONS  += -xregs=no%frameptr
+        CXX_XKEEPFRAME_OPTIONS += -xregs=no%frameptr
+      endif
+    endif
+  
+    #  Optimizer for sparc needs to be told not to do certain things
+    #   related to frames or save instructions.
+    ifeq ($(ARCH_FAMILY), sparc)
+      #  Do not use save instructions instead of add instructions
+      #  This was an optimization starting in SC5.0 that made it hard for us to
+      #    find the "save" instruction (which got turned into an "add")
+      CC_XKEEPFRAME_OPTIONS  += -Wc,-Qrm-s
+      CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qrm-s
+      # Don't allow tail call code optimization. Started in SC5.0.
+      #    We don't like code of this form:
+      #	save
+      #	<code>
+      #	call foo
+      #	   restore
+      #   because we can't tell if the method will have a stack frame
+      #   and register windows or not.
+      CC_XKEEPFRAME_OPTIONS  += -Wc,-Qiselect-T0
+      CXX_XKEEPFRAME_OPTIONS += -Qoption cg -Qiselect-T0
+    endif
+  
+  endif
+
+  # Extra options used with HIGHEST
   #
-  # WARNING: Use of _OPT=$(CC_HIGHEST_OPT) in your Makefile needs to be
+  # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
   #          done with care, there are some assumptions below that need to
   #          be understood about the use of pointers, and IEEE behavior.
   #
   # Use non-standard floating point mode (not IEEE 754)
-  CC_HIGHEST_OPT += -fns
+  CC_HIGHEST_EXTRAS += -fns
   # Do some simplification of floating point arithmetic (not IEEE 754)
-  CC_HIGHEST_OPT += -fsimple
+  CC_HIGHEST_EXTRAS += -fsimple
   # Use single precision floating point with 'float'
-  CC_HIGHEST_OPT += -fsingle
+  CC_HIGHEST_EXTRAS += -fsingle
   # Assume memory references via basic pointer types do not alias
   #   (Source with excessing pointer casting and data access with mixed 
   #    pointer types are not recommended)
-  CC_HIGHEST_OPT += -xalias_level=basic
+  CC_HIGHEST_EXTRAS += -xalias_level=basic
   # Use intrinsic or inline versions for math/std functions
   #   (If you expect perfect errno behavior, do not use this)
-  CC_HIGHEST_OPT += -xbuiltin=%all
+  CC_HIGHEST_EXTRAS += -xbuiltin=%all
   # Loop data dependency optimizations (need -xO3 or higher)
-  CC_HIGHEST_OPT += -xdepend
+  CC_HIGHEST_EXTRAS += -xdepend
   # Pointer parameters to functions do not overlap
   #   (Similar to -xalias_level=basic usage, but less obvious sometimes.
   #    If you pass in multiple pointers to the same data, do not use this)
-  CC_HIGHEST_OPT += -xrestrict
+  CC_HIGHEST_EXTRAS += -xrestrict
   # Inline some library routines
   #   (If you expect perfect errno behavior, do not use this)
-  CC_HIGHEST_OPT += -xlibmil
+  CC_HIGHEST_EXTRAS += -xlibmil
   # Use optimized math routines
   #   (If you expect perfect errno behavior, do not use this)
   #  Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
-  #  CC_HIGHEST_OPT += -xlibmopt
+  #  CC_HIGHEST_EXTRAS += -xlibmopt
   ifeq ($(ARCH_FAMILY), sparc)
     # Assume at most 8byte alignment, raise SIGBUS on error
     ### Presents an ABI issue with customer JNI libs?
-    ####CC_HIGHEST_OPT  += -xmemalign=8s
+    ####CC_HIGHEST_EXTRAS  += -xmemalign=8s
     # Automatic prefetch instructions, explicit prefetch macros
-    CC_HIGHEST_OPT  += -xprefetch=auto,explicit
+    CC_HIGHEST_EXTRAS += -xprefetch=auto,explicit
     # Pick ultra as the chip to optimize to
-    CC_HIGHEST_OPT  += -xchip=ultra
+    CC_HIGHEST_EXTRAS += -xchip=ultra
   endif
   ifeq ($(ARCH), i586)
     # Pick pentium as the chip to optimize to
-    CC_HIGHEST_OPT  += -xchip=pentium
+    CC_HIGHEST_EXTRAS += -xchip=pentium
   endif
   ifdef LIBRARY
     # The Solaris CBE (Common Build Environment) requires that the use
@@ -450,9 +542,6 @@
     CFLAGS_REQUIRED_sparcv9  += -xregs=no%appl
   endif
   ifeq ($(shell $(EXPR) $(CC_VER) \> 5.6), 1)
-    # Do NOT use the frame pointer register as a general purpose opt register
-    CFLAGS_REQUIRED_i586  += -xregs=no%frameptr
-    CFLAGS_REQUIRED_amd64 += -xregs=no%frameptr
     # We MUST allow data alignment of 4 for sparc V8 (32bit)
     #     Presents an ABI issue with customer JNI libs? We must be able to
     #     to handle 4byte aligned objects? (rare occurance, but possible?)
@@ -466,77 +555,28 @@
   # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
   #   (See Rules.gmk) The SS11 -xpch=auto* options appear to be broken.
   AUTOMATIC_PCH_OPTION =
+  
+  # Add in keep frame options
+  CC_OPT/LOWER    += $(CC_XKEEPFRAME_OPTIONS)
+  CC_OPT/HIGHER   += $(CC_XKEEPFRAME_OPTIONS)
+  CC_OPT/HIGHEST  += $(CC_XKEEPFRAME_OPTIONS)
+  CXX_OPT/LOWER   += $(CXX_XKEEPFRAME_OPTIONS)
+  CXX_OPT/HIGHER  += $(CXX_XKEEPFRAME_OPTIONS)
+  CXX_OPT/HIGHEST += $(CXX_XKEEPFRAME_OPTIONS)
+ 
+  # Add in highest optimization settings
+  CC_OPT/HIGHEST  += $(CC_HIGHEST_EXTRAS)
+  CXX_OPT/HIGHEST += $(CC_HIGHEST_EXTRAS)
+  
 endif
-CC_NO_OPT      = 
 
-# If NO_OPTIMIZATIONS is defined in the environment, turn all optimzations off
-ifdef NO_OPTIMIZATIONS
-  CC_HIGHEST_OPT = $(CC_NO_OPT)
-  CC_HIGHER_OPT  = $(CC_NO_OPT)
-  CC_LOWER_OPT   = $(CC_NO_OPT)
-endif
+# Default optimization settings based on level.
+CC_OPT  = $(CC_OPT/$(OPTIMIZATION_LEVEL))
+CXX_OPT = $(CXX_OPT/$(OPTIMIZATION_LEVEL))
 
 # Flags required all the time
 CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
 
-# Add processor specific options for optimizations
-CC_HIGHEST_OPT += $(_OPT_$(ARCH))
-CC_HIGHER_OPT  += $(_OPT_$(ARCH))
-CC_LOWER_OPT   += $(_OPT_$(ARCH))
-
-# Secret compiler optimization options that should be in the above macros
-#    but since they differ in format from C to C++, are added into the C or
-#    C++ specific macros for compiler flags.
-#
-#  On i586 we need to tell the code generator to ALWAYS use a
-#   frame pointer.
-ifeq ($(ARCH_FAMILY), i586)
-  # Note that in 5.7, this is done with -xregs=no%frameptr
-  ifeq ($(CC_VER), 5.5)
-    #       It's not exactly clear when this optimization kicks in, the
-    #       current assumption is -xO4 or greater and for C++ with
-    #       the -features=no%except option and -xO4 and greater.
-    #       Bottom line is, we ALWAYS want a frame pointer!
-    CXXFLAGS_OPT += -Qoption ube -Z~B
-    CFLAGS_OPT   +=          -Wu,-Z~B
-    ifeq ($(FASTDEBUG), true)
-        CXXFLAGS_DBG += -Qoption ube -Z~B
-        CFLAGS_DBG   +=          -Wu,-Z~B
-    endif
-  endif
-endif
-#
-#  Optimizer for sparc needs to be told not to do certain things
-#   related to frames or save instructions.
-ifeq ($(ARCH_FAMILY), sparc)
-  # NOTE: Someday the compilers will provide a high-level option for this.
-  #   Use save instructions instead of add instructions
-  #    This was an optimization starting in SC5.0 that made it hard for us to
-  #    find the "save" instruction (which got turned into an "add")
-  CXXFLAGS_OPT += -Qoption cg -Qrm-s
-  CFLAGS_OPT   +=         -Wc,-Qrm-s
-  ifeq ($(FASTDEBUG), true)
-    CXXFLAGS_DBG += -Qoption cg -Qrm-s
-    CFLAGS_DBG   +=         -Wc,-Qrm-s
-  endif
-  #
-  # NOTE: Someday the compilers will provide a high-level option for this.
-  #   Don't allow tail call code optimization. Started in SC5.0.
-  #    We don't like code of this form:
-  #	save
-  #	<code>
-  #	call foo
-  #	   restore
-  #   because we can't tell if the method will have a stack frame
-  #   and register windows or not.
-  CXXFLAGS_OPT += -Qoption cg -Qiselect-T0
-  CFLAGS_OPT   +=         -Wc,-Qiselect-T0
-  ifeq ($(FASTDEBUG), true)
-    CXXFLAGS_DBG += -Qoption cg -Qiselect-T0
-    CFLAGS_DBG   +=         -Wc,-Qiselect-T0
-  endif
-endif
-
 #
 # Path and option to link against the VM, if you have to.  Note that
 # there are libraries that link against only -ljava, but they do get
--- a/make/common/Defs-windows.gmk	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/common/Defs-windows.gmk	Wed Jul 30 19:40:57 2008 -0700
@@ -84,6 +84,15 @@
 #
 # Default optimization
 #
+
+ifndef OPTIMIZATION_LEVEL
+  ifeq ($(PRODUCT), java)
+    OPTIMIZATION_LEVEL = HIGHER
+  else
+    OPTIMIZATION_LEVEL = LOWER
+  endif
+endif
+
 ifeq ($(CC_VERSION),msvc)
   # Visual Studio .NET 2003 or VS2003 compiler option definitions:
   #   -O1      Favors reduced size over speed (-Og     -Os -Oy -Ob2 -Gs -GF -Gy)
@@ -113,21 +122,28 @@
   # NOTE: With VC6, -Ox, -O1, and -O2 used -Ob1, not -Ob2.
   # NOTE: With VC6, -O1 and -O2 used -Gf, not -GF.
   #
+
+  CC_OPT/NONE    = -Od
+  CC_OPT/LOWER   = -O2
+  CC_OPT/HIGHER  = -O3
+  CC_OPT/HIGHEST = -O3
+  
   ifeq ($(COMPILER_VERSION), VC6)
     # VC6 (6.2) msvc compiler (the way Tiger and early Mustang were built)
     # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
     AUTOMATIC_PCH_OPTION =
     GX_OPTION = -GX
     ifeq ($(ARCH_DATA_MODEL), 32)
-      CC_HIGHEST_OPT = -Ox -Gy -Os -GB
-      CC_HIGHER_OPT  = -Ox -Gy -Os -GB
-      CC_LOWER_OPT   = -Ox -Gy -Os -GB
+      CC_OPT/HIGHEST = -Ox -Gy -Os -GB
+      CC_OPT/HIGHER  = -Ox -Gy -Os -GB
+      CC_OPT/LOWER   = -Ox -Gy -Os -GB
     else
-      CC_HIGHEST_OPT = -Ox -Gy -Op
-      CC_HIGHER_OPT  = -Ox -Gy -Op
-      CC_LOWER_OPT   = -Ox -Gy -Op
+      CC_OPT/HIGHEST = -Ox -Gy -Op
+      CC_OPT/HIGHER  = -Ox -Gy -Op
+      CC_OPT/LOWER   = -Ox -Gy -Op
     endif
   endif
+  
   ifeq ($(COMPILER_VERSION), VS2003)
     # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
     AUTOMATIC_PCH_OPTION = -YX
@@ -135,53 +151,45 @@
     GX_OPTION = -GX
     ifeq ($(ARCH_DATA_MODEL), 32)
       # Lowered opt level to try and reduce footprint, dll size especially.
-      #     Was: CC_HIGHEST_OPT = -O2 -G6
-      #     Was: CC_HIGHER_OPT  = -O2
-      CC_HIGHEST_OPT = -O2
-      CC_HIGHER_OPT  = -O1
-      CC_LOWER_OPT   = -O1
+      #     Was: CC_OPT/HIGHEST = -O2 -G6
+      #     Was: CC_OPT/HIGHER  = -O2
+      CC_OPT/HIGHEST = -O2
+      CC_OPT/HIGHER  = -O1
+      CC_OPT/LOWER   = -O1
     else
-      CC_HIGHEST_OPT = -O2 -Op
-      CC_HIGHER_OPT  = -O2 -Op
-      CC_LOWER_OPT   = -O1 -Op
+      CC_OPT/HIGHEST = -O2 -Op
+      CC_OPT/HIGHER  = -O2 -Op
+      CC_OPT/LOWER   = -O1 -Op
     endif
   endif
+  
   ifeq ($(COMPILER_VERSION), VS2005)
     # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
     AUTOMATIC_PCH_OPTION =
     # VS2005 compiler, only with Platform SDK right now?
     GX_OPTION = -EHsc
     ifeq ($(ARCH_DATA_MODEL), 32)
-      CC_HIGHEST_OPT = -O2
-      CC_HIGHER_OPT  = -O1
-      CC_LOWER_OPT   = -O1
+      CC_OPT/HIGHEST = -O2
+      CC_OPT/HIGHER  = -O1
+      CC_OPT/LOWER   = -O1
     else
-      CC_HIGHEST_OPT = -O2
-      CC_HIGHER_OPT  = -O1
-      CC_LOWER_OPT   = -O1
+      CC_OPT/HIGHEST = -O2
+      CC_OPT/HIGHER  = -O1
+      CC_OPT/LOWER   = -O1
     endif
   endif
-  CC_NO_OPT      = -Od
+
 else # CC_VERSION
+  
   # GCC not supported, but left for historical reference...
-  CC_HIGHEST_OPT = -O3
-  CC_HIGHER_OPT  = -O2
-  CC_LOWER_OPT   = -O2
-  CC_NO_OPT      = 
+  CC_OPT/NONE     =
+  CC_OPT/LOWER    = -O2
+  CC_OPT/HIGHER   = -O2
+  CC_OPT/HIGHEST  = -O3
+
 endif
 
-# If NO_OPTIMIZATIONS is defined in the environment, turn all optimzations off
-ifdef NO_OPTIMIZATIONS
-  CC_HIGHEST_OPT = $(CC_NO_OPT)
-  CC_HIGHER_OPT  = $(CC_NO_OPT)
-  CC_LOWER_OPT   = $(CC_NO_OPT)
-endif
-
-ifeq ($(PRODUCT), java)
-    _OPT = $(CC_HIGHER_OPT)
-else
-    _OPT = $(CC_LOWER_OPT)
-endif
+CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
 
 # Select the runtime support library carefully, need to be consistent
 #
@@ -233,7 +241,7 @@
   #            Use static link for the C++ runtime (so msvcp71.dll not needed)
   #   
   CFLAGS_COMMON  += -Zi -nologo
-  CFLAGS_OPT      = $(POPT)
+  CFLAGS_OPT      = $(CC_OPT)
   CFLAGS_DBG      = -Od $(MS_RUNTIME_DEBUG_OPTION)
 
   # Starting from VS2005 the wchar_t is handled as a built-in C/C++ data type
--- a/make/common/Defs.gmk	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/common/Defs.gmk	Wed Jul 30 19:40:57 2008 -0700
@@ -483,11 +483,6 @@
 include $(JDK_MAKE_SHARED_DIR)/Defs-java.gmk
 
 #
-# Set opt level to ALT_OPT if set otherwise _OPT
-#
-POPT = $(_OPT$(ALT_OPT))$(ALT_OPT)
-
-#
 # Convenient macros
 #
 
--- a/make/common/Library.gmk	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/common/Library.gmk	Wed Jul 30 19:40:57 2008 -0700
@@ -238,7 +238,7 @@
 #
 $(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder)
 	@$(prep-target)
-	@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), _OPT=$(_OPT)"
+	@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
 	@$(ECHO) "Rebuilding $@ because of $?"
 ifeq ($(LIBRARY), fdlibm)
 	$(AR) -r $@ $(FILES_o)
--- a/make/common/shared/Defs.gmk	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/common/shared/Defs.gmk	Wed Jul 30 19:40:57 2008 -0700
@@ -277,9 +277,6 @@
 PROMOTED_BUILD_BASEDIR = $(PROMOTED_RE_AREA)/$(PROMOTED_BUILD_LATEST)
 PROMOTED_BUILD_BINARIES = $(PROMOTED_BUILD_BASEDIR)/binaries
 
-# OPT: Changes what the optimizations settings (in _OPT)
-POPT = $(_OPT$(ALT_OPT))$(ALT_OPT)
-
 # PARALLEL_COMPILE_JOBS: is the number of compiles done in parallel.
 #  If the user sets ALT_PARALLEL_COMPILE_JOBS, then COMPILE_APPROACH is set
 #  to parallel.
--- a/make/java/fdlibm/Makefile	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/java/fdlibm/Makefile	Wed Jul 30 19:40:57 2008 -0700
@@ -33,6 +33,7 @@
 BUILDDIR     = ../..
 LIBRARY      = fdlibm
 PRODUCT      = java
+
 include $(BUILDDIR)/common/Defs.gmk
 
 #
@@ -40,10 +41,10 @@
 #
 FDLIBM_SRC = $(SHARE_SRC)/native/java/lang/fdlibm
 
-# windows compiler flags
+# Windows: compiler flags
 ifeq ($(PLATFORM),windows)
   # Turn all optimizations off
-  _OPT = $(CC_NO_OPT)
+  OPTIMIZATION_LEVEL = NONE
   OTHER_CFLAGS =
   CPPFLAGS_DBG += -DLOGGING
   # Files built here do not compile with warning level 3 if warnings are fatal
@@ -51,6 +52,15 @@
 endif
 
 #
+# Linux: Disable optimization to get correctly reproducible
+# floating-point results.
+#
+ifeq ($(PLATFORM),linux)
+  # Turn all optimizations off
+  OPTIMIZATION_LEVEL = NONE
+endif
+
+#
 # Include path.
 #
 OTHER_INCLUDES = -I$(FDLIBM_SRC)/include
@@ -71,15 +81,6 @@
 include $(BUILDDIR)/common/Library.gmk
 
 #
-# Disable optimization to get correctly reproducible 
-# floating-point results.
-#
-ifeq ($(PLATFORM),linux)
-  # Turn all optimizations off
-  _OPT = $(CC_NO_OPT)
-endif
-
-#
 # Find fdlibm source files.
 #
 vpath %.c
--- a/make/java/java_hprof_demo/Makefile	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/java/java_hprof_demo/Makefile	Wed Jul 30 19:40:57 2008 -0700
@@ -28,14 +28,14 @@
 PRODUCT = sun
 LIBRARY_OUTPUT = hprof_jvmti
 
+# Use highest optimization
+OPTIMIZATION_LEVEL = HIGHEST
+
 # Configure the CFLAGS for this library.
-
 FILES_m = mapfile-vers
 
 include $(BUILDDIR)/common/Defs.gmk
 
-_OPT=$(CC_HIGHEST_OPT)
-
 SRCDIR=$(SHARE_SRC)/demo/jvmti/hprof
 PSRCDIR=$(PLATFORM_SRC)/demo/jvmti/hprof
 
--- a/make/sun/awt/Makefile	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/sun/awt/Makefile	Wed Jul 30 19:40:57 2008 -0700
@@ -28,18 +28,14 @@
 LIBRARY = awt
 PRODUCT = sun
 
-#
 # Tell Defs.gmk that VIS is needed
-#
 VIS_NEEDED=true
 
+# Use highest optimization level
+OPTMIZATION_LEVEL = HIGHEST
+
 include $(BUILDDIR)/common/Defs.gmk
 
-#
-# Use highest optimization level
-#
-_OPT = $(CC_HIGHEST_OPT)
-
 OTHER_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES
 
 #
--- a/make/sun/font/Makefile	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/sun/font/Makefile	Wed Jul 30 19:40:57 2008 -0700
@@ -35,6 +35,9 @@
 # Indicate we want the C++ compiler to do the linking.
 CPLUSPLUSLIBRARY=true
 
+# Use higher optimization level
+OPTIMIZATION_LEVEL = HIGHER
+
 include $(BUILDDIR)/common/Defs.gmk
 
 #
@@ -48,11 +51,6 @@
 # Files
 #
 
-#
-# Use higher optimization level
-#
-_OPT = $(CC_HIGHER_OPT)
-
 include FILES_c.gmk
 
 AUTO_FILES_JAVA_DIRS = sun/font
--- a/make/sun/font/t2k/Makefile	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/sun/font/t2k/Makefile	Wed Jul 30 19:40:57 2008 -0700
@@ -41,14 +41,12 @@
 # for a few ones with native methods) so shouldn't clobber them.
 DONT_CLOBBER_CLASSES=true
 
+# Use higher optimization level
+OPTIMIZATION_LEVEL = HIGHER
+
 include $(BUILDDIR)/common/Defs.gmk
 
 #
-# Use higher optimization level
-#
-_OPT = $(CC_HIGHER_OPT)
-
-#
 # Files
 #
 include FILES_c.gmk
--- a/make/sun/image/generic/Makefile	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/sun/image/generic/Makefile	Wed Jul 30 19:40:57 2008 -0700
@@ -31,14 +31,13 @@
 PACKAGE = sun.awt.medialib
 LIBRARY = mlib_image
 PRODUCT = sun
+
+# Use highest level of optimization on this library
+OPTIMIZATION_LEVEL = HIGHEST
+
 include $(BUILDDIR)/common/Defs.gmk
 
 #
-# Use highest level of optimization on this library
-#
-_OPT = $(CC_HIGHEST_OPT)
-
-#
 # Use mapfile
 #
 FILES_m = mapfile-vers
--- a/make/sun/image/vis/Makefile	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/sun/image/vis/Makefile	Wed Jul 30 19:40:57 2008 -0700
@@ -31,19 +31,15 @@
 LIBRARY = mlib_image_v
 PRODUCT = sun
 
-#
 # Tell Defs.gmk we need VIS instructions
-#
 VIS_NEEDED=true
 
+# Select highest level of optimization for this library
+OPTIMIZATION_LEVEL = HIGHEST
+
 include $(BUILDDIR)/common/Defs.gmk
 
 #
-# Select highest level of optimization for this library
-#
-_OPT = $(CC_HIGHEST_OPT)
-
-#
 # Use generic mapfile
 #
 FILES_m = ../generic/mapfile-vers
--- a/make/sun/jpeg/Makefile	Wed Jul 09 10:04:09 2008 -0700
+++ b/make/sun/jpeg/Makefile	Wed Jul 30 19:40:57 2008 -0700
@@ -27,14 +27,13 @@
 PACKAGE = sun.awt
 LIBRARY = jpeg
 PRODUCT = sun
+
+# Use highest optimization level
+OPTIMIZATION_LEVEL = HIGHEST
+
 include $(BUILDDIR)/common/Defs.gmk
 
 #
-# Use highest optimization level
-#
-_OPT = $(CC_HIGHEST_OPT)
-
-#
 # Files
 #
 include FILES_c.gmk