common/autoconf/toolchain.m4
changeset 13697 5262b00bc10c
parent 13133 701e61c32ece
child 14111 2a82ecb35fc7
--- a/common/autoconf/toolchain.m4	Wed Jul 05 18:22:17 2017 +0200
+++ b/common/autoconf/toolchain.m4	Tue Sep 18 11:29:16 2012 -0700
@@ -31,6 +31,19 @@
 # the set env variables into the spec file.
 SETUPDEVENV="# No special vars"
 if test "x$OPENJDK_BUILD_OS" = "xwindows"; then
+    # Store path to cygwin link.exe to help excluding it when searching for 
+    # VS linker.
+    AC_PATH_PROG(CYGWIN_LINK, link)
+    AC_MSG_CHECKING([if the first found link.exe is actually the Cygwin link tool])
+    "$CYGWIN_LINK" --version > /dev/null
+    if test $? -eq 0 ; then
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no])
+      # This might be the VS linker. Don't exclude it later on.
+      CYGWIN_LINK=""
+    fi
+    
     # If vcvarsall.bat has been run, then VCINSTALLDIR is set.
     if test "x$VCINSTALLDIR" != x; then
         # No further setup is needed. The build will happen from this kind
@@ -57,12 +70,12 @@
             AC_MSG_RESULT([no])
             AC_MSG_ERROR([Tried to find a VS installation using both $SEARCH_ROOT but failed. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.])
         fi
-        case "$LEGACY_OPENJDK_TARGET_CPU1" in
-          i?86)
+        case "$OPENJDK_TARGET_CPU" in
+          x86)
             VARSBAT_ARCH=x86
             ;;
-          *)
-            VARSBAT_ARCH=$LEGACY_OPENJDK_TARGET_CPU1
+          x86_64)
+            VARSBAT_ARCH=amd64
             ;;
         esac
         # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat
@@ -122,9 +135,6 @@
 # Configure the development tool paths and potential sysroot.
 #
 AC_LANG(C++)
-DEVKIT=
-SYS_ROOT=/
-AC_SUBST(SYS_ROOT)
 
 # The option used to specify the target .o,.a or .so file.
 # When compiling, how to specify the to be created object file.
@@ -153,44 +163,28 @@
 # Setting only --host, does not seem to be really supported.
 # Please set both --build and --host if you want to cross compile.
 
-DEFINE_CROSS_COMPILE_ARCH=""
-HOSTCC=""
-HOSTCXX=""
-HOSTLD=""
-AC_SUBST(DEFINE_CROSS_COMPILE_ARCH)
-AC_MSG_CHECKING([if this is a cross compile])
-if test "x$OPENJDK_BUILD_SYSTEM" != "x$OPENJDK_TARGET_SYSTEM"; then
-    AC_MSG_RESULT([yes, from $OPENJDK_BUILD_SYSTEM to $OPENJDK_TARGET_SYSTEM])
-    # We have detected a cross compile!
-    DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$LEGACY_OPENJDK_TARGET_CPU1"
+if test "x$COMPILE_TYPE" = "xcross"; then
     # Now we to find a C/C++ compiler that can build executables for the build
     # platform. We can't use the AC_PROG_CC macro, since it can only be used
-    # once.
-    AC_PATH_PROGS(HOSTCC, [cl cc gcc])
-    WHICHCMD(HOSTCC)
-    AC_PATH_PROGS(HOSTCXX, [cl CC g++])
-    WHICHCMD(HOSTCXX)
-    AC_PATH_PROG(HOSTLD, ld)
-    WHICHCMD(HOSTLD)
-    # Building for the build platform should be easy. Therefore
-    # we do not need any linkers or assemblers etc.    
-else
-    AC_MSG_RESULT([no])
+    # once. Also, we need to do this before adding a tools dir to the path,
+    # otherwise we might pick up cross-compilers which don't use standard naming.
+    # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
+    # to wait until they are properly discovered.
+    AC_PATH_PROGS(BUILD_CC, [cl cc gcc])
+    SET_FULL_PATH(BUILD_CC)
+    AC_PATH_PROGS(BUILD_CXX, [cl CC g++])
+    SET_FULL_PATH(BUILD_CXX)
+    AC_PATH_PROG(BUILD_LD, ld)
+    SET_FULL_PATH(BUILD_LD)
 fi
