common/autoconf/toolchain.m4

Wed, 28 Nov 2012 13:48:36 +0100

author
erikj
date
Wed, 28 Nov 2012 13:48:36 +0100
changeset 519
7d7dd520ebfd
parent 517
f8b0bacd4de5
child 532
2795874efd16
permissions
-rw-r--r--

8003528: build-infra: Diffs in libjava and hotspot libs on solaris.
Summary: Linking against server jvm first if available. Adding filters and exceptions for hotspot lib compare on solaris.
Reviewed-by: ohair, ohrstrom

erikj@459 1 #
erikj@459 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
erikj@459 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@459 4 #
erikj@459 5 # This code is free software; you can redistribute it and/or modify it
erikj@459 6 # under the terms of the GNU General Public License version 2 only, as
erikj@459 7 # published by the Free Software Foundation. Oracle designates this
erikj@459 8 # particular file as subject to the "Classpath" exception as provided
erikj@459 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@459 10 #
erikj@459 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@459 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@459 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@459 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@459 15 # accompanied this code).
erikj@459 16 #
erikj@459 17 # You should have received a copy of the GNU General Public License version
erikj@459 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@459 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@459 20 #
erikj@459 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@459 22 # or visit www.oracle.com if you need additional information or have any
erikj@459 23 # questions.
erikj@459 24 #
erikj@459 25
ohair@494 26 # $1 = compiler to test (CC or CXX)
ohair@494 27 # $2 = human readable name of compiler (C or C++)
ohair@494 28 AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION],
erikj@459 29 [
ohair@494 30 COMPILER=[$]$1
ohair@494 31 COMPILER_NAME=$2
erikj@459 32
ohair@494 33 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
ohair@494 34 # Make sure we use the Sun Studio compiler and not gcc on Solaris, which won't work
ohair@494 35 COMPILER_VERSION_TEST=`$COMPILER -V 2>&1 | $HEAD -n 1`
ohair@494 36 $ECHO $COMPILER_VERSION_TEST | $GREP "^.*: Sun $COMPILER_NAME" > /dev/null
ohair@494 37 if test $? -ne 0; then
ohair@494 38 GCC_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
ohair@494 39
ohair@494 40 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required Sun Studio compiler.])
ohair@494 41 AC_MSG_NOTICE([The result from running with -V was: "$COMPILER_VERSION_TEST" and with --version: "$GCC_VERSION_TEST"])
ohair@494 42 AC_MSG_ERROR([Sun Studio compiler is required. Try setting --with-tools-dir.])
ohair@478 43 else
ohair@494 44 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*@<:@ ,\t@:>@$COMPILER_NAME@<:@ ,\t@:>@\(@<:@1-9@:>@\.@<:@0-9@:>@@<:@0-9@:>@*\).*/\1/p"`
ohair@494 45 COMPILER_VENDOR="Sun Studio"
ohair@494 46 fi
ohair@494 47 elif test "x$OPENJDK_TARGET_OS" = xwindows; then
ohair@494 48 # First line typically looks something like:
ohair@494 49 # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
ohair@494 50 COMPILER_VERSION_TEST=`$COMPILER 2>&1 | $HEAD -n 1`
ohair@494 51 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.*Version \(@<:@1-9@:>@@<:@0-9.@:>@*\) .*/\1/p"`
ohair@494 52 COMPILER_VENDOR="Microsoft CL.EXE"
ohair@494 53 COMPILER_CPU_TEST=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* for \(.*\)$/\1/p"`
ohair@494 54 if test "x$OPENJDK_TARGET_CPU" = "xx86"; then
ohair@494 55 if test "x$COMPILER_CPU_TEST" != "x80x86"; then
ohair@494 56 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "80x86".])
ohair@494 57 fi
ohair@494 58 elif test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
ohair@494 59 if test "x$COMPILER_CPU_TEST" != "xx64"; then
ohair@494 60 AC_MSG_ERROR([Target CPU mismatch. We are building for $OPENJDK_TARGET_CPU but CL is for "$COMPILER_CPU_TEST"; expected "x64".])
ohair@494 61 fi
ohair@494 62 fi
ohair@494 63 else
ohair@494 64 COMPILER_VERSION_TEST=`$COMPILER --version 2>&1 | $HEAD -n 1`
ohair@494 65 # Check that this is likely to be GCC.
ohair@494 66 $COMPILER --version 2>&1 | $GREP "Free Software Foundation" > /dev/null
ohair@494 67 if test $? -ne 0; then
ohair@494 68 AC_MSG_NOTICE([The $COMPILER_NAME compiler (located as $COMPILER) does not seem to be the required GCC compiler.])
ohair@494 69 AC_MSG_NOTICE([The result from running with --version was: "$COMPILER_VERSION_TEST"])
ohair@494 70 AC_MSG_ERROR([GCC compiler is required. Try setting --with-tools-dir.])
ohair@478 71 fi
ohair@478 72
ohair@494 73 # First line typically looks something like:
ohair@494 74 # gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
ohair@494 75 COMPILER_VERSION=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^.* \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/p"`
ohair@494 76 COMPILER_VENDOR=`$ECHO $COMPILER_VERSION_TEST | $SED -n "s/^\(.*\) @<:@1-9@:>@@<:@0-9.@:>@*/\1/p"`
ohair@494 77 fi
ohair@494 78 # This sets CC_VERSION or CXX_VERSION. (This comment is a grep marker)
ohair@494 79 $1_VERSION="$COMPILER_VERSION"
ohair@494 80 # This sets CC_VENDOR or CXX_VENDOR. (This comment is a grep marker)
ohair@494 81 $1_VENDOR="$COMPILER_VENDOR"
erikj@459 82
ohair@494 83 AC_MSG_NOTICE([Using $COMPILER_VENDOR $COMPILER_NAME compiler version $COMPILER_VERSION (located at $COMPILER)])
erikj@459 84 ])
erikj@459 85
ohair@494 86
erikj@459 87 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_SYSROOT_AND_OUT_OPTIONS],
erikj@459 88 [
erikj@459 89 ###############################################################################
erikj@459 90 #
erikj@459 91 # Configure the development tool paths and potential sysroot.
erikj@459 92 #
erikj@459 93 AC_LANG(C++)
erikj@459 94
erikj@459 95 # The option used to specify the target .o,.a or .so file.
erikj@459 96 # When compiling, how to specify the to be created object file.
erikj@459 97 CC_OUT_OPTION='-o$(SPACE)'
erikj@459 98 # When linking, how to specify the to be created executable.
erikj@459 99 EXE_OUT_OPTION='-o$(SPACE)'
erikj@459 100 # When linking, how to specify the to be created dynamically linkable library.
erikj@459 101 LD_OUT_OPTION='-o$(SPACE)'
erikj@459 102 # When archiving, how to specify the to be create static archive for object files.
erikj@459 103 AR_OUT_OPTION='rcs$(SPACE)'
erikj@459 104 AC_SUBST(CC_OUT_OPTION)
erikj@459 105 AC_SUBST(EXE_OUT_OPTION)
erikj@459 106 AC_SUBST(LD_OUT_OPTION)
erikj@459 107 AC_SUBST(AR_OUT_OPTION)
erikj@459 108 ])
erikj@459 109
ohair@494 110 # $1 = compiler to test (CC or CXX)
ohair@494 111 # $2 = human readable name of compiler (C or C++)
ohair@494 112 # $3 = list of compiler names to search for
ohair@494 113 AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
erikj@459 114 [
ohair@494 115 COMPILER_NAME=$2
ohair@494 116
ohair@494 117 # Do a first initial attempt at searching the list of compiler names.
ohair@494 118 # AC_PATH_PROGS can't be run multiple times with the same variable,
ohair@494 119 # so create a new name for this run.
ohair@494 120 AC_PATH_PROGS(POTENTIAL_$1, $3)
ohair@494 121 $1=$POTENTIAL_$1
ohair@494 122
ohair@494 123 if test "x$[$]$1" = x; then
ohair@494 124 HELP_MSG_MISSING_DEPENDENCY([devkit])
ohair@494 125 AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
ohair@494 126 fi
ohair@494 127 BASIC_FIXUP_EXECUTABLE($1)
ohair@494 128 AC_MSG_CHECKING([resolved symbolic links for $1])
ohair@494 129 TEST_COMPILER="[$]$1"
ohair@494 130 BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
ohair@494 131 AC_MSG_RESULT([$TEST_COMPILER])
ohair@494 132 AC_MSG_CHECKING([if $1 is disguised ccache])
ohair@494 133
ohair@494 134 COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
ohair@494 135 if test "x$COMPILER_BASENAME" = "xccache"; then
ohair@494 136 AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
ohair@494 137 # We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
ohair@494 138 # We want to control ccache invocation ourselves, so ignore this cc and try
ohair@494 139 # searching again.
ohair@494 140
ohair@494 141 # Remove the path to the fake ccache cc from the PATH
ohair@494 142 RETRY_COMPILER_SAVED_PATH="$PATH"
ohair@494 143 COMPILER_DIRNAME=`$DIRNAME [$]$1`
ohair@494 144 PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
ohair@494 145
ohair@494 146 # Try again looking for our compiler
ohair@494 147 AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
ohair@494 148 BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
ohair@494 149 PATH="$RETRY_COMPILER_SAVED_PATH"
ohair@494 150
ohair@494 151 AC_MSG_CHECKING([for resolved symbolic links for $1])
ohair@494 152 BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
ohair@494 153 AC_MSG_RESULT([$PROPER_COMPILER_$1])
ohair@494 154 $1="$PROPER_COMPILER_$1"
ohair@494 155 else
ohair@494 156 AC_MSG_RESULT([no, keeping $1])
ohair@494 157 $1="$TEST_COMPILER"
ohair@494 158 fi
ohair@494 159 TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME])
ohair@494 160 ])
ohair@494 161
ohair@494 162
ohair@494 163 AC_DEFUN([TOOLCHAIN_SETUP_PATHS],
ohair@494 164 [
ohair@494 165 if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
ohair@494 166 TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV
ohair@494 167 fi
ohair@494 168
ohair@494 169 AC_SUBST(MSVCR_DLL)
ohair@494 170
erikj@459 171 # If --build AND --host is set, then the configure script will find any
erikj@459 172 # cross compilation tools in the PATH. Cross compilation tools
erikj@459 173 # follows the cross compilation standard where they are prefixed with ${host}.
erikj@459 174 # For example the binary i686-sun-solaris2.10-gcc
erikj@459 175 # will cross compile for i686-sun-solaris2.10
erikj@459 176 # If neither of build and host is not set, then build=host and the
erikj@459 177 # default compiler found in the path will be used.
erikj@459 178 # Setting only --host, does not seem to be really supported.
erikj@459 179 # Please set both --build and --host if you want to cross compile.
erikj@459 180
ohair@478 181 if test "x$COMPILE_TYPE" = "xcross"; then
erikj@459 182 # Now we to find a C/C++ compiler that can build executables for the build
erikj@459 183 # platform. We can't use the AC_PROG_CC macro, since it can only be used
ohair@478 184 # once. Also, we need to do this before adding a tools dir to the path,
ohair@478 185 # otherwise we might pick up cross-compilers which don't use standard naming.
ohair@478 186 # Otherwise, we'll set the BUILD_tools to the native tools, but that'll have
ohair@478 187 # to wait until they are properly discovered.
ohair@478 188 AC_PATH_PROGS(BUILD_CC, [cl cc gcc])
ohair@494 189 BASIC_FIXUP_EXECUTABLE(BUILD_CC)
ohair@478 190 AC_PATH_PROGS(BUILD_CXX, [cl CC g++])
ohair@494 191 BASIC_FIXUP_EXECUTABLE(BUILD_CXX)
ohair@478 192 AC_PATH_PROG(BUILD_LD, ld)
ohair@494 193 BASIC_FIXUP_EXECUTABLE(BUILD_LD)
erikj@459 194 fi
ohair@478 195 AC_SUBST(BUILD_CC)
ohair@478 196 AC_SUBST(BUILD_CXX)
ohair@478 197 AC_SUBST(BUILD_LD)
erikj@459 198
erikj@459 199 # If a devkit is found on the builddeps server, then prepend its path to the
erikj@459 200 # PATH variable. If there are cross compilers available in the devkit, these
erikj@459 201 # will be found by AC_PROG_CC et al.
ohair@478 202 DEVKIT=
erikj@459 203 BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx,
erikj@459 204 [# Found devkit
erikj@459 205 PATH="$DEVKIT/bin:$PATH"
erikj@459 206 SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root"
erikj@459 207 if test "x$x_includes" = "xNONE"; then
erikj@459 208 x_includes="$SYS_ROOT/usr/include/X11"
erikj@459 209 fi
erikj@459 210 if test "x$x_libraries" = "xNONE"; then
erikj@459 211 x_libraries="$SYS_ROOT/usr/lib"
erikj@459 212 fi
erikj@459 213 ],
erikj@459 214 [])
erikj@459 215
erikj@459 216 if test "x$SYS_ROOT" != "x/" ; then
erikj@459 217 CFLAGS="--sysroot=$SYS_ROOT $CFLAGS"
erikj@459 218 CXXFLAGS="--sysroot=$SYS_ROOT $CXXFLAGS"
erikj@459 219 OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS"
erikj@459 220 OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS"
erikj@459 221 CPPFLAGS="--sysroot=$SYS_ROOT $CPPFLAGS"
erikj@459 222 LDFLAGS="--sysroot=$SYS_ROOT $LDFLAGS"
erikj@459 223 fi
erikj@459 224
erikj@459 225 # Store the CFLAGS etal passed to the configure script.
erikj@459 226 ORG_CFLAGS="$CFLAGS"
erikj@459 227 ORG_CXXFLAGS="$CXXFLAGS"
erikj@459 228 ORG_OBJCFLAGS="$OBJCFLAGS"
erikj@459 229
erikj@459 230 # autoconf magic only relies on PATH, so update it if tools dir is specified
erikj@459 231 OLD_PATH="$PATH"
erikj@459 232 if test "x$TOOLS_DIR" != x; then
erikj@459 233 PATH=$TOOLS_DIR:$PATH
erikj@459 234 fi
erikj@459 235
ohair@494 236
ohair@494 237 ### Locate C compiler (CC)
ohair@494 238
erikj@459 239 # gcc is almost always present, but on Windows we
erikj@459 240 # prefer cl.exe and on Solaris we prefer CC.
erikj@459 241 # Thus test for them in this order.
ohair@494 242 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
ohair@494 243 # Do not probe for cc on MacOSX.
ohair@494 244 COMPILER_CHECK_LIST="cl gcc"
ohair@494 245 else
ohair@494 246 COMPILER_CHECK_LIST="cl cc gcc"
erikj@459 247 fi
erikj@459 248
ohair@494 249 TOOLCHAIN_FIND_COMPILER([CC],[C],[$COMPILER_CHECK_LIST])
ohair@494 250 # Now that we have resolved CC ourself, let autoconf have it's go at it
ohair@494 251 AC_PROG_CC([$CC])
ohair@494 252
ohair@494 253 ### Locate C++ compiler (CXX)
ohair@494 254
ohair@494 255 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
ohair@494 256 # Do not probe for CC on MacOSX.
ohair@494 257 COMPILER_CHECK_LIST="cl g++"
ohair@494 258 else
ohair@494 259 COMPILER_CHECK_LIST="cl CC g++"
ohair@494 260 fi
ohair@494 261 TOOLCHAIN_FIND_COMPILER([CXX],[C++],[$COMPILER_CHECK_LIST])
ohair@494 262 # Now that we have resolved CXX ourself, let autoconf have it's go at it
ohair@494 263 AC_PROG_CXX([$CXX])
ohair@494 264
ohair@494 265 ### Locate other tools
ohair@494 266
ihse@495 267 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
erikj@459 268 AC_PROG_OBJC
ohair@494 269 BASIC_FIXUP_EXECUTABLE(OBJC)
erikj@459 270 else
erikj@459 271 OBJC=
erikj@459 272 fi
erikj@459 273
erikj@459 274 # Restore the flags to the user specified values.
erikj@459 275 # This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2"
erikj@459 276 CFLAGS="$ORG_CFLAGS"
erikj@459 277 CXXFLAGS="$ORG_CXXFLAGS"
erikj@459 278 OBJCFLAGS="$ORG_OBJCFLAGS"
erikj@459 279
erikj@459 280 LD="$CC"
erikj@459 281 LDEXE="$CC"
erikj@459 282 LDCXX="$CXX"
erikj@459 283 LDEXECXX="$CXX"
ohair@478 284 AC_SUBST(LD)
erikj@459 285 # LDEXE is the linker to use, when creating executables.
erikj@459 286 AC_SUBST(LDEXE)
erikj@459 287 # Linking C++ libraries.
erikj@459 288 AC_SUBST(LDCXX)
erikj@459 289 # Linking C++ executables.
erikj@459 290 AC_SUBST(LDEXECXX)
erikj@459 291
ohair@494 292 if test "x$OPENJDK_TARGET_OS" != xwindows; then
ohair@478 293 AC_CHECK_TOOL(AR, ar)
ohair@494 294 BASIC_FIXUP_EXECUTABLE(AR)
ohair@478 295 fi
ohair@494 296 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
erikj@459 297 ARFLAGS="-r"
erikj@459 298 else
erikj@459 299 ARFLAGS=""
erikj@459 300 fi
erikj@459 301 AC_SUBST(ARFLAGS)
erikj@459 302
ohair@494 303 # For hotspot, we need these in Windows mixed path; other platforms keep them the same
ohair@494 304 HOTSPOT_CXX="$CXX"
ohair@494 305 HOTSPOT_LD="$LD"
ohair@494 306 AC_SUBST(HOTSPOT_CXX)
ohair@494 307 AC_SUBST(HOTSPOT_LD)
ohair@494 308
erikj@459 309 COMPILER_NAME=gcc
erikj@459 310 COMPILER_TYPE=CC
ohair@494 311 AS_IF([test "x$OPENJDK_TARGET_OS" = xwindows], [
erikj@459 312 # For now, assume that we are always compiling using cl.exe.
erikj@459 313 CC_OUT_OPTION=-Fo
erikj@459 314 EXE_OUT_OPTION=-out:
erikj@459 315 LD_OUT_OPTION=-out:
erikj@459 316 AR_OUT_OPTION=-out:
ohair@478 317 # On Windows, reject /usr/bin/link (as determined in CYGWIN_LINK), which is a cygwin
erikj@459 318 # program for something completely different.
ohair@478 319 AC_CHECK_PROG([WINLD], [link],[link],,, [$CYGWIN_LINK])
erikj@459 320 # Since we must ignore the first found link, WINLD will contain
erikj@459 321 # the full path to the link.exe program.
ohair@494 322 BASIC_FIXUP_EXECUTABLE(WINLD)
ohair@478 323 printf "Windows linker was found at $WINLD\n"
ohair@478 324 AC_MSG_CHECKING([if the found link.exe is actually the Visual Studio linker])
ohair@478 325 "$WINLD" --version > /dev/null
ohair@478 326 if test $? -eq 0 ; then
ohair@478 327 AC_MSG_RESULT([no])
ohair@478 328 AC_MSG_ERROR([This is the Cygwin link tool. Please check your PATH and rerun configure.])
ohair@478 329 else
ohair@478 330 AC_MSG_RESULT([yes])
ohair@478 331 fi
erikj@459 332 LD="$WINLD"
erikj@459 333 LDEXE="$WINLD"
erikj@459 334 LDCXX="$WINLD"
erikj@459 335 LDEXECXX="$WINLD"
erikj@459 336
erikj@459 337 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt])
ohair@494 338 BASIC_FIXUP_EXECUTABLE(MT)
erikj@459 339 # The resource compiler
erikj@459 340 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc])
ohair@494 341 BASIC_FIXUP_EXECUTABLE(RC)
erikj@459 342
ohair@494 343 # For hotspot, we need these in Windows mixed path,
ohair@494 344 # so rewrite them all. Need added .exe suffix.
ohair@494 345 HOTSPOT_CXX="$CXX.exe"
ohair@494 346 HOTSPOT_LD="$LD.exe"
ohair@494 347 HOTSPOT_MT="$MT.exe"
ohair@494 348 HOTSPOT_RC="$RC.exe"
ohair@494 349 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_CXX)
ohair@494 350 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_LD)
ohair@494 351 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_MT)
ohair@494 352 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(HOTSPOT_RC)
ohair@494 353 AC_SUBST(HOTSPOT_MT)
ohair@494 354 AC_SUBST(HOTSPOT_RC)
ohair@494 355
ohair@494 356 RC_FLAGS="-nologo -l 0x409 -r"
erikj@459 357 AS_IF([test "x$VARIANT" = xOPT], [
erikj@459 358 RC_FLAGS="$RC_FLAGS -d NDEBUG"
erikj@459 359 ])
erikj@459 360 JDK_UPDATE_VERSION_NOTNULL=$JDK_UPDATE_VERSION
erikj@459 361 AS_IF([test "x$JDK_UPDATE_VERSION" = x], [
erikj@459 362 JDK_UPDATE_VERSION_NOTNULL=0
erikj@459 363 ])
erikj@459 364 RC_FLAGS="$RC_FLAGS -d \"JDK_BUILD_ID=$FULL_VERSION\""
erikj@459 365 RC_FLAGS="$RC_FLAGS -d \"JDK_COMPANY=$COMPANY_NAME\""
erikj@459 366 RC_FLAGS="$RC_FLAGS -d \"JDK_COMPONENT=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME binary\""
erikj@459 367 RC_FLAGS="$RC_FLAGS -d \"JDK_VER=$JDK_MINOR_VERSION.$JDK_MICRO_VERSION.$JDK_UPDATE_VERSION_NOTNULL.$COOKED_BUILD_NUMBER\""
erikj@459 368 RC_FLAGS="$RC_FLAGS -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\""
erikj@459 369 RC_FLAGS="$RC_FLAGS -d \"JDK_NAME=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME $JDK_MINOR_VERSION $JDK_UPDATE_META_TAG\""
erikj@459 370 RC_FLAGS="$RC_FLAGS -d \"JDK_FVER=$JDK_MINOR_VERSION,$JDK_MICRO_VERSION,$JDK_UPDATE_VERSION_NOTNULL,$COOKED_BUILD_NUMBER\""
erikj@459 371
erikj@459 372 # lib.exe is used to create static libraries.
erikj@459 373 AC_CHECK_PROG([WINAR], [lib],[lib],,,)
ohair@494 374 BASIC_FIXUP_EXECUTABLE(WINAR)
erikj@459 375 AR="$WINAR"
erikj@459 376 ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT"
erikj@459 377
erikj@459 378 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,)
ohair@494 379 BASIC_FIXUP_EXECUTABLE(DUMPBIN)
erikj@459 380
erikj@459 381 COMPILER_TYPE=CL
erikj@459 382 CCXXFLAGS="$CCXXFLAGS -nologo"
erikj@459 383 ])
erikj@459 384 AC_SUBST(RC_FLAGS)
erikj@459 385 AC_SUBST(COMPILER_TYPE)
erikj@459 386
erikj@459 387 AC_PROG_CPP
ohair@494 388 BASIC_FIXUP_EXECUTABLE(CPP)
erikj@459 389
erikj@459 390 AC_PROG_CXXCPP
ohair@494 391 BASIC_FIXUP_EXECUTABLE(CXXCPP)
ohair@478 392
ohair@478 393 if test "x$COMPILE_TYPE" != "xcross"; then
ohair@478 394 # If we are not cross compiling, use the same compilers for
ohair@478 395 # building the build platform executables. The cross-compilation
ohair@478 396 # case needed to be done earlier, but this can only be done after
ohair@478 397 # the native tools have been localized.
ohair@478 398 BUILD_CC="$CC"
ohair@478 399 BUILD_CXX="$CXX"
ohair@478 400 BUILD_LD="$LD"
ohair@478 401 fi
erikj@459 402
erikj@459 403 # for solaris we really need solaris tools, and not gnu equivalent
erikj@459 404 # these seems to normally reside in /usr/ccs/bin so add that to path before
erikj@459 405 # starting to probe
erikj@459 406 #
erikj@459 407 # NOTE: I add this /usr/ccs/bin after TOOLS but before OLD_PATH
erikj@459 408 # so that it can be overriden --with-tools-dir
erikj@459 409 if test "x$OPENJDK_BUILD_OS" = xsolaris; then
erikj@459 410 PATH="${TOOLS_DIR}:/usr/ccs/bin:${OLD_PATH}"
erikj@459 411 fi
erikj@459 412
erikj@459 413 # Find the right assembler.
ohair@494 414 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
erikj@459 415 AC_PATH_PROG(AS, as)
ohair@494 416 BASIC_FIXUP_EXECUTABLE(AS)
erikj@459 417 else
erikj@459 418 AS="$CC -c"
erikj@459 419 fi
erikj@459 420 AC_SUBST(AS)
erikj@459 421
ohair@494 422 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
ohair@478 423 AC_PATH_PROGS(NM, [gnm nm])
ohair@494 424 BASIC_FIXUP_EXECUTABLE(NM)
erikj@459 425 AC_PATH_PROG(STRIP, strip)
ohair@494 426 BASIC_FIXUP_EXECUTABLE(STRIP)
erikj@459 427 AC_PATH_PROG(MCS, mcs)
ohair@494 428 BASIC_FIXUP_EXECUTABLE(MCS)
ohair@494 429 elif test "x$OPENJDK_TARGET_OS" != xwindows; then
erikj@459 430 AC_CHECK_TOOL(NM, nm)
ohair@494 431 BASIC_FIXUP_EXECUTABLE(NM)
erikj@459 432 AC_CHECK_TOOL(STRIP, strip)
ohair@494 433 BASIC_FIXUP_EXECUTABLE(STRIP)
erikj@459 434 fi
erikj@459 435
ohair@494 436 # objcopy is used for moving debug symbols to separate files when
ohair@494 437 # full debug symbols are enabled.
ohair@494 438 if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; then
ohair@494 439 AC_CHECK_TOOLS(OBJCOPY, [gobjcopy objcopy])
tbell@516 440 # Only call fixup if objcopy was found.
tbell@516 441 if test -n "$OBJCOPY"; then
tbell@516 442 BASIC_FIXUP_EXECUTABLE(OBJCOPY)
tbell@516 443 fi
ohair@494 444 fi
ohair@494 445
ohair@494 446 AC_CHECK_TOOLS(OBJDUMP, [gobjdump objdump])
ohair@494 447 if test "x$OBJDUMP" != x; then
ohair@494 448 # Only used for compare.sh; we can live without it. BASIC_FIXUP_EXECUTABLE bails if argument is missing.
ohair@494 449 BASIC_FIXUP_EXECUTABLE(OBJDUMP)
erikj@459 450 fi
erikj@459 451
ohair@478 452 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
ohair@478 453 AC_PATH_PROG(LIPO, lipo)
ohair@494 454 BASIC_FIXUP_EXECUTABLE(LIPO)
ohair@478 455 fi
ohair@478 456
erikj@459 457 # Restore old path without tools dir
erikj@459 458 PATH="$OLD_PATH"
erikj@459 459 ])
erikj@459 460
erikj@459 461
erikj@459 462 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS],
erikj@459 463 [
erikj@459 464
erikj@459 465 ###############################################################################
erikj@459 466 #
erikj@459 467 # How to compile shared libraries.
erikj@459 468 #
erikj@459 469
erikj@459 470 if test "x$GCC" = xyes; then
erikj@459 471 COMPILER_NAME=gcc
erikj@459 472 PICFLAG="-fPIC"
erikj@459 473 LIBRARY_PREFIX=lib
erikj@459 474 SHARED_LIBRARY='lib[$]1.so'
erikj@459 475 STATIC_LIBRARY='lib[$]1.a'
erikj@459 476 SHARED_LIBRARY_FLAGS="-shared"
erikj@459 477 SHARED_LIBRARY_SUFFIX='.so'
erikj@459 478 STATIC_LIBRARY_SUFFIX='.a'
erikj@459 479 OBJ_SUFFIX='.o'
erikj@459 480 EXE_SUFFIX=''
erikj@459 481 SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1'
erikj@459 482 SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1'
erikj@459 483 C_FLAG_REORDER=''
erikj@459 484 CXX_FLAG_REORDER=''
ohair@478 485 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
ohair@478 486 SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1'
erikj@459 487 LD="$CC"
erikj@459 488 LDEXE="$CC"
erikj@459 489 LDCXX="$CXX"
erikj@459 490 LDEXECXX="$CXX"
erikj@459 491 POST_STRIP_CMD="$STRIP -g"
erikj@459 492
erikj@459 493 # Linking is different on MacOSX
ohair@494 494 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
erikj@459 495 # Might change in the future to clang.
erikj@459 496 COMPILER_NAME=gcc
erikj@459 497 SHARED_LIBRARY='lib[$]1.dylib'
erikj@459 498 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG"
erikj@459 499 SHARED_LIBRARY_SUFFIX='.dylib'
erikj@459 500 EXE_SUFFIX=''
erikj@459 501 SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1'
erikj@459 502 SET_SHARED_LIBRARY_MAPFILE=''
erikj@459 503 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.'
ohair@478 504 SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
erikj@459 505 POST_STRIP_CMD="$STRIP -S"
erikj@459 506 fi
erikj@459 507 else
ohair@494 508 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
erikj@459 509 # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler
erikj@459 510 COMPILER_NAME=ossc
erikj@459 511 PICFLAG="-KPIC"
erikj@459 512 LIBRARY_PREFIX=lib
erikj@459 513 SHARED_LIBRARY='lib[$]1.so'
erikj@459 514 STATIC_LIBRARY='lib[$]1.a'
ohair@478 515 SHARED_LIBRARY_FLAGS="-G"
erikj@459 516 SHARED_LIBRARY_SUFFIX='.so'
erikj@459 517 STATIC_LIBRARY_SUFFIX='.a'
erikj@459 518 OBJ_SUFFIX='.o'
erikj@459 519 EXE_SUFFIX=''
erikj@459 520 SET_SHARED_LIBRARY_NAME=''
erikj@459 521 SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
erikj@459 522 C_FLAG_REORDER='-xF'
erikj@459 523 CXX_FLAG_REORDER='-xF'
ohair@478 524 SET_SHARED_LIBRARY_ORIGIN='-R\$$$$ORIGIN[$]1'
ohair@478 525 SET_EXECUTABLE_ORIGIN="$SET_SHARED_LIBRARY_ORIGIN"
erikj@459 526 CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
erikj@459 527 CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
erikj@459 528 CFLAGS_JDKLIB_EXTRA='-xstrconst'
erikj@459 529 POST_STRIP_CMD="$STRIP -x"
erikj@459 530 POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\""
erikj@459 531 fi
ohair@494 532 if test "x$OPENJDK_TARGET_OS" = xwindows; then
erikj@459 533 # If it is not gcc, then assume it is the MS Visual Studio compiler
erikj@459 534 COMPILER_NAME=cl
erikj@459 535 PICFLAG=""
erikj@459 536 LIBRARY_PREFIX=
erikj@459 537 SHARED_LIBRARY='[$]1.dll'
erikj@459 538 STATIC_LIBRARY='[$]1.lib'
erikj@459 539 SHARED_LIBRARY_FLAGS="-LD"
erikj@459 540 SHARED_LIBRARY_SUFFIX='.dll'
erikj@459 541 STATIC_LIBRARY_SUFFIX='.lib'
erikj@459 542 OBJ_SUFFIX='.obj'
erikj@459 543 EXE_SUFFIX='.exe'
erikj@459 544 SET_SHARED_LIBRARY_NAME=''
erikj@459 545 SET_SHARED_LIBRARY_MAPFILE=''
erikj@459 546 SET_SHARED_LIBRARY_ORIGIN=''
ohair@478 547 SET_EXECUTABLE_ORIGIN=''
erikj@459 548 fi
erikj@459 549 fi
erikj@459 550
erikj@459 551 AC_SUBST(OBJ_SUFFIX)
erikj@459 552 AC_SUBST(SHARED_LIBRARY)
erikj@459 553 AC_SUBST(STATIC_LIBRARY)
erikj@459 554 AC_SUBST(LIBRARY_PREFIX)
erikj@459 555 AC_SUBST(SHARED_LIBRARY_SUFFIX)
erikj@459 556 AC_SUBST(STATIC_LIBRARY_SUFFIX)
erikj@459 557 AC_SUBST(EXE_SUFFIX)
erikj@459 558 AC_SUBST(SHARED_LIBRARY_FLAGS)
erikj@459 559 AC_SUBST(SET_SHARED_LIBRARY_NAME)
erikj@459 560 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE)
erikj@459 561 AC_SUBST(C_FLAG_REORDER)
erikj@459 562 AC_SUBST(CXX_FLAG_REORDER)
erikj@459 563 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
ohair@478 564 AC_SUBST(SET_EXECUTABLE_ORIGIN)
erikj@459 565 AC_SUBST(POST_STRIP_CMD)
erikj@459 566 AC_SUBST(POST_MCS_CMD)
erikj@459 567
erikj@459 568 # The (cross) compiler is now configured, we can now test capabilities
erikj@459 569 # of the target platform.
erikj@459 570 ])
erikj@459 571
erikj@459 572 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
erikj@459 573 [
erikj@459 574
erikj@459 575 ###############################################################################
erikj@459 576 #
erikj@459 577 # Setup the opt flags for different compilers
erikj@459 578 # and different operating systems.
erikj@459 579 #
ohair@478 580
ohair@478 581 #
ohair@478 582 # NOTE: check for -mstackrealign needs to be below potential addition of -m32
ohair@478 583 #
ohair@478 584 if test "x$OPENJDK_TARGET_CPU_BITS" = x32 && test "x$OPENJDK_TARGET_OS" = xmacosx; then
ohair@478 585 # On 32-bit MacOSX the OS requires C-entry points to be 16 byte aligned.
ohair@478 586 # While waiting for a better solution, the current workaround is to use -mstackrealign.
ohair@478 587 CFLAGS="$CFLAGS -mstackrealign"
ohair@478 588 AC_MSG_CHECKING([if 32-bit compiler supports -mstackrealign])
ohair@478 589 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
ohair@478 590 [
ohair@478 591 AC_MSG_RESULT([yes])
ohair@478 592 ],
ohair@478 593 [
ohair@478 594 AC_MSG_RESULT([no])
ohair@478 595 AC_MSG_ERROR([The selected compiler $CXX does not support -mstackrealign! Try to put another compiler in the path.])
ohair@478 596 ])
ohair@478 597 fi
ohair@478 598
erikj@459 599 C_FLAG_DEPS="-MMD -MF"
erikj@459 600 CXX_FLAG_DEPS="-MMD -MF"
erikj@459 601
erikj@459 602 case $COMPILER_TYPE in
erikj@459 603 CC )
erikj@459 604 D_FLAG="-g"
erikj@459 605 case $COMPILER_NAME in
erikj@459 606 gcc )
erikj@459 607 case $OPENJDK_TARGET_OS in
erikj@459 608 macosx )
erikj@459 609 # On MacOSX we optimize for size, something
erikj@459 610 # we should do for all platforms?
erikj@459 611 C_O_FLAG_HI="-Os"
erikj@459 612 C_O_FLAG_NORM="-Os"
erikj@459 613 C_O_FLAG_NONE=""
erikj@459 614 ;;
erikj@459 615 *)
erikj@459 616 C_O_FLAG_HI="-O3"
erikj@459 617 C_O_FLAG_NORM="-O2"
erikj@459 618 C_O_FLAG_NONE="-O0"
erikj@459 619 CFLAGS_DEBUG_SYMBOLS="-g"
erikj@459 620 CXXFLAGS_DEBUG_SYMBOLS="-g"
erikj@459 621 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then
erikj@459 622 CFLAGS_DEBUG_SYMBOLS="-g1"
ohair@478 623 CXXFLAGS_DEBUG_SYMBOLS="-g1"
erikj@459 624 fi
erikj@459 625 ;;
erikj@459 626 esac
erikj@459 627 CXX_O_FLAG_HI="$C_O_FLAG_HI"
erikj@459 628 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
erikj@459 629 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
erikj@459 630 ;;
erikj@459 631 ossc )
erikj@459 632 #
erikj@459 633 # Forte has different names for this with their C++ compiler...
erikj@459 634 #
ohair@478 635 C_FLAG_DEPS="-xMMD -xMF"
ohair@478 636 CXX_FLAG_DEPS="-xMMD -xMF"
erikj@459 637
ohair@478 638 # Extra options used with HIGHEST
ohair@478 639 #
ohair@478 640 # WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be
ohair@478 641 # done with care, there are some assumptions below that need to
ohair@478 642 # be understood about the use of pointers, and IEEE behavior.
ohair@478 643 #
ohair@478 644 # Use non-standard floating point mode (not IEEE 754)
ohair@478 645 CC_HIGHEST="$CC_HIGHEST -fns"
ohair@478 646 # Do some simplification of floating point arithmetic (not IEEE 754)
ohair@478 647 CC_HIGHEST="$CC_HIGHEST -fsimple"
ohair@478 648 # Use single precision floating point with 'float'
ohair@478 649 CC_HIGHEST="$CC_HIGHEST -fsingle"
ohair@478 650 # Assume memory references via basic pointer types do not alias
ohair@478 651 # (Source with excessing pointer casting and data access with mixed
ohair@478 652 # pointer types are not recommended)
ohair@478 653 CC_HIGHEST="$CC_HIGHEST -xalias_level=basic"
ohair@478 654 # Use intrinsic or inline versions for math/std functions
ohair@478 655 # (If you expect perfect errno behavior, do not use this)
ohair@478 656 CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all"
ohair@478 657 # Loop data dependency optimizations (need -xO3 or higher)
ohair@478 658 CC_HIGHEST="$CC_HIGHEST -xdepend"
ohair@478 659 # Pointer parameters to functions do not overlap
ohair@478 660 # (Similar to -xalias_level=basic usage, but less obvious sometimes.
ohair@478 661 # If you pass in multiple pointers to the same data, do not use this)
ohair@478 662 CC_HIGHEST="$CC_HIGHEST -xrestrict"
ohair@478 663 # Inline some library routines
ohair@478 664 # (If you expect perfect errno behavior, do not use this)
ohair@478 665 CC_HIGHEST="$CC_HIGHEST -xlibmil"
ohair@478 666 # Use optimized math routines
ohair@478 667 # (If you expect perfect errno behavior, do not use this)
ohair@478 668 # Can cause undefined external on Solaris 8 X86 on __sincos, removing for now
ohair@478 669 #CC_HIGHEST="$CC_HIGHEST -xlibmopt"
erikj@459 670
ohair@494 671 if test "x$OPENJDK_TARGET_CPU" = xsparc; then
ohair@494 672 CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s"
ohair@494 673 CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s"
ohair@494 674 fi
ohair@494 675
ohair@478 676 case $OPENJDK_TARGET_CPU_ARCH in
ohair@478 677 x86)
ohair@478 678 C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xregs=no%frameptr"
ohair@478 679 C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr"
ohair@478 680 C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr"
ohair@478 681 C_O_FLAG_NONE="-xregs=no%frameptr"
ohair@478 682 CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr"
ohair@478 683 CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr"
ohair@478 684 CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr"
ohair@478 685 CXX_O_FLAG_NONE="-xregs=no%frameptr"
ohair@478 686 if test "x$OPENJDK_TARGET_CPU" = xx86; then
ohair@478 687 C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium"
ohair@478 688 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium"
ohair@478 689 fi
erikj@459 690 ;;
erikj@459 691 sparc)
erikj@459 692 CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
erikj@459 693 CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl"
erikj@459 694 C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
erikj@459 695 C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
erikj@459 696 C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
erikj@459 697 C_O_FLAG_NONE=""
erikj@459 698 CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra"
erikj@459 699 CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
erikj@459 700 CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0"
erikj@459 701 CXX_O_FLAG_NONE=""
erikj@459 702 ;;
erikj@459 703 esac
erikj@459 704
erikj@459 705 CFLAGS_DEBUG_SYMBOLS="-g -xs"
erikj@459 706 CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs"
erikj@459 707 esac
erikj@459 708 ;;
erikj@459 709 CL )
erikj@459 710 D_FLAG=
ohair@478 711 C_O_FLAG_HIGHEST="-O2"
ohair@478 712 C_O_FLAG_HI="-O1"
erikj@459 713 C_O_FLAG_NORM="-O1"
erikj@459 714 C_O_FLAG_NONE="-Od"
ohair@478 715 CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST"
erikj@459 716 CXX_O_FLAG_HI="$C_O_FLAG_HI"
erikj@459 717 CXX_O_FLAG_NORM="$C_O_FLAG_NORM"
erikj@459 718 CXX_O_FLAG_NONE="$C_O_FLAG_NONE"
erikj@459 719 ;;
erikj@459 720 esac
erikj@459 721
erikj@459 722 if test -z "$C_O_FLAG_HIGHEST"; then
erikj@459 723 C_O_FLAG_HIGHEST="$C_O_FLAG_HI"
erikj@459 724 fi
erikj@459 725
erikj@459 726 if test -z "$CXX_O_FLAG_HIGHEST"; then
erikj@459 727 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HI"
erikj@459 728 fi
erikj@459 729
erikj@459 730 AC_SUBST(C_O_FLAG_HIGHEST)
erikj@459 731 AC_SUBST(C_O_FLAG_HI)
erikj@459 732 AC_SUBST(C_O_FLAG_NORM)
erikj@459 733 AC_SUBST(C_O_FLAG_NONE)
erikj@459 734 AC_SUBST(CXX_O_FLAG_HIGHEST)
erikj@459 735 AC_SUBST(CXX_O_FLAG_HI)
erikj@459 736 AC_SUBST(CXX_O_FLAG_NORM)
erikj@459 737 AC_SUBST(CXX_O_FLAG_NONE)
erikj@459 738 AC_SUBST(C_FLAG_DEPS)
erikj@459 739 AC_SUBST(CXX_FLAG_DEPS)
erikj@459 740 ])
erikj@459 741
erikj@459 742 AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK],
erikj@459 743 [
erikj@459 744
erikj@459 745 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then
ohair@478 746 AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags])
erikj@459 747 fi
erikj@459 748
erikj@459 749 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then
ohair@478 750 AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags])
erikj@459 751 fi
erikj@459 752
erikj@459 753 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then
ohair@478 754 AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags])
erikj@459 755 fi
erikj@459 756
erikj@459 757 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags],
erikj@459 758 [extra flags to be used when compiling jdk c-files])])
erikj@459 759
erikj@459 760 AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags],
erikj@459 761 [extra flags to be used when compiling jdk c++-files])])
erikj@459 762
erikj@459 763 AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags],
erikj@459 764 [extra flags to be used when linking jdk])])
erikj@459 765
erikj@459 766 CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags"
erikj@459 767 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags"
erikj@459 768 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags"
erikj@459 769
ohair@478 770 # Hotspot needs these set in their legacy form
ohair@478 771 LEGACY_EXTRA_CFLAGS=$with_extra_cflags
ohair@478 772 LEGACY_EXTRA_CXXFLAGS=$with_extra_cxxflags
ohair@478 773 LEGACY_EXTRA_LDFLAGS=$with_extra_ldflags
ohair@478 774
ohair@478 775 AC_SUBST(LEGACY_EXTRA_CFLAGS)
ohair@478 776 AC_SUBST(LEGACY_EXTRA_CXXFLAGS)
ohair@478 777 AC_SUBST(LEGACY_EXTRA_LDFLAGS)
ohair@478 778
erikj@459 779 ###############################################################################
erikj@459 780 #
erikj@459 781 # Now setup the CFLAGS and LDFLAGS for the JDK build.
erikj@459 782 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build.
erikj@459 783 #
erikj@459 784 case $COMPILER_NAME in
erikj@459 785 gcc )
erikj@459 786 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \
erikj@459 787 -pipe \
erikj@459 788 -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE"
erikj@459 789 case $OPENJDK_TARGET_CPU_ARCH in
erikj@459 790 arm )
erikj@459 791 # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing
erikj@459 792 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
erikj@459 793 ;;
erikj@459 794 ppc )
erikj@459 795 # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
erikj@459 796 ;;
erikj@459 797 * )
erikj@459 798 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
erikj@459 799 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
erikj@459 800 ;;
erikj@459 801 esac
erikj@459 802 ;;
erikj@459 803 ossc )
ohair@478 804 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS"
ohair@478 805 case $OPENJDK_TARGET_CPU_ARCH in
ohair@478 806 x86 )
ohair@494 807 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB"
ohair@478 808 CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE"
ohair@478 809 ;;
ohair@478 810 esac
ohair@478 811
ohair@478 812 CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal"
ohair@478 813 CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib"
ohair@478 814
ohair@478 815 LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext"
ohair@478 816 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib"
erikj@459 817 ;;
erikj@459 818 cl )
erikj@459 819 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \
erikj@459 820 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \
erikj@459 821 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
erikj@459 822 -DWIN32 -DIAL"
ohair@478 823 case $OPENJDK_TARGET_CPU in
ohair@478 824 x86 )
erikj@459 825 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86"
erikj@459 826 ;;
ohair@478 827 x86_64 )
erikj@459 828 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64"
erikj@459 829 ;;
erikj@459 830 esac
erikj@459 831 ;;
erikj@459 832 esac
erikj@459 833
erikj@459 834 ###############################################################################
erikj@459 835
erikj@459 836 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64"
erikj@459 837
erikj@459 838 # The package path is used only on macosx?
erikj@459 839 PACKAGE_PATH=/opt/local
erikj@459 840 AC_SUBST(PACKAGE_PATH)
erikj@459 841
ohair@478 842 if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then
ohair@478 843 # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the
ohair@478 844 # Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN
ohair@478 845 # (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h).
ohair@478 846 # Note: -Dmacro is the same as #define macro 1
ohair@478 847 # -Dmacro= is the same as #define macro
ohair@478 848 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
ohair@478 849 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN="
ohair@478 850 else
ohair@478 851 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN"
ohair@478 852 fi
erikj@459 853 else
erikj@459 854 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN"
erikj@459 855 fi
erikj@459 856 if test "x$OPENJDK_TARGET_OS" = xlinux; then
erikj@459 857 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX"
erikj@459 858 fi
erikj@459 859 if test "x$OPENJDK_TARGET_OS" = xwindows; then
erikj@459 860 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DWINDOWS"
erikj@459 861 fi
erikj@459 862 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
erikj@459 863 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS"
erikj@459 864 fi
erikj@459 865 if test "x$OPENJDK_TARGET_OS" = xmacosx; then
erikj@459 866 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE"
erikj@459 867 fi
erikj@459 868 if test "x$OPENJDK_TARGET_OS" = xbsd; then
erikj@459 869 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE"
erikj@459 870 fi
erikj@459 871 if test "x$DEBUG_LEVEL" = xrelease; then
erikj@459 872 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG"
ohair@478 873 if test "x$OPENJDK_TARGET_OS" = xsolaris; then
ohair@478 874 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED"
ohair@478 875 fi
erikj@459 876 else
erikj@459 877 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG"
erikj@459 878 fi
erikj@459 879
ohair@478 880 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY"
erikj@459 881 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'"
erikj@459 882
erikj@459 883 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \
erikj@459 884 -I${JDK_OUTPUTDIR}/include \
erikj@459 885 -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \
erikj@459 886 -I${JDK_TOPDIR}/src/share/javavm/export \
ohair@478 887 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/javavm/export \
erikj@459 888 -I${JDK_TOPDIR}/src/share/native/common \
ohair@478 889 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common"
erikj@459 890
erikj@459 891 # The shared libraries are compiled using the picflag.
erikj@459 892 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA"
erikj@459 893 CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA "
erikj@459 894
erikj@459 895 # Executable flags
erikj@459 896 CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK"
erikj@459 897 CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK"
erikj@459 898
erikj@459 899 # Now this is odd. The JDK native libraries have to link against libjvm.so
erikj@459 900 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server.
erikj@459 901 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library
erikj@459 902 # is identical for client and server? Yes. Which is picked at runtime (client or server)?
erikj@459 903 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following
erikj@459 904 # libraries will link to whatever is in memory. Yuck.
erikj@459 905 #
erikj@459 906 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh.
ohair@494 907 if test "x$COMPILER_NAME" = xcl; then
erikj@459 908 LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no"
ohair@478 909 if test "x$OPENJDK_TARGET_CPU" = xx86; then
erikj@459 910 LDFLAGS_JDK="$LDFLAGS_JDK -safeseh"
erikj@459 911 fi
erikj@459 912 # TODO: make -debug optional "--disable-full-debug-symbols"
erikj@459 913 LDFLAGS_JDK="$LDFLAGS_JDK -debug"
erikj@459 914 LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib"
erikj@459 915 LDFLAGS_JDKLIB_SUFFIX=""
erikj@459 916 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then
erikj@459 917 LDFLAGS_STACK_SIZE=1048576
erikj@459 918 else
erikj@459 919 LDFLAGS_STACK_SIZE=327680
erikj@459 920 fi
erikj@459 921 LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE"
erikj@459 922 else
ohair@494 923 if test "x$COMPILER_NAME" = xgcc; then
ohair@494 924 # If this is a --hash-style=gnu system, use --hash-style=both, why?
ohair@494 925 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'`
ohair@494 926 if test -n "$HAS_GNU_HASH"; then
ohair@494 927 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both "
ohair@494 928 fi
ohair@494 929 if test "x$OPENJDK_TARGET_OS" = xlinux; then
ohair@494 930 # And since we now know that the linker is gnu, then add -z defs, to forbid
ohair@494 931 # undefined symbols in object files.
ohair@494 932 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs"
ohair@494 933 if test "x$DEBUG_LEVEL" = "xrelease"; then
ohair@494 934 # When building release libraries, tell the linker optimize them.
ohair@494 935 # Should this be supplied to the OSS linker as well?
ohair@494 936 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1"
ohair@494 937 fi
erikj@459 938 fi
erikj@459 939 fi
erikj@459 940 LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \
ohair@478 941 -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}"
ohair@478 942
erikj@517 943 # On some platforms (mac) the linker warns about non existing -L dirs.
erikj@519 944 # Add server first if available. Linking aginst client does not always produce the same results.
erikj@519 945 # Only add client dir if client is being built. Default to server for other variants.
erikj@519 946 if test "x$JVM_VARIANT_SERVER" = xtrue; then
erikj@519 947 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
erikj@519 948 elif test "x$JVM_VARIANT_CLIENT" = xtrue; then
erikj@517 949 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client"
erikj@517 950 else
erikj@517 951 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server"
erikj@517 952 fi
erikj@517 953
ohair@478 954 LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm"
erikj@459 955 if test "x$COMPILER_NAME" = xossc; then
erikj@459 956 LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc"
erikj@459 957 fi
erikj@459 958
erikj@459 959 LDFLAGS_JDKEXE="${LDFLAGS_JDK}"
ohair@478 960 if test "x$OPENJDK_TARGET_OS" = xlinux; then
ohair@478 961 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined"
erikj@459 962 fi
erikj@459 963 fi
erikj@459 964
erikj@459 965 # Adjust flags according to debug level.
erikj@459 966 case $DEBUG_LEVEL in
erikj@459 967 fastdebug )
erikj@459 968 CFLAGS="$CFLAGS $D_FLAG"
erikj@459 969 JAVAC_FLAGS="$JAVAC_FLAGS -g"
erikj@459 970 ;;
erikj@459 971 slowdebug )
erikj@459 972 CFLAGS="$CFLAGS $D_FLAG"
erikj@459 973 C_O_FLAG_HI="$C_O_FLAG_NONE"
erikj@459 974 C_O_FLAG_NORM="$C_O_FLAG_NONE"
erikj@459 975 CXX_O_FLAG_HI="$CXX_O_FLAG_NONE"
erikj@459 976 CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE"
erikj@459 977 JAVAC_FLAGS="$JAVAC_FLAGS -g"
erikj@459 978 ;;
erikj@459 979 esac
erikj@459 980
erikj@459 981
erikj@459 982 AC_SUBST(CFLAGS_JDKLIB)
erikj@459 983 AC_SUBST(CFLAGS_JDKEXE)
erikj@459 984
erikj@459 985 AC_SUBST(CXXFLAGS_JDKLIB)
erikj@459 986 AC_SUBST(CXXFLAGS_JDKEXE)
erikj@459 987
erikj@459 988 AC_SUBST(LDFLAGS_JDKLIB)
erikj@459 989 AC_SUBST(LDFLAGS_JDKEXE)
erikj@459 990 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX)
erikj@459 991 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX)
ohair@478 992 AC_SUBST(LDFLAGS_CXX_JDK)
erikj@459 993 ])

mercurial