common/autoconf/toolchain.m4

Fri, 26 Oct 2012 14:29:57 -0700

author
ohair
date
Fri, 26 Oct 2012 14:29:57 -0700
changeset 494
e64f2cb57d05
parent 478
2ba6f4da4bf3
child 495
e3182741ade2
permissions
-rw-r--r--

8000992: Update new build-infra makefiles
Summary: Build-infra project integration. Multiple authors on this work: erikj and ihse primarily, also changes from ohair, tbell, and dholmes. Special credit to ohstrom for his smartjavac work.
Reviewed-by: erikj, ihse, dholmes, tbell

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

mercurial