+AC_SUBST(BUILD_CC)
+AC_SUBST(BUILD_CXX)
+AC_SUBST(BUILD_LD)
 
-# You can force the sys-root if the sys-root encoded into the cross compiler tools
-# is not correct.
-AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root],
-    [pass this sys-root to the compilers and linker (useful if the sys-root encoded in
-     the cross compiler tools is incorrect)])])
-
-if test "x$with_sys_root" != x; then
-    SYS_ROOT=$with_sys_root
-fi
-                     
 # If a devkit is found on the builddeps server, then prepend its path to the
 # PATH variable. If there are cross compilers available in the devkit, these
 # will be found by AC_PROG_CC et al.
+DEVKIT=
 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
                     [# Found devkit
                      PATH="$DEVKIT/bin:$PATH"
@@ -218,21 +212,6 @@
 ORG_CXXFLAGS="$CXXFLAGS"
 ORG_OBJCFLAGS="$OBJCFLAGS"
 
-AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir],
-	[search this directory for compilers and tools])], [TOOLS_DIR=$with_tools_dir])
-
-AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit],
-	[use this directory as base for tools-dir and sys-root])], [
-    if test "x$with_sys_root" != x; then
-      AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time])
-    fi
-    if test "x$with_tools_dir" != x; then
-      AC_MSG_ERROR([Cannot specify both --with-devkit and --with-tools-dir at the same time])
-    fi
-    TOOLS_DIR=$with_devkit/bin
-    SYS_ROOT=$with_devkit/$host_alias/libc
-    ])
-
 # autoconf magic only relies on PATH, so update it if tools dir is specified
 OLD_PATH="$PATH"
 if test "x$TOOLS_DIR" != x; then
@@ -251,7 +230,7 @@
     # Do not use cc on MacOSX use gcc instead.
     CC="gcc"
 fi
-WHICHCMD(CC)
+SET_FULL_PATH(CC)
 
 AC_PROG_CXX([cl CC g++])
 if test "x$CXX" = xCC && test "x$OPENJDK_BUILD_OS" = xmacosx; then
@@ -259,7 +238,7 @@
     # c++ code. Override.
     CXX="g++"
 fi
-WHICHCMD(CXX)
+SET_FULL_PATH(CXX)
 
 if test "x$CXX" = x || test "x$CC" = x; then
     HELP_MSG_MISSING_DEPENDENCY([devkit])
@@ -268,7 +247,7 @@
 
 if test "x$OPENJDK_BUILD_OS" != xwindows; then
     AC_PROG_OBJC
-    WHICHCMD(OBJC)
+    SET_FULL_PATH(OBJC)
 else
     OBJC=
 fi
@@ -279,19 +258,11 @@
 CXXFLAGS="$ORG_CXXFLAGS"
 OBJCFLAGS="$ORG_OBJCFLAGS"
 
-# If we are not cross compiling, use the same compilers for
-# building the build platform executables.
-if test "x$DEFINE_CROSS_COMPILE_ARCH" = x; then
-    HOSTCC="$CC"
-    HOSTCXX="$CXX"
-fi
-
-AC_CHECK_TOOL(LD, ld)
-WHICHCMD(LD)
 LD="$CC"
 LDEXE="$CC"
 LDCXX="$CXX"
 LDEXECXX="$CXX"
+AC_SUBST(LD)
 # LDEXE is the linker to use, when creating executables.
 AC_SUBST(LDEXE)
 # Linking C++ libraries.
@@ -299,8 +270,10 @@
 # Linking C++ executables.
 AC_SUBST(LDEXECXX)
 
-AC_CHECK_TOOL(AR, ar)
-WHICHCMD(AR)
+if test "x$OPENJDK_BUILD_OS" != xwindows; then
+    AC_CHECK_TOOL(AR, ar)
+    SET_FULL_PATH(AR)
+fi
 if test "x$OPENJDK_BUILD_OS" = xmacosx; then
     ARFLAGS="-r"
 else
