annotate common/autoconf/toolchain.m4 @ 507:0e1b5886b06c

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