toolchain.m4 revision 457:3156dff953b1
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 26AC_DEFUN_ONCE([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV], 27[ 28 29# Check if the VS env variables were setup prior to running configure. 30# If not, then find vcvarsall.bat and run it automatically, and integrate 31# the set env variables into the spec file. 32SETUPDEVENV="# No special vars" 33if test "x$OPENJDK_BUILD_OS" = "xwindows"; then 34 # If vcvarsall.bat has been run, then VCINSTALLDIR is set. 35 if test "x$VCINSTALLDIR" != x; then 36 # No further setup is needed. The build will happen from this kind 37 # of shell. 38 SETUPDEVENV="# This spec file expects that you are running bash from within a VS command prompt." 39 # Make sure to remind you, if you forget to run make from a cygwin bash shell 40 # that is spawned "bash -l" from a VS command prompt. 41 CHECK_FOR_VCINSTALLDIR=yes 42 AC_MSG_CHECKING([if you are running from within a VS command prompt]) 43 AC_MSG_RESULT([yes]) 44 else 45 # Ah, we have not yet run vcvarsall.bat/vsvars32.bat/vsvars64.bat. Lets do that. First find it. 46 if test "x$VS100COMNTOOLS" != x; then 47 VARSBAT=`find "$VS100COMNTOOLS/../.." -name vcvarsall.bat` 48 SEARCH_ROOT="$VS100COMNTOOLS" 49 else 50 VARSBAT=`find "$PROGRAMFILES" -name vcvarsall.bat` 51 SEARCH_ROOT="$PROGRAMFILES" 52 fi 53 VCPATH=`dirname "$VARSBAT"` 54 VCPATH=`cygpath -w "$VCPATH"` 55 if test "x$VARSBAT" = x || test ! -d "$VCPATH"; then 56 AC_MSG_CHECKING([if we can find the VS installation]) 57 AC_MSG_RESULT([no]) 58 AC_MSG_ERROR([Tried to find a VS installation using both $SEARCH_ROOT but failed. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.]) 59 fi 60 case "$LEGACY_OPENJDK_TARGET_CPU1" in 61 i?86) 62 VARSBAT_ARCH=x86 63 ;; 64 *) 65 VARSBAT_ARCH=$LEGACY_OPENJDK_TARGET_CPU1 66 ;; 67 esac 68 # Lets extract the variables that are set by vcvarsall.bat/vsvars32.bat/vsvars64.bat 69 cd $OUTPUT_ROOT 70 bash $SRC_ROOT/common/bin/extractvcvars.sh "$VARSBAT" "$VARSBAT_ARCH" 71 cd $CURDIR 72 if test ! -s $OUTPUT_ROOT/localdevenv.sh || test ! -s $OUTPUT_ROOT/localdevenv.gmk; then 73 AC_MSG_CHECKING([if we can extract the needed env variables]) 74 AC_MSG_RESULT([no]) 75 AC_MSG_ERROR([Could not succesfully extract the env variables needed for the VS setup. Please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.]) 76 fi 77 # Now set all paths and other env variables. This will allow the rest of 78 # the configure script to find and run the compiler in the proper way. 79 . $OUTPUT_ROOT/localdevenv.sh 80 AC_MSG_CHECKING([if we can find the VS installation]) 81 if test "x$VCINSTALLDIR" != x; then 82 AC_MSG_RESULT([$VCINSTALLDIR]) 83 else 84 AC_MSG_RESULT([no]) 85 AC_MSG_ERROR([Could not find VS installation. Please install. If you are sure you have installed VS, then please run "c:\\cygwin\\bin\\bash.exe -l" from a VS command prompt and then run configure/make from there.]) 86 fi 87 CHECK_FOR_VCINSTALLDIR=no 88 SETUPDEVENV="include $OUTPUT_ROOT/localdevenv.gmk" 89 90 AC_MSG_CHECKING([for msvcr100.dll]) 91 AC_ARG_WITH(msvcr100dll, [AS_HELP_STRING([--with-msvcr100dll], 92 [copy this msvcr100.dll into the built JDK])]) 93 if test "x$with_msvcr100dll" != x; then 94 MSVCR100DLL="$with_msvcr100dll" 95 else 96 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then 97 MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | grep x64 | head --lines 1` 98 else 99 MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | grep x86 | grep -v ia64 | grep -v x64 | head --lines 1` 100 if test "x$MSVCR100DLL" = x; then 101 MSVCR100DLL=`find "$VCINSTALLDIR/.." -name msvcr100.dll | head --lines 1` 102 fi 103 fi 104 fi 105 if test "x$MSVCR100DLL" = x; then 106 AC_MSG_RESULT([no]) 107 AC_MSG_ERROR([Could not find msvcr100.dll !]) 108 fi 109 AC_MSG_RESULT([$MSVCR100DLL]) 110 SPACESAFE(MSVCR100DLL,[the path to msvcr100.dll]) 111 fi 112fi 113AC_SUBST(SETUPDEVENV) 114AC_SUBST(CHECK_FOR_VCINSTALLDIR) 115AC_SUBST(MSVCR100DLL) 116]) 117 118AC_DEFUN_ONCE([TOOLCHAIN_SETUP_SYSROOT_AND_OUT_OPTIONS], 119[ 120############################################################################### 121# 122# Configure the development tool paths and potential sysroot. 123# 124AC_LANG(C++) 125DEVKIT= 126SYS_ROOT=/ 127AC_SUBST(SYS_ROOT) 128 129# The option used to specify the target .o,.a or .so file. 130# When compiling, how to specify the to be created object file. 131CC_OUT_OPTION='-o$(SPACE)' 132# When linking, how to specify the to be created executable. 133EXE_OUT_OPTION='-o$(SPACE)' 134# When linking, how to specify the to be created dynamically linkable library. 135LD_OUT_OPTION='-o$(SPACE)' 136# When archiving, how to specify the to be create static archive for object files. 137AR_OUT_OPTION='rcs$(SPACE)' 138AC_SUBST(CC_OUT_OPTION) 139AC_SUBST(EXE_OUT_OPTION) 140AC_SUBST(LD_OUT_OPTION) 141AC_SUBST(AR_OUT_OPTION) 142]) 143 144AC_DEFUN_ONCE([TOOLCHAIN_SETUP_PATHS], 145[ 146# If --build AND --host is set, then the configure script will find any 147# cross compilation tools in the PATH. Cross compilation tools 148# follows the cross compilation standard where they are prefixed with ${host}. 149# For example the binary i686-sun-solaris2.10-gcc 150# will cross compile for i686-sun-solaris2.10 151# If neither of build and host is not set, then build=host and the 152# default compiler found in the path will be used. 153# Setting only --host, does not seem to be really supported. 154# Please set both --build and --host if you want to cross compile. 155 156DEFINE_CROSS_COMPILE_ARCH="" 157HOSTCC="" 158HOSTCXX="" 159HOSTLD="" 160AC_SUBST(DEFINE_CROSS_COMPILE_ARCH) 161AC_MSG_CHECKING([if this is a cross compile]) 162if test "x$OPENJDK_BUILD_SYSTEM" != "x$OPENJDK_TARGET_SYSTEM"; then 163 AC_MSG_RESULT([yes, from $OPENJDK_BUILD_SYSTEM to $OPENJDK_TARGET_SYSTEM]) 164 # We have detected a cross compile! 165 DEFINE_CROSS_COMPILE_ARCH="CROSS_COMPILE_ARCH:=$LEGACY_OPENJDK_TARGET_CPU1" 166 # Now we to find a C/C++ compiler that can build executables for the build 167 # platform. We can't use the AC_PROG_CC macro, since it can only be used 168 # once. 169 AC_PATH_PROGS(HOSTCC, [cl cc gcc]) 170 WHICHCMD(HOSTCC) 171 AC_PATH_PROGS(HOSTCXX, [cl CC g++]) 172 WHICHCMD(HOSTCXX) 173 AC_PATH_PROG(HOSTLD, ld) 174 WHICHCMD(HOSTLD) 175 # Building for the build platform should be easy. Therefore 176 # we do not need any linkers or assemblers etc. 177else 178 AC_MSG_RESULT([no]) 179fi 180 181# You can force the sys-root if the sys-root encoded into the cross compiler tools 182# is not correct. 183AC_ARG_WITH(sys-root, [AS_HELP_STRING([--with-sys-root], 184 [pass this sys-root to the compilers and linker (useful if the sys-root encoded in 185 the cross compiler tools is incorrect)])]) 186 187if test "x$with_sys_root" != x; then 188 SYS_ROOT=$with_sys_root 189fi 190 191# If a devkit is found on the builddeps server, then prepend its path to the 192# PATH variable. If there are cross compilers available in the devkit, these 193# will be found by AC_PROG_CC et al. 194BDEPS_CHECK_MODULE(DEVKIT, devkit, xxx, 195 [# Found devkit 196 PATH="$DEVKIT/bin:$PATH" 197 SYS_ROOT="$DEVKIT/${rewritten_target}/sys-root" 198 if test "x$x_includes" = "xNONE"; then 199 x_includes="$SYS_ROOT/usr/include/X11" 200 fi 201 if test "x$x_libraries" = "xNONE"; then 202 x_libraries="$SYS_ROOT/usr/lib" 203 fi 204 ], 205 []) 206 207if test "x$SYS_ROOT" != "x/" ; then 208 CFLAGS="--sysroot=$SYS_ROOT $CFLAGS" 209 CXXFLAGS="--sysroot=$SYS_ROOT $CXXFLAGS" 210 OBJCFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 211 OBJCXXFLAGS="--sysroot=$SYS_ROOT $OBJCFLAGS" 212 CPPFLAGS="--sysroot=$SYS_ROOT $CPPFLAGS" 213 LDFLAGS="--sysroot=$SYS_ROOT $LDFLAGS" 214fi 215 216# Store the CFLAGS etal passed to the configure script. 217ORG_CFLAGS="$CFLAGS" 218ORG_CXXFLAGS="$CXXFLAGS" 219ORG_OBJCFLAGS="$OBJCFLAGS" 220 221AC_ARG_WITH([tools-dir], [AS_HELP_STRING([--with-tools-dir], 222 [search this directory for compilers and tools])], [TOOLS_DIR=$with_tools_dir]) 223 224AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit], 225 [use this directory as base for tools-dir and sys-root])], [ 226 if test "x$with_sys_root" != x; then 227 AC_MSG_ERROR([Cannot specify both --with-devkit and --with-sys-root at the same time]) 228 fi 229 if test "x$with_tools_dir" != x; then 230 AC_MSG_ERROR([Cannot specify both --with-devkit and --with-tools-dir at the same time]) 231 fi 232 TOOLS_DIR=$with_devkit/bin 233 SYS_ROOT=$with_devkit/$host_alias/libc 234 ]) 235 236# autoconf magic only relies on PATH, so update it if tools dir is specified 237OLD_PATH="$PATH" 238if test "x$TOOLS_DIR" != x; then 239 PATH=$TOOLS_DIR:$PATH 240fi 241 242# gcc is almost always present, but on Windows we 243# prefer cl.exe and on Solaris we prefer CC. 244# Thus test for them in this order. 245AC_PROG_CC([cl cc gcc]) 246if test "x$CC" = x; then 247 HELP_MSG_MISSING_DEPENDENCY([devkit]) 248 AC_MSG_ERROR([Could not find a compiler. $HELP_MSG]) 249fi 250if test "x$CC" = xcc && test "x$OPENJDK_BUILD_OS" = xmacosx; then 251 # Do not use cc on MacOSX use gcc instead. 252 CC="gcc" 253fi 254WHICHCMD(CC) 255 256AC_PROG_CXX([cl CC g++]) 257if test "x$CXX" = xCC && test "x$OPENJDK_BUILD_OS" = xmacosx; then 258 # The found CC, even though it seems to be a g++ derivate, cannot compile 259 # c++ code. Override. 260 CXX="g++" 261fi 262WHICHCMD(CXX) 263 264if test "x$CXX" = x || test "x$CC" = x; then 265 HELP_MSG_MISSING_DEPENDENCY([devkit]) 266 AC_MSG_ERROR([Could not find the needed compilers! $HELP_MSG ]) 267fi 268 269if test "x$OPENJDK_BUILD_OS" != xwindows; then 270 AC_PROG_OBJC 271 WHICHCMD(OBJC) 272else 273 OBJC= 274fi 275 276# Restore the flags to the user specified values. 277# This is necessary since AC_PROG_CC defaults CFLAGS to "-g -O2" 278CFLAGS="$ORG_CFLAGS" 279CXXFLAGS="$ORG_CXXFLAGS" 280OBJCFLAGS="$ORG_OBJCFLAGS" 281 282# If we are not cross compiling, use the same compilers for 283# building the build platform executables. 284if test "x$DEFINE_CROSS_COMPILE_ARCH" = x; then 285 HOSTCC="$CC" 286 HOSTCXX="$CXX" 287fi 288 289AC_CHECK_TOOL(LD, ld) 290WHICHCMD(LD) 291LD="$CC" 292LDEXE="$CC" 293LDCXX="$CXX" 294LDEXECXX="$CXX" 295# LDEXE is the linker to use, when creating executables. 296AC_SUBST(LDEXE) 297# Linking C++ libraries. 298AC_SUBST(LDCXX) 299# Linking C++ executables. 300AC_SUBST(LDEXECXX) 301 302AC_CHECK_TOOL(AR, ar) 303WHICHCMD(AR) 304if test "x$OPENJDK_BUILD_OS" = xmacosx; then 305 ARFLAGS="-r" 306else 307 ARFLAGS="" 308fi 309AC_SUBST(ARFLAGS) 310 311COMPILER_NAME=gcc 312COMPILER_TYPE=CC 313AS_IF([test "x$OPENJDK_BUILD_OS" = xwindows], [ 314 # For now, assume that we are always compiling using cl.exe. 315 CC_OUT_OPTION=-Fo 316 EXE_OUT_OPTION=-out: 317 LD_OUT_OPTION=-out: 318 AR_OUT_OPTION=-out: 319 # On Windows, reject /usr/bin/link, which is a cygwin 320 # program for something completely different. 321 AC_CHECK_PROG([WINLD], [link],[link],,, [/usr/bin/link]) 322 # Since we must ignore the first found link, WINLD will contain 323 # the full path to the link.exe program. 324 WHICHCMD_SPACESAFE([WINLD]) 325 LD="$WINLD" 326 LDEXE="$WINLD" 327 LDCXX="$WINLD" 328 LDEXECXX="$WINLD" 329 # Set HOSTLD to same as LD until we fully support cross compilation 330 # on windows. 331 HOSTLD="$WINLD" 332 333 AC_CHECK_PROG([MT], [mt], [mt],,, [/usr/bin/mt]) 334 WHICHCMD_SPACESAFE([MT]) 335 # The resource compiler 336 AC_CHECK_PROG([RC], [rc], [rc],,, [/usr/bin/rc]) 337 WHICHCMD_SPACESAFE([RC]) 338 339 RC_FLAGS="-nologo /l 0x409 /r" 340 AS_IF([test "x$VARIANT" = xOPT], [ 341 RC_FLAGS="$RC_FLAGS -d NDEBUG" 342 ]) 343 JDK_UPDATE_VERSION_NOTNULL=$JDK_UPDATE_VERSION 344 AS_IF([test "x$JDK_UPDATE_VERSION" = x], [ 345 JDK_UPDATE_VERSION_NOTNULL=0 346 ]) 347 RC_FLAGS="$RC_FLAGS -d \"JDK_BUILD_ID=$FULL_VERSION\"" 348 RC_FLAGS="$RC_FLAGS -d \"JDK_COMPANY=$COMPANY_NAME\"" 349 RC_FLAGS="$RC_FLAGS -d \"JDK_COMPONENT=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME binary\"" 350 RC_FLAGS="$RC_FLAGS -d \"JDK_VER=$JDK_MINOR_VERSION.$JDK_MICRO_VERSION.$JDK_UPDATE_VERSION_NOTNULL.$COOKED_BUILD_NUMBER\"" 351 RC_FLAGS="$RC_FLAGS -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\"" 352 RC_FLAGS="$RC_FLAGS -d \"JDK_NAME=$PRODUCT_NAME $JDK_RC_PLATFORM_NAME $JDK_MINOR_VERSION $JDK_UPDATE_META_TAG\"" 353 RC_FLAGS="$RC_FLAGS -d \"JDK_FVER=$JDK_MINOR_VERSION,$JDK_MICRO_VERSION,$JDK_UPDATE_VERSION_NOTNULL,$COOKED_BUILD_NUMBER\"" 354 355 # lib.exe is used to create static libraries. 356 AC_CHECK_PROG([WINAR], [lib],[lib],,,) 357 WHICHCMD_SPACESAFE([WINAR]) 358 AR="$WINAR" 359 ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT" 360 361 AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,) 362 WHICHCMD_SPACESAFE([DUMPBIN]) 363 364 COMPILER_TYPE=CL 365 CCXXFLAGS="$CCXXFLAGS -nologo" 366]) 367AC_SUBST(RC_FLAGS) 368AC_SUBST(COMPILER_TYPE) 369 370AC_PROG_CPP 371WHICHCMD(CPP) 372 373AC_PROG_CXXCPP 374WHICHCMD(CXXCPP) 375 376# for solaris we really need solaris tools, and not gnu equivalent 377# these seems to normally reside in /usr/ccs/bin so add that to path before 378# starting to probe 379# 380# NOTE: I add this /usr/ccs/bin after TOOLS but before OLD_PATH 381# so that it can be overriden --with-tools-dir 382if test "x$OPENJDK_BUILD_OS" = xsolaris; then 383 PATH="${TOOLS_DIR}:/usr/ccs/bin:${OLD_PATH}" 384fi 385 386# Find the right assembler. 387if test "x$OPENJDK_BUILD_OS" = xsolaris; then 388 AC_PATH_PROG(AS, as) 389 WHICHCMD(AS) 390 ASFLAGS=" " 391else 392 AS="$CC -c" 393 ASFLAGS=" " 394fi 395AC_SUBST(AS) 396AC_SUBST(ASFLAGS) 397 398if test "x$OPENJDK_BUILD_OS" = xsolaris; then 399 AC_PATH_PROG(NM, nm) 400 WHICHCMD(NM) 401 AC_PATH_PROG(STRIP, strip) 402 WHICHCMD(STRIP) 403 AC_PATH_PROG(MCS, mcs) 404 WHICHCMD(MCS) 405else 406 AC_CHECK_TOOL(NM, nm) 407 WHICHCMD(NM) 408 AC_CHECK_TOOL(STRIP, strip) 409 WHICHCMD(STRIP) 410fi 411 412### 413# 414# Check for objcopy 415# 416# but search for gobjcopy first... 417# since I on solaris found a broken objcopy...buhh 418# 419AC_PATH_TOOL(OBJCOPY, gobjcopy) 420if test "x$OBJCOPY" = x; then 421 AC_PATH_TOOL(OBJCOPY, objcopy) 422fi 423 424# Restore old path without tools dir 425PATH="$OLD_PATH" 426]) 427 428 429AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_LIBS], 430[ 431 432############################################################################### 433# 434# How to compile shared libraries. 435# 436 437if test "x$GCC" = xyes; then 438 COMPILER_NAME=gcc 439 PICFLAG="-fPIC" 440 LIBRARY_PREFIX=lib 441 SHARED_LIBRARY='lib[$]1.so' 442 STATIC_LIBRARY='lib[$]1.a' 443 SHARED_LIBRARY_FLAGS="-shared" 444 SHARED_LIBRARY_SUFFIX='.so' 445 STATIC_LIBRARY_SUFFIX='.a' 446 OBJ_SUFFIX='.o' 447 EXE_SUFFIX='' 448 SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1' 449 SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1' 450 C_FLAG_REORDER='' 451 CXX_FLAG_REORDER='' 452 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$$$ORIGIN/[$]1' 453 LD="$CC" 454 LDEXE="$CC" 455 LDCXX="$CXX" 456 LDEXECXX="$CXX" 457 POST_STRIP_CMD="$STRIP -g" 458 if test "x$JDK_VARIANT" = xembedded; then 459 POST_STRIP_CMD="$STRIP --strip-unneeded" 460 fi 461 462 # Linking is different on MacOSX 463 if test "x$OPENJDK_BUILD_OS" = xmacosx; then 464 # Might change in the future to clang. 465 COMPILER_NAME=gcc 466 SHARED_LIBRARY='lib[$]1.dylib' 467 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG" 468 SHARED_LIBRARY_SUFFIX='.dylib' 469 EXE_SUFFIX='' 470 SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 471 SET_SHARED_LIBRARY_MAPFILE='' 472 SET_SHARED_LIBRARY_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.' 473 POST_STRIP_CMD="$STRIP -S" 474 fi 475else 476 if test "x$OPENJDK_BUILD_OS" = xsolaris; then 477 # If it is not gcc, then assume it is the Oracle Solaris Studio Compiler 478 COMPILER_NAME=ossc 479 PICFLAG="-KPIC" 480 LIBRARY_PREFIX=lib 481 SHARED_LIBRARY='lib[$]1.so' 482 STATIC_LIBRARY='lib[$]1.a' 483 SHARED_LIBRARY_FLAGS="-z defs -xildoff -ztext -G" 484 SHARED_LIBRARY_SUFFIX='.so' 485 STATIC_LIBRARY_SUFFIX='.a' 486 OBJ_SUFFIX='.o' 487 EXE_SUFFIX='' 488 SET_SHARED_LIBRARY_NAME='' 489 SET_SHARED_LIBRARY_MAPFILE='-M[$]1' 490 C_FLAG_REORDER='-xF' 491 CXX_FLAG_REORDER='-xF' 492 SET_SHARED_LIBRARY_ORIGIN='-R \$$$$ORIGIN/[$]1' 493 CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__" 494 CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__" 495 CFLAGS_JDKLIB_EXTRA='-xstrconst' 496 POST_STRIP_CMD="$STRIP -x" 497 POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\"" 498 fi 499 if test "x$OPENJDK_BUILD_OS" = xwindows; then 500 # If it is not gcc, then assume it is the MS Visual Studio compiler 501 COMPILER_NAME=cl 502 PICFLAG="" 503 LIBRARY_PREFIX= 504 SHARED_LIBRARY='[$]1.dll' 505 STATIC_LIBRARY='[$]1.lib' 506 SHARED_LIBRARY_FLAGS="-LD" 507 SHARED_LIBRARY_SUFFIX='.dll' 508 STATIC_LIBRARY_SUFFIX='.lib' 509 OBJ_SUFFIX='.obj' 510 EXE_SUFFIX='.exe' 511 SET_SHARED_LIBRARY_NAME='' 512 SET_SHARED_LIBRARY_MAPFILE='' 513 SET_SHARED_LIBRARY_ORIGIN='' 514 fi 515fi 516 517AC_SUBST(OBJ_SUFFIX) 518AC_SUBST(SHARED_LIBRARY) 519AC_SUBST(STATIC_LIBRARY) 520AC_SUBST(LIBRARY_PREFIX) 521AC_SUBST(SHARED_LIBRARY_SUFFIX) 522AC_SUBST(STATIC_LIBRARY_SUFFIX) 523AC_SUBST(EXE_SUFFIX) 524AC_SUBST(SHARED_LIBRARY_FLAGS) 525AC_SUBST(SET_SHARED_LIBRARY_NAME) 526AC_SUBST(SET_SHARED_LIBRARY_MAPFILE) 527AC_SUBST(C_FLAG_REORDER) 528AC_SUBST(CXX_FLAG_REORDER) 529AC_SUBST(SET_SHARED_LIBRARY_ORIGIN) 530AC_SUBST(POST_STRIP_CMD) 531AC_SUBST(POST_MCS_CMD) 532 533# The (cross) compiler is now configured, we can now test capabilities 534# of the target platform. 535]) 536 537AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], 538[ 539 540############################################################################### 541# 542# Setup the opt flags for different compilers 543# and different operating systems. 544# 545C_FLAG_DEPS="-MMD -MF" 546CXX_FLAG_DEPS="-MMD -MF" 547 548case $COMPILER_TYPE in 549 CC ) 550 D_FLAG="-g" 551 case $COMPILER_NAME in 552 gcc ) 553 case $OPENJDK_TARGET_OS in 554 macosx ) 555 # On MacOSX we optimize for size, something 556 # we should do for all platforms? 557 C_O_FLAG_HI="-Os" 558 C_O_FLAG_NORM="-Os" 559 C_O_FLAG_NONE="" 560 ;; 561 *) 562 C_O_FLAG_HI="-O3" 563 C_O_FLAG_NORM="-O2" 564 C_O_FLAG_NONE="-O0" 565 CFLAGS_DEBUG_SYMBOLS="-g" 566 CXXFLAGS_DEBUG_SYMBOLS="-g" 567 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then 568 CFLAGS_DEBUG_SYMBOLS="-g1" 569 CXXFLAGS_DEBUG_SYMBOLSG="-g1" 570 fi 571 ;; 572 esac 573 CXX_O_FLAG_HI="$C_O_FLAG_HI" 574 CXX_O_FLAG_NORM="$C_O_FLAG_NORM" 575 CXX_O_FLAG_NONE="$C_O_FLAG_NONE" 576 ;; 577 ossc ) 578 # 579 # Forte has different names for this with their C++ compiler... 580 # 581 C_FLAG_DEPS="-xMMD -xMF" 582 CXX_FLAG_DEPS="-xMMD -xMF" 583 584# Extra options used with HIGHEST 585# 586# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be 587# done with care, there are some assumptions below that need to 588# be understood about the use of pointers, and IEEE behavior. 589# 590# Use non-standard floating point mode (not IEEE 754) 591CC_HIGHEST="$CC_HIGHEST -fns" 592# Do some simplification of floating point arithmetic (not IEEE 754) 593CC_HIGHEST="$CC_HIGHEST -fsimple" 594# Use single precision floating point with 'float' 595CC_HIGHEST="$CC_HIGHEST -fsingle" 596# Assume memory references via basic pointer types do not alias 597# (Source with excessing pointer casting and data access with mixed 598# pointer types are not recommended) 599CC_HIGHEST="$CC_HIGHEST -xalias_level=basic" 600# Use intrinsic or inline versions for math/std functions 601# (If you expect perfect errno behavior, do not use this) 602CC_HIGHEST="$CC_HIGHEST -xbuiltin=%all" 603# Loop data dependency optimizations (need -xO3 or higher) 604CC_HIGHEST="$CC_HIGHEST -xdepend" 605# Pointer parameters to functions do not overlap 606# (Similar to -xalias_level=basic usage, but less obvious sometimes. 607# If you pass in multiple pointers to the same data, do not use this) 608CC_HIGHEST="$CC_HIGHEST -xrestrict" 609# Inline some library routines 610# (If you expect perfect errno behavior, do not use this) 611CC_HIGHEST="$CC_HIGHEST -xlibmil" 612# Use optimized math routines 613# (If you expect perfect errno behavior, do not use this) 614# Can cause undefined external on Solaris 8 X86 on __sincos, removing for now 615#CC_HIGHEST="$CC_HIGHEST -xlibmopt" 616 617 case $LEGACY_OPENJDK_TARGET_CPU1 in 618 i586) 619 C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xchip=pentium" 620 C_O_FLAG_HI="-xO4 -Wu,-O4~yz" 621 C_O_FLAG_NORM="-xO2 -Wu,-O2~yz" 622 C_O_FLAG_NONE="" 623 CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xchip=pentium" 624 CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz" 625 CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz" 626 CXX_O_FLAG_NONE="" 627 ;; 628 sparc) 629 CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s" 630 CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s" 631 CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl" 632 CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl" 633 C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra" 634 C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0" 635 C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0" 636 C_O_FLAG_NONE="" 637 CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra" 638 CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" 639 CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" 640 CXX_O_FLAG_NONE="" 641 ;; 642 esac 643 644 CFLAGS_DEBUG_SYMBOLS="-g -xs" 645 CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs" 646 esac 647 ;; 648 CL ) 649 D_FLAG= 650 C_O_FLAG_HI="-O2" 651 C_O_FLAG_NORM="-O1" 652 C_O_FLAG_NONE="-Od" 653 CXX_O_FLAG_HI="$C_O_FLAG_HI" 654 CXX_O_FLAG_NORM="$C_O_FLAG_NORM" 655 CXX_O_FLAG_NONE="$C_O_FLAG_NONE" 656 ;; 657esac 658 659if test -z "$C_O_FLAG_HIGHEST"; then 660 C_O_FLAG_HIGHEST="$C_O_FLAG_HI" 661fi 662 663if test -z "$CXX_O_FLAG_HIGHEST"; then 664 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HI" 665fi 666 667AC_SUBST(C_O_FLAG_HIGHEST) 668AC_SUBST(C_O_FLAG_HI) 669AC_SUBST(C_O_FLAG_NORM) 670AC_SUBST(C_O_FLAG_NONE) 671AC_SUBST(CXX_O_FLAG_HIGHEST) 672AC_SUBST(CXX_O_FLAG_HI) 673AC_SUBST(CXX_O_FLAG_NORM) 674AC_SUBST(CXX_O_FLAG_NONE) 675AC_SUBST(C_FLAG_DEPS) 676AC_SUBST(CXX_FLAG_DEPS) 677]) 678 679AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK], 680[ 681 682if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then 683 AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags"]) 684fi 685 686if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then 687 AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags"]) 688fi 689 690if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then 691 AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags"]) 692fi 693 694AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags], 695 [extra flags to be used when compiling jdk c-files])]) 696 697AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags], 698 [extra flags to be used when compiling jdk c++-files])]) 699 700AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags], 701 [extra flags to be used when linking jdk])]) 702 703CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags" 704CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags" 705LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags" 706 707############################################################################### 708# 709# Now setup the CFLAGS and LDFLAGS for the JDK build. 710# Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build. 711# 712case $COMPILER_NAME in 713 gcc ) 714 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -W -Wall -Wno-unused -Wno-parentheses \ 715 -pipe \ 716 -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" 717 case $OPENJDK_TARGET_CPU_ARCH in 718 arm ) 719 # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing 720 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" 721 ;; 722 ppc ) 723 # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing 724 ;; 725 * ) 726 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer" 727 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" 728 ;; 729 esac 730 ;; 731 ossc ) 732 CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -norunpath -xnolib" 733 CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX" 734 ;; 735 cl ) 736 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ 737 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \ 738 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \ 739 -DWIN32 -DIAL" 740 case $LEGACY_OPENJDK_TARGET_CPU1 in 741 i?86 ) 742 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86" 743 ;; 744 amd64 ) 745 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64" 746 ;; 747 esac 748 ;; 749esac 750 751############################################################################### 752# 753# Cross-compile arch specific flags 754 755# 756if test "x$JDK_VARIANT" = "xembedded"; then 757 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DJAVASE_EMBEDDED" 758fi 759 760case $OPENJDK_TARGET_CPU_ARCH in 761arm ) 762 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char" 763 ;; 764ppc ) 765 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fsigned-char" 766 ;; 767esac 768 769############################################################################### 770 771CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64" 772 773# The package path is used only on macosx? 774PACKAGE_PATH=/opt/local 775AC_SUBST(PACKAGE_PATH) 776 777# Sometimes we use a cpu dir (.../lib/amd64/server) 778# Sometimes not (.../lib/server) 779LIBARCHDIR="$LEGACY_OPENJDK_TARGET_CPU2/" 780if test "x$ENDIAN" = xlittle; then 781 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN" 782else 783 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN" 784fi 785if test "x$OPENJDK_TARGET_OS" = xlinux; then 786 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DLINUX" 787fi 788if test "x$OPENJDK_TARGET_OS" = xwindows; then 789 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DWINDOWS" 790fi 791if test "x$OPENJDK_TARGET_OS" = xsolaris; then 792 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DSOLARIS" 793fi 794if test "x$OPENJDK_TARGET_OS" = xmacosx; then 795 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMACOSX -D_ALLBSD_SOURCE" 796 LIBARCHDIR="" 797fi 798if test "x$OPENJDK_TARGET_OS" = xbsd; then 799 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DBSD -D_ALLBSD_SOURCE" 800fi 801if test "x$DEBUG_LEVEL" = xrelease; then 802 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG" 803else 804 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG" 805fi 806 807CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$LEGACY_OPENJDK_TARGET_CPU1\"' -D$LEGACY_OPENJDK_TARGET_CPU1" 808CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"$RELEASE\"'" 809 810CCXXFLAGS_JDK="$CCXXFLAGS_JDK \ 811 -I${JDK_OUTPUTDIR}/include \ 812 -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \ 813 -I${JDK_TOPDIR}/src/share/javavm/export \ 814 -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/javavm/export \ 815 -I${JDK_TOPDIR}/src/share/native/common \ 816 -I${JDK_TOPDIR}/src/$LEGACY_OPENJDK_TARGET_OS_API/native/common" 817 818# The shared libraries are compiled using the picflag. 819CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" 820CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " 821 822# Executable flags 823CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK" 824CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK" 825 826# Now this is odd. The JDK native libraries have to link against libjvm.so 827# On 32-bit machines there is normally two distinct libjvm.so:s, client and server. 828# Which should we link to? Are we lucky enough that the binary api to the libjvm.so library 829# is identical for client and server? Yes. Which is picked at runtime (client or server)? 830# Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following 831# libraries will link to whatever is in memory. Yuck. 832# 833# Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh. 834if test "x$COMPILER_TYPE" = xCL; then 835 LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no" 836 if test "x$LEGACY_OPENJDK_TARGET_CPU1" = xi586; then 837 LDFLAGS_JDK="$LDFLAGS_JDK -safeseh" 838 fi 839 # TODO: make -debug optional "--disable-full-debug-symbols" 840 LDFLAGS_JDK="$LDFLAGS_JDK -debug" 841 LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib" 842 LDFLAGS_JDKLIB_SUFFIX="" 843 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then 844 LDFLAGS_STACK_SIZE=1048576 845 else 846 LDFLAGS_STACK_SIZE=327680 847 fi 848 LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE" 849else 850 # If this is a --hash-style=gnu system, use --hash-style=both, why? 851 HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'` 852 if test -n "$HAS_GNU_HASH"; then 853 # And since we now know that the linker is gnu, then add -z defs, to forbid 854 # undefined symbols in object files. 855 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both -Xlinker -z -Xlinker defs" 856 if test "x$DEBUG_LEVEL" == "xrelease"; then 857 # When building release libraries, tell the linker optimize them. 858 # Should this be supplied to the OSS linker as well? 859 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" 860 fi 861 fi 862 863 LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \ 864 -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}server \ 865 -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}client \ 866 -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}" 867 LDFLAGS_JDKLIB_SUFFIX="-ljvm -ljava" 868 if test "x$COMPILER_NAME" = xossc; then 869 LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc" 870 fi 871 872 # Only the jli library is explicitly linked when the launchers are built. 873 # The libjvm is then dynamically loaded/linked by the launcher. 874 LDFLAGS_JDKEXE="${LDFLAGS_JDK}" 875 if test "x$OPENJDK_TARGET_OS" != "xmacosx"; then 876 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -L${JDK_OUTPUTDIR}/lib/${LIBARCHDIR}jli" 877 LDFLAGS_JDKEXE_SUFFIX="-ljli" 878 fi 879fi 880 881# Adjust flags according to debug level. 882case $DEBUG_LEVEL in 883 fastdebug ) 884 CFLAGS="$CFLAGS $D_FLAG" 885 JAVAC_FLAGS="$JAVAC_FLAGS -g" 886 ;; 887 slowdebug ) 888 CFLAGS="$CFLAGS $D_FLAG" 889 C_O_FLAG_HI="$C_O_FLAG_NONE" 890 C_O_FLAG_NORM="$C_O_FLAG_NONE" 891 CXX_O_FLAG_HI="$CXX_O_FLAG_NONE" 892 CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE" 893 JAVAC_FLAGS="$JAVAC_FLAGS -g" 894 ;; 895esac 896 897 898AC_SUBST(CFLAGS_JDKLIB) 899AC_SUBST(CFLAGS_JDKEXE) 900 901AC_SUBST(CXXFLAGS_JDKLIB) 902AC_SUBST(CXXFLAGS_JDKEXE) 903 904AC_SUBST(LDFLAGS_JDKLIB) 905AC_SUBST(LDFLAGS_JDKEXE) 906AC_SUBST(LDFLAGS_JDKLIB_SUFFIX) 907AC_SUBST(LDFLAGS_JDKEXE_SUFFIX) 908]) 909