@@ -316,25 +289,31 @@
     EXE_OUT_OPTION=-out:
     LD_OUT_OPTION=-out:
     AR_OUT_OPTION=-out:
-    # On Windows, reject /usr/bin/link, which is a cygwin
+    # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
     # program for something completely different.
-    AC_CHECK_PROG([WINLD], [link],[link],,, [/usr/bin/link])
+    AC_CHECK_PROG([WINLD], [link],[link],,, [$CYGWIN_LINK])
     # Since we must ignore the first found link, WINLD will contain
     # the full path to the link.exe program.
-    WHICHCMD_SPACESAFE([WINLD])
+    SET_FULL_PATH_SPACESAFE([WINLD])
+    printf "Windows linker was found at $WINLD\n"
+    AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
+    "$WINLD" --version > /dev/null
+    if test $? -eq 0 ; then
+      AC_MSG_RESULT([no])
+      AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
+    else
+      AC_MSG_RESULT([yes])
+    fi
     LD="$WINLD"
     LDEXE="$WINLD"
     LDCXX="$WINLD"
     LDEXECXX="$WINLD"
-    # Set HOSTLD to same as LD until we fully support cross compilation
-    # on windows.
-    HOSTLD="$WINLD"
 
     AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
-    WHICHCMD_SPACESAFE([MT])
+    SET_FULL_PATH_SPACESAFE([MT])
     # The resource compiler
     AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
-    WHICHCMD_SPACESAFE([RC])
+    SET_FULL_PATH_SPACESAFE([RC])
 
     RC_FLAGS="-nologo /l 0x409 /r"
     AS_IF([test "x$VARIANT" = xOPT], [
@@ -354,12 +333,12 @@
 
     # lib.exe is used to create static libraries.
     AC_CHECK_PROG([WINAR], [lib],[lib],,,)
-    WHICHCMD_SPACESAFE([WINAR])
+    SET_FULL_PATH_SPACESAFE([WINAR])
     AR="$WINAR"
     ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
 
     AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
-    WHICHCMD_SPACESAFE([DUMPBIN])
+    SET_FULL_PATH_SPACESAFE([DUMPBIN])
 
     COMPILER_TYPE=CL
     CCXXFLAGS="$CCXXFLAGS -nologo"
@@ -368,10 +347,20 @@
 AC_SUBST(COMPILER_TYPE)
 
 AC_PROG_CPP
-WHICHCMD(CPP)
+SET_FULL_PATH(CPP)
 
 AC_PROG_CXXCPP
-WHICHCMD(CXXCPP)
+SET_FULL_PATH(CXXCPP)
+
+if test "x$COMPILE_TYPE" != "xcross"; then
+    # If we are not cross compiling, use the same compilers for
+    # building the build platform executables. The cross-compilation
+    # case needed to be done earlier, but this can only be done after
+    # the native tools have been localized.
+    BUILD_CC="$CC"
+    BUILD_CXX="$CXX"
+    BUILD_LD="$LD"
+fi
 
 # for solaris we really need solaris tools, and not gnu equivalent
 #   these seems to normally reside in /usr/ccs/bin so add that to path before
@@ -386,27 +375,24 @@
 # Find the right assembler.
 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
     AC_PATH_PROG(AS, as)
-    WHICHCMD(AS)
-    ASFLAGS=" "
+    SET_FULL_PATH(AS)
 else
     AS="$CC -c"
-    ASFLAGS=" "
 fi
 AC_SUBST(AS)
-AC_SUBST(ASFLAGS)
 
 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
-    AC_PATH_PROG(NM, nm)
-    WHICHCMD(NM)
+    AC_PATH_PROGS(NM, [gnm nm])
+    SET_FULL_PATH(NM)
     AC_PATH_PROG(STRIP, strip)
-    WHICHCMD(STRIP)
+    SET_FULL_PATH(STRIP)
     AC_PATH_PROG(MCS, mcs)
-    WHICHCMD(MCS)
-else
+    SET_FULL_PATH(MCS)
+elif test "x$OPENJDK_BUILD_OS" != xwindows; then
     AC_CHECK_TOOL(NM, nm)
-    WHICHCMD(NM)
+    SET_FULL_PATH(NM)
     AC_CHECK_TOOL(STRIP, strip)
-    WHICHCMD(STRIP)
+    SET_FULL_PATH(STRIP)
 fi
 
 ###
@@ -421,6 +407,11 @@
    AC_PATH_TOOL(OBJCOPY, objcopy)
 fi
 
+if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+   AC_PATH_PROG(LIPO, lipo)
+   SET_FULL_PATH(LIPO)
+fi
+
 # Restore old path without tools dir
 PATH="$OLD_PATH"
 ])
@@ -449,15 +440,13 @@
     SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
     C_FLAG_REORDER=''
     CXX_FLAG_REORDER=''
-    SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN/[$]1'
+    SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
+    SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
     LD="$CC"
     LDEXE="$CC"
     LDCXX="$CXX"
     LDEXECXX="$CXX"
     POST_STRIP_CMD="$STRIP -g"
-    if test "x$JDK_VARIANT" = xembedded; then
-        POST_STRIP_CMD="$STRIP --strip-unneeded"
-    fi
 
     # Linking is different on MacOSX
     if test "x$OPENJDK_BUILD_OS" = xmacosx; then
@@ -470,6 +459,7 @@
         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 
         SET_SHARED_LIBRARY_MAPFILE=''
         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
+        SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
         POST_STRIP_CMD="$STRIP -S"
     fi
 else
@@ -480,7 +470,7 @@
         LIBRARY_PREFIX=lib
         SHARED_LIBRARY='lib[$]1.so'
         STATIC_LIBRARY='lib[$]1.a'
-        SHARED_LIBRARY_FLAGS="-z defs -xildoff -ztext -G"
+        SHARED_LIBRARY_FLAGS="-G"
         SHARED_LIBRARY_SUFFIX='.so'
         STATIC_LIBRARY_SUFFIX='.a'
         OBJ_SUFFIX='.o'
@@ -489,7 +479,8 @@
         SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
 	C_FLAG_REORDER='-xF'
 	CXX_FLAG_REORDER='-xF'
-        SET_SHARED_LIBRARY_ORIGIN='-R \$$$$ORIGIN/[$]1'
+        SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN[$]1'
+        SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
         CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
         CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
         CFLAGS_JDKLIB_EXTRA='-xstrconst'
@@ -511,6 +502,7 @@
         SET_SHARED_LIBRARY_NAME=''
         SET_SHARED_LIBRARY_MAPFILE=''
         SET_SHARED_LIBRARY_ORIGIN=''
+        SET_EXECUTABLE_ORIGIN=''
     fi
 fi
 
@@ -527,6 +519,7 @@
 AC_SUBST(C_FLAG_REORDER)
 AC_SUBST(CXX_FLAG_REORDER)
 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
+AC_SUBST(SET_EXECUTABLE_ORIGIN)
 AC_SUBST(POST_STRIP_CMD)
 AC_SUBST(POST_MCS_CMD)
 
@@ -542,6 +535,25 @@
 # Setup the opt flags for different compilers
 # and different operating systems.
 #
+
+#
+# NOTE: check for -mstackrealign needs to be below potential addition of -m32
+#
+if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
+    # While waiting for a better solution, the current workaround is to use -mstackrealign.
+    CFLAGS="$CFLAGS -mstackrealign"
+    AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
+    AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
+                   [
+		        AC_MSG_RESULT([yes])
+                   ],
+	           [
+		        AC_MSG_RESULT([no])
+	                AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
+	           ])
+fi
+
 C_FLAG_DEPS="-MMD -MF"
 CXX_FLAG_DEPS="-MMD -MF"
 
@@ -566,7 +578,7 @@
 	    CXXFLAGS_DEBUG_SYMBOLS="-g"
 	    if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
 	       CFLAGS_DEBUG_SYMBOLS="-g1"
-	       CXXFLAGS_DEBUG_SYMBOLSG="-g1"
+	       CXXFLAGS_DEBUG_SYMBOLS="-g1"
 	    fi
 	    ;;
 	esac
@@ -578,52 +590,56 @@
         #
         # Forte has different names for this with their C++ compiler...
         #
-	C_FLAG_DEPS="-xMMD -xMF"
-	CXX_FLAG_DEPS="-xMMD -xMF"
+        C_FLAG_DEPS="-xMMD -xMF"
+        CXX_FLAG_DEPS="-xMMD -xMF"
 
-# Extra options used with HIGHEST
-#
-# 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="$CC_HIGHEST -fns"
-# Do some simplification of floating point arithmetic (not IEEE 754)
-CC_HIGHEST="$CC_HIGHEST -fsimple"
-# Use single precision floating point with 'float'
-CC_HIGHEST="$CC_HIGHEST -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="$CC_HIGHEST -xalias_level=basic"
-# Use intrinsic or inline versions for math/std functions
-#   (If you expect perfect errno behavior, do not use this)
-CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
-# Loop data dependency optimizations (need -xO3 or higher)
-CC_HIGHEST="$CC_HIGHEST -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="$CC_HIGHEST -xrestrict"
-# Inline some library routines
-#   (If you expect perfect errno behavior, do not use this)
-CC_HIGHEST="$CC_HIGHEST -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="$CC_HIGHEST -xlibmopt"
+        # Extra options used with HIGHEST
+        #
+        # 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="$CC_HIGHEST -fns"
+        # Do some simplification of floating point arithmetic (not IEEE 754)
+        CC_HIGHEST="$CC_HIGHEST -fsimple"
+        # Use single precision floating point with 'float'
+        CC_HIGHEST="$CC_HIGHEST -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="$CC_HIGHEST -xalias_level=basic"
+        # Use intrinsic or inline versions for math/std functions
+        #   (If you expect perfect errno behavior, do not use this)
+        CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
+        # Loop data dependency optimizations (need -xO3 or higher)
+        CC_HIGHEST="$CC_HIGHEST -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="$CC_HIGHEST -xrestrict"
+        # Inline some library routines
+        #   (If you expect perfect errno behavior, do not use this)
+        CC_HIGHEST="$CC_HIGHEST -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="$CC_HIGHEST -xlibmopt"
 
-        case $LEGACY_OPENJDK_TARGET_CPU1 in
-          i586)
-            C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xchip=pentium"
-            C_O_FLAG_HI="-xO4 -Wu,-O4~yz"
-            C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
-            C_O_FLAG_NONE=""
-            CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xchip=pentium"
-            CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz"
-            CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz"
-            CXX_O_FLAG_NONE=""
+        case $OPENJDK_TARGET_CPU_ARCH in
+          x86)
+            C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
+            C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
+            C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
+            C_O_FLAG_NONE="-xregs=no%frameptr"
+            CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
+            CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
+            CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
+            CXX_O_FLAG_NONE="-xregs=no%frameptr"
+            if test "x$OPENJDK_TARGET_CPU" = xx86; then
+               C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
+               CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
+            fi
             ;;
           sparc)
             CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
@@ -647,9 +663,11 @@
     ;;
   CL )
     D_FLAG=
-    C_O_FLAG_HI="-O2"
+    C_O_FLAG_HIGHEST="-O2"
+    C_O_FLAG_HI="-O1"
     C_O_FLAG_NORM="-O1"
     C_O_FLAG_NONE="-Od"
+    CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
     CXX_O_FLAG_HI="$C_O_FLAG_HI"
     CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
     CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
@@ -680,15 +698,15 @@
 [
 
 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
-   AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags"])
+   AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
 fi
 
 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
-   AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags"])
+   AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
 fi
 
 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
-   AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags"])
+   AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
 fi
 
 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
@@ -704,6 +722,15 @@
 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
 
+# Hotspot needs these set in their legacy form
+LEGACY_EXTRA_CFLAGS=$with_extra_cflags
+LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
+LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
+
+AC_SUBST(LEGACY_EXTRA_CFLAGS)
+AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
+AC_SUBST(LEGACY_EXTRA_LDFLAGS)
+
 ###############################################################################
 #
 # Now setup the CFLAGS and LDFLAGS for the JDK build.
@@ -729,19 +756,30 @@
 	  esac
           ;;
       ossc )
-      	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -norunpath -xnolib"
-      	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX"
+          CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
+          case $OPENJDK_TARGET_CPU_ARCH in
+          x86 )
+            CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -Di386"
+       	    CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
+          ;;
+          esac
+
+      	  CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
+      	  CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
+
+          LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
+          LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
           ;;
       cl )
           CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
                -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
 	       -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
 	       -DWIN32 -DIAL"
-          case $LEGACY_OPENJDK_TARGET_CPU1 in
-              i?86 )
+          case $OPENJDK_TARGET_CPU in
+              x86 )
                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
                   ;;
-              amd64 )
+              x86_64 )
                   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
                   ;;
           esac
@@ -749,24 +787,6 @@
 esac
 
 ###############################################################################
-#
-# Cross-compile arch specific flags
-
-#
-if test "x$JDK_VARIANT" = "xembedded"; then
-   CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DJAVASE_EMBEDDED"
-fi
-
-case $OPENJDK_TARGET_CPU_ARCH in
-arm )
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
-    ;;
-ppc )
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char"
-    ;;
-esac
-
-###############################################################################
 
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
 
@@ -774,11 +794,17 @@
 PACKAGE_PATH=/opt/local
 AC_SUBST(PACKAGE_PATH)
 
-# Sometimes we use a cpu dir (.../lib/amd64/server) 
-# Sometimes not (.../lib/server) 
-LIBARCHDIR="$LEGACY_OPENJDK_TARGET_CPU2/"
-if test "x$ENDIAN" = xlittle; then
-    CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
+if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
+    # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
+    #   Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
+    #   (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
+    #   Note: -Dmacro         is the same as    #define macro 1
+    #         -Dmacro=	    is the same as    #define macro
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
+    else
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
+    fi
 else
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
 fi
@@ -793,27 +819,29 @@
 fi
 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
-    LIBARCHDIR=""
 fi
 if test "x$OPENJDK_TARGET_OS" = xbsd; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
 fi
 if test "x$DEBUG_LEVEL" = xrelease; then
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
+    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
+        CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
+    fi
 else
     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
 fi
 
-CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$LEGACY_OPENJDK_TARGET_CPU1\"' -D$LEGACY_OPENJDK_TARGET_CPU1"
+CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
 
 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
         -I${JDK_OUTPUTDIR}/include \
         -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
         -I${JDK_TOPDIR}/src/share/javavm/export \
-        -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/javavm/export \
+        -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/javavm/export \
         -I${JDK_TOPDIR}/src/share/native/common \
-        -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/native/common"
+        -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
 
 # The shared libraries are compiled using the picflag.
 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
@@ -833,7 +861,7 @@
 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
 if test "x$COMPILER_TYPE" = xCL; then
     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
-    if test "x$LEGACY_OPENJDK_TARGET_CPU1" = xi586; then 
+    if test "x$OPENJDK_TARGET_CPU" = xx86; then 
         LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
     fi
     # TODO: make -debug optional "--disable-full-debug-symbols"
@@ -861,20 +889,18 @@
     fi
 
     LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
-                    -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}server \
-                    -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}client \
-  	            -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}"
-    LDFLAGS_JDKLIB_SUFFIX="-ljvm -ljava"
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server \
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client \
+                    -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
+
+    LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
     if test "x$COMPILER_NAME" = xossc; then
         LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
     fi
 
-    # Only the jli library is explicitly linked when the launchers are built.
-    # The libjvm is then dynamically loaded/linked by the launcher.
     LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
-    if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then
-       LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}jli"
-       LDFLAGS_JDKEXE_SUFFIX="-ljli"
+    if test "x$OPENJDK_TARGET_OS" = xlinux; then
+        LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
     fi
 fi
 
@@ -905,4 +931,5 @@
 AC_SUBST(LDFLAGS_JDKEXE)
 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
+AC_SUBST(LDFLAGS_CXX_JDK)
 ])