common/autoconf/toolchain.m4

Tue, 05 Mar 2013 13:16:40 -0800

author
martin
date
Tue, 05 Mar 2013 13:16:40 -0800
changeset 648
a9c8a32d09f9
parent 621
ffb4d2e95140
child 650
c4901c0e0579
permissions
-rw-r--r--

8006988: build-infra: Configure fails if 'cl' is in path on linux
Summary: Respect user CC and CXX environment variables; use cl iff on windows
Reviewed-by: erikj

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

mercurial