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