common/autoconf/toolchain.m4
changeset 17664 2cb42641740b
parent 17593 de6741d8a142
child 18020 eade0d9836bf
equal deleted inserted replaced
17663:d2ae6f7a7e7b 17664:2cb42641740b
    34     # Make sure we use the Sun Studio compiler and not gcc on Solaris, which won't work
    34     # Make sure we use the Sun Studio compiler and not gcc on Solaris, which won't work
    35     COMPILER_VERSION_TEST=`$COMPILER -V 2>&1 | $HEAD -n 1`
    35     COMPILER_VERSION_TEST=`$COMPILER -V 2>&1 | $HEAD -n 1`
    36     $ECHO $COMPILER_VERSION_TEST | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
    36     $ECHO $COMPILER_VERSION_TEST | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
    37     if test $? -ne 0; then
    37     if test $? -ne 0; then
    38       GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
    38       GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
    39       
    39 
    40       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler.])
    40       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler.])
    41       AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_TEST" and with --version: "$GCC_VERSION_TEST"])
    41       AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_TEST" and with --version: "$GCC_VERSION_TEST"])
    42       AC_MSG_ERROR([Sun Studio compiler is required. Try setting --with-tools-dir.])
    42       AC_MSG_ERROR([Sun Studio compiler is required. Try setting --with-tools-dir.])
    43     else
    43     else
    44       COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/p"`
    44       COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/p"`
    67     if test $? -ne 0; then
    67     if test $? -ne 0; then
    68       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler.])
    68       AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler.])
    69       AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"])
    69       AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"])
    70       AC_MSG_ERROR([GCC compiler is required. Try setting --with-tools-dir.])
    70       AC_MSG_ERROR([GCC compiler is required. Try setting --with-tools-dir.])
    71     fi
    71     fi
    72     
    72 
    73     # First line typically looks something like:
    73     # First line typically looks something like:
    74     # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
    74     # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
    75     COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/p"`
    75     COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/p"`
    76     COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) @<:@1-9@:>@@<:@0-9.@:>@*/\1/p"`
    76     COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) @<:@1-9@:>@@<:@0-9.@:>@*/\1/p"`
    77   fi
    77   fi
   140   AC_MSG_CHECKING([resolved symbolic links for $1])
   140   AC_MSG_CHECKING([resolved symbolic links for $1])
   141   TEST_COMPILER="[$]$1"
   141   TEST_COMPILER="[$]$1"
   142   BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
   142   BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
   143   AC_MSG_RESULT([$TEST_COMPILER])
   143   AC_MSG_RESULT([$TEST_COMPILER])
   144   AC_MSG_CHECKING([if $1 is disguised ccache])
   144   AC_MSG_CHECKING([if $1 is disguised ccache])
   145   
   145 
   146   COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
   146   COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
   147   if test "x$COMPILER_BASENAME" = "xccache"; then
   147   if test "x$COMPILER_BASENAME" = "xccache"; then
   148     AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
   148     AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
   149     # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
   149     # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
   150     # We want to control ccache invocation ourselves, so ignore this cc and try
   150     # We want to control ccache invocation ourselves, so ignore this cc and try
   224                          x_libraries="$SYS_ROOT/usr/lib"
   224                          x_libraries="$SYS_ROOT/usr/lib"
   225                      fi
   225                      fi
   226                     ],
   226                     ],
   227                     [])
   227                     [])
   228 
   228 
   229 if test "x$SYS_ROOT" != "x/" ; then                    
   229 if test "x$SYS_ROOT" != "x/" ; then
   230     CFLAGS="--sysroot=$SYS_ROOT $CFLAGS"
   230     CFLAGS="--sysroot=$SYS_ROOT $CFLAGS"
   231     CXXFLAGS="--sysroot=$SYS_ROOT $CXXFLAGS"
   231     CXXFLAGS="--sysroot=$SYS_ROOT $CXXFLAGS"
   232     OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 
   232     OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS"
   233     OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 
   233     OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS"
   234     CPPFLAGS="--sysroot=$SYS_ROOT $CPPFLAGS"
   234     CPPFLAGS="--sysroot=$SYS_ROOT $CPPFLAGS"
   235     LDFLAGS="--sysroot=$SYS_ROOT $LDFLAGS"
   235     LDFLAGS="--sysroot=$SYS_ROOT $LDFLAGS"
   236 fi
   236 fi
   237 
   237 
   238 # Store the CFLAGS etal passed to the configure script.
   238 # Store the CFLAGS etal passed to the configure script.
   328 AC_SUBST(HOTSPOT_LD)
   328 AC_SUBST(HOTSPOT_LD)
   329 
   329 
   330 COMPILER_NAME=gcc
   330 COMPILER_NAME=gcc
   331 COMPILER_TYPE=CC
   331 COMPILER_TYPE=CC
   332 AS_IF([test "x$OPENJDK_TARGET_OS" = xwindows], [
   332 AS_IF([test "x$OPENJDK_TARGET_OS" = xwindows], [
   333     # For now, assume that we are always compiling using cl.exe. 
   333     # For now, assume that we are always compiling using cl.exe.
   334     CC_OUT_OPTION=-Fo
   334     CC_OUT_OPTION=-Fo
   335     EXE_OUT_OPTION=-out:
   335     EXE_OUT_OPTION=-out:
   336     LD_OUT_OPTION=-out:
   336     LD_OUT_OPTION=-out:
   337     AR_OUT_OPTION=-out:
   337     AR_OUT_OPTION=-out:
   338     # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
   338     # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
   489 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS],
   489 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS],
   490 [
   490 [
   491 
   491 
   492 ###############################################################################
   492 ###############################################################################
   493 #
   493 #
   494 # How to compile shared libraries. 
   494 # How to compile shared libraries.
   495 #
   495 #
   496 
   496 
   497 if test "x$GCC" = xyes; then
   497 if test "x$GCC" = xyes; then
   498     COMPILER_NAME=gcc
   498     COMPILER_NAME=gcc
   499     PICFLAG="-fPIC"
   499     PICFLAG="-fPIC"
   523         COMPILER_NAME=gcc
   523         COMPILER_NAME=gcc
   524         SHARED_LIBRARY='lib[$]1.dylib'
   524         SHARED_LIBRARY='lib[$]1.dylib'
   525         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
   525         SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
   526         SHARED_LIBRARY_SUFFIX='.dylib'
   526         SHARED_LIBRARY_SUFFIX='.dylib'
   527         EXE_SUFFIX=''
   527         EXE_SUFFIX=''
   528         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 
   528         SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
   529         SET_SHARED_LIBRARY_MAPFILE=''
   529         SET_SHARED_LIBRARY_MAPFILE=''
   530         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
   530         SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
   531         SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
   531         SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
   532         POST_STRIP_CMD="$STRIP -S"
   532         POST_STRIP_CMD="$STRIP -S"
   533     fi
   533     fi
   674         # Do some simplification of floating point arithmetic (not IEEE 754)
   674         # Do some simplification of floating point arithmetic (not IEEE 754)
   675         CC_HIGHEST="$CC_HIGHEST -fsimple"
   675         CC_HIGHEST="$CC_HIGHEST -fsimple"
   676         # Use single precision floating point with 'float'
   676         # Use single precision floating point with 'float'
   677         CC_HIGHEST="$CC_HIGHEST -fsingle"
   677         CC_HIGHEST="$CC_HIGHEST -fsingle"
   678         # Assume memory references via basic pointer types do not alias
   678         # Assume memory references via basic pointer types do not alias
   679         #   (Source with excessing pointer casting and data access with mixed 
   679         #   (Source with excessing pointer casting and data access with mixed
   680         #    pointer types are not recommended)
   680         #    pointer types are not recommended)
   681         CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
   681         CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
   682         # Use intrinsic or inline versions for math/std functions
   682         # Use intrinsic or inline versions for math/std functions
   683         #   (If you expect perfect errno behavior, do not use this)
   683         #   (If you expect perfect errno behavior, do not use this)
   684         CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
   684         CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
   890 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   890 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
   891     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
   891     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
   892 fi
   892 fi
   893 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   893 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
   894     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
   894     CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
   895     # Setting these parameters makes it an error to link to macosx APIs that are 
   895     # Setting these parameters makes it an error to link to macosx APIs that are
   896     # newer than the given OS version and makes the linked binaries compatible even
   896     # newer than the given OS version and makes the linked binaries compatible even
   897     # if built on a newer version of the OS.
   897     # if built on a newer version of the OS.
   898     # The expected format is X.Y.Z
   898     # The expected format is X.Y.Z
   899     MACOSX_VERSION_MIN=10.7.0
   899     MACOSX_VERSION_MIN=10.7.0
   900     AC_SUBST(MACOSX_VERSION_MIN)
   900     AC_SUBST(MACOSX_VERSION_MIN)
   938 # Now this is odd. The JDK native libraries have to link against libjvm.so
   938 # Now this is odd. The JDK native libraries have to link against libjvm.so
   939 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
   939 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
   940 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
   940 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
   941 # is identical for client and server? Yes. Which is picked at runtime (client or server)?
   941 # is identical for client and server? Yes. Which is picked at runtime (client or server)?
   942 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
   942 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
   943 # libraries will link to whatever is in memory. Yuck. 
   943 # libraries will link to whatever is in memory. Yuck.
   944 #
   944 #
   945 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
   945 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
   946 if test "x$COMPILER_NAME" = xcl; then
   946 if test "x$COMPILER_NAME" = xcl; then
   947     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
   947     LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
   948     if test "x$OPENJDK_TARGET_CPU" = xx86; then 
   948     if test "x$OPENJDK_TARGET_CPU" = xx86; then
   949         LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
   949         LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
   950     fi
   950     fi
   951     # TODO: make -debug optional "--disable-full-debug-symbols"
   951     # TODO: make -debug optional "--disable-full-debug-symbols"
   952     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
   952     LDFLAGS_JDK="$LDFLAGS_JDK -debug"
   953     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
   953     LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
   963         # If this is a --hash-style=gnu system, use --hash-style=both, why?
   963         # If this is a --hash-style=gnu system, use --hash-style=both, why?
   964         HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
   964         HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
   965         if test -n "$HAS_GNU_HASH"; then
   965         if test -n "$HAS_GNU_HASH"; then
   966             LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
   966             LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
   967         fi
   967         fi
   968         if test "x$OPENJDK_TARGET_OS" = xlinux; then 
   968         if test "x$OPENJDK_TARGET_OS" = xlinux; then
   969           # And since we now know that the linker is gnu, then add -z defs, to forbid
   969           # And since we now know that the linker is gnu, then add -z defs, to forbid
   970           # undefined symbols in object files.
   970           # undefined symbols in object files.
   971           LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
   971           LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
   972           if test "x$DEBUG_LEVEL" = "xrelease"; then
   972           if test "x$DEBUG_LEVEL" = "xrelease"; then
   973               # When building release libraries, tell the linker optimize them.
   973               # When building release libraries, tell the linker optimize them.
  1004     fi
  1004     fi
  1005 fi
  1005 fi
  1006 
  1006 
  1007 # Adjust flags according to debug level.
  1007 # Adjust flags according to debug level.
  1008 case $DEBUG_LEVEL in
  1008 case $DEBUG_LEVEL in
  1009       fastdebug ) 
  1009       fastdebug )
  1010               CFLAGS="$CFLAGS $D_FLAG"
  1010               CFLAGS="$CFLAGS $D_FLAG"
  1011               JAVAC_FLAGS="$JAVAC_FLAGS -g"
  1011               JAVAC_FLAGS="$JAVAC_FLAGS -g"
  1012               ;;
  1012               ;;
  1013       slowdebug )
  1013       slowdebug )
  1014               CFLAGS="$CFLAGS $D_FLAG"
  1014               CFLAGS="$CFLAGS $D_FLAG"
  1016 	      C_O_FLAG_NORM="$C_O_FLAG_NONE"
  1016 	      C_O_FLAG_NORM="$C_O_FLAG_NONE"
  1017 	      CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
  1017 	      CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
  1018 	      CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
  1018 	      CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
  1019               JAVAC_FLAGS="$JAVAC_FLAGS -g"
  1019               JAVAC_FLAGS="$JAVAC_FLAGS -g"
  1020               ;;
  1020               ;;
  1021 esac              
  1021 esac
  1022 
  1022 
  1023                 
  1023 
  1024 AC_SUBST(CFLAGS_JDKLIB)
  1024 AC_SUBST(CFLAGS_JDKLIB)
  1025 AC_SUBST(CFLAGS_JDKEXE)
  1025 AC_SUBST(CFLAGS_JDKEXE)
  1026 
  1026 
  1027 AC_SUBST(CXXFLAGS_JDKLIB)
  1027 AC_SUBST(CXXFLAGS_JDKLIB)
  1028 AC_SUBST(CXXFLAGS_JDKEXE)
  1028 AC_SUBST(CXXFLAGS_JDKEXE)
  1090     [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
  1090     [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
  1091     [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
  1091     [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
  1092   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
  1092   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
  1093 ])
  1093 ])
  1094 
  1094 
  1095 # Setup the JTREG paths 
  1095 # Setup the JTREG paths
  1096 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], 
  1096 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
  1097 [ 
  1097 [
  1098   AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], 
  1098   AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
  1099   [Regression Test Harness @<:@probed@:>@])]) 
  1099   [Regression Test Harness @<:@probed@:>@])],
  1100  
  1100   [],
  1101   AC_MSG_CHECKING([for JTReg Regression Test Harness]) 
  1101   [with_jtreg=no])
  1102  
  1102 
  1103   if test "x$with_jtreg" != x; then 
  1103   if test "x$with_jtreg" = xno; then
  1104     JT_HOME="$with_jtreg"
  1104     # jtreg disabled
  1105     BASIC_FIXUP_PATH([JT_HOME])
  1105     AC_MSG_CHECKING([for jtreg])
  1106     AC_MSG_RESULT($JT_HOME)
       
  1107  
       
  1108     # jtreg win32 script works for everybody 
       
  1109     JTREGEXE="$JT_HOME/win32/bin/jtreg"
       
  1110     if test ! -f "$JTREGEXE"; then
       
  1111       AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
       
  1112     fi
       
  1113   else 
       
  1114     AC_MSG_RESULT(no)
  1106     AC_MSG_RESULT(no)
  1115   fi 
  1107   else
  1116  
  1108     if test "x$with_jtreg" != xyes; then
  1117   AC_SUBST(JT_HOME) 
  1109       # with path specified.
  1118   AC_SUBST(JTREGEXE) 
  1110       JT_HOME="$with_jtreg"
       
  1111     fi
       
  1112 
       
  1113     if test "x$JT_HOME" != x; then
       
  1114       AC_MSG_CHECKING([for jtreg])
       
  1115 
       
  1116       # use JT_HOME enviroment var.
       
  1117       BASIC_FIXUP_PATH([JT_HOME])
       
  1118 
       
  1119       # jtreg win32 script works for everybody
       
  1120       JTREGEXE="$JT_HOME/win32/bin/jtreg"
       
  1121 
       
  1122       if test ! -f "$JTREGEXE"; then
       
  1123         AC_MSG_ERROR([JTReg executable does not exist: $JTREGEXE])
       
  1124       fi
       
  1125 
       
  1126       AC_MSG_RESULT($JTREGEXE)
       
  1127     else
       
  1128       # try to find jtreg on path
       
  1129       BASIC_REQUIRE_PROG(JTREGEXE, jtreg)
       
  1130       JT_HOME="`$DIRNAME $JTREGEXE`"
       
  1131     fi
       
  1132   fi
       
  1133 
       
  1134   AC_SUBST(JT_HOME)
       
  1135   AC_SUBST(JTREGEXE)
  1119 ])
  1136 ])