flags.m4 revision 1008:9786ef8ca58c
1# 2# Copyright (c) 2011, 2014, 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([FLAGS_SETUP_INIT_FLAGS], 27[ 28 # Option used to tell the compiler whether to create 32- or 64-bit executables 29 if test "x$TOOLCHAIN_TYPE" = xxlc; then 30 COMPILER_TARGET_BITS_FLAG="-q" 31 else 32 COMPILER_TARGET_BITS_FLAG="-m" 33 fi 34 AC_SUBST(COMPILER_TARGET_BITS_FLAG) 35 36 # FIXME: figure out if we should select AR flags depending on OS or toolchain. 37 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 38 ARFLAGS="-r" 39 elif test "x$OPENJDK_TARGET_OS" = xaix; then 40 ARFLAGS="-X64" 41 elif test "x$OPENJDK_TARGET_OS" = xwindows; then 42 # lib.exe is used as AR to create static libraries. 43 ARFLAGS="-nologo -NODEFAULTLIB:MSVCRT" 44 else 45 ARFLAGS="" 46 fi 47 AC_SUBST(ARFLAGS) 48 49 ## Setup strip. 50 # FIXME: should this really be per platform, or should it be per toolchain type? 51 # strip is not provided by clang or solstudio; so guessing platform makes most sense. 52 # FIXME: we should really only export STRIPFLAGS from here, not POST_STRIP_CMD. 53 if test "x$OPENJDK_TARGET_OS" = xlinux; then 54 STRIPFLAGS="-g" 55 elif test "x$OPENJDK_TARGET_OS" = xsolaris; then 56 STRIPFLAGS="-x" 57 elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 58 STRIPFLAGS="-S" 59 elif test "x$OPENJDK_TARGET_OS" = xaix; then 60 STRIPFLAGS="-X32_64" 61 fi 62 63 if test "x$OPENJDK_TARGET_OS" != xwindows; then 64 POST_STRIP_CMD="$STRIP $STRIPFLAGS" 65 fi 66 AC_SUBST(POST_STRIP_CMD) 67 68 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 69 # FIXME: break out into MCSFLAGS 70 POST_MCS_CMD="$MCS -d -a \"JDK $FULL_VERSION\"" 71 fi 72 AC_SUBST(POST_MCS_CMD) 73 74 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 75 CC_OUT_OPTION=-Fo 76 EXE_OUT_OPTION=-out: 77 LD_OUT_OPTION=-out: 78 AR_OUT_OPTION=-out: 79 else 80 # The option used to specify the target .o,.a or .so file. 81 # When compiling, how to specify the to be created object file. 82 CC_OUT_OPTION='-o$(SPACE)' 83 # When linking, how to specify the to be created executable. 84 EXE_OUT_OPTION='-o$(SPACE)' 85 # When linking, how to specify the to be created dynamically linkable library. 86 LD_OUT_OPTION='-o$(SPACE)' 87 # When archiving, how to specify the to be create static archive for object files. 88 AR_OUT_OPTION='rcs$(SPACE)' 89 fi 90 AC_SUBST(CC_OUT_OPTION) 91 AC_SUBST(EXE_OUT_OPTION) 92 AC_SUBST(LD_OUT_OPTION) 93 AC_SUBST(AR_OUT_OPTION) 94 95 # On Windows, we need to set RC flags. 96 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 97 RC_FLAGS="-nologo -l 0x409 -r" 98 if test "x$VARIANT" = xOPT; then 99 RC_FLAGS="$RC_FLAGS -d NDEBUG" 100 fi 101 102 # The version variables used to create RC_FLAGS may be overridden 103 # in a custom configure script, or possibly the command line. 104 # Let those variables be expanded at make time in spec.gmk. 105 # The \$ are escaped to the shell, and the $(...) variables 106 # are evaluated by make. 107 RC_FLAGS="$RC_FLAGS \ 108 -d \"JDK_BUILD_ID=\$(FULL_VERSION)\" \ 109 -d \"JDK_COMPANY=\$(COMPANY_NAME)\" \ 110 -d \"JDK_COMPONENT=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) binary\" \ 111 -d \"JDK_VER=\$(JDK_MINOR_VERSION).\$(JDK_MICRO_VERSION).\$(if \$(JDK_UPDATE_VERSION),\$(JDK_UPDATE_VERSION),0).\$(COOKED_BUILD_NUMBER)\" \ 112 -d \"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \ 113 -d \"JDK_NAME=\$(PRODUCT_NAME) \$(JDK_RC_PLATFORM_NAME) \$(JDK_MINOR_VERSION) \$(JDK_UPDATE_META_TAG)\" \ 114 -d \"JDK_FVER=\$(JDK_MINOR_VERSION),\$(JDK_MICRO_VERSION),\$(if \$(JDK_UPDATE_VERSION),\$(JDK_UPDATE_VERSION),0),\$(COOKED_BUILD_NUMBER)\"" 115 fi 116 AC_SUBST(RC_FLAGS) 117 118 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 119 # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX. 120 CCXXFLAGS="$CCXXFLAGS -nologo" 121 fi 122 123 if test "x$SYSROOT" != "x"; then 124 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then 125 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 126 # Solaris Studio does not have a concept of sysroot. Instead we must 127 # make sure the default include and lib dirs are appended to each 128 # compile and link command line. 129 SYSROOT_CFLAGS="-I$SYSROOT/usr/include" 130 SYSROOT_LDFLAGS="-L$SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \ 131 -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \ 132 -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR" 133 fi 134 elif test "x$TOOLCHAIN_TYPE" = xgcc; then 135 SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\"" 136 SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\"" 137 elif test "x$TOOLCHAIN_TYPE" = xclang; then 138 SYSROOT_CFLAGS="-isysroot \"$SYSROOT\"" 139 SYSROOT_LDFLAGS="-isysroot \"$SYSROOT\"" 140 fi 141 # Propagate the sysroot args to hotspot 142 LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $SYSROOT_CFLAGS" 143 LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $SYSROOT_CFLAGS" 144 LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS" 145 fi 146 AC_SUBST(SYSROOT_CFLAGS) 147 AC_SUBST(SYSROOT_LDFLAGS) 148]) 149 150AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS], 151[ 152 ############################################################################### 153 # 154 # How to compile shared libraries. 155 # 156 157 if test "x$TOOLCHAIN_TYPE" = xgcc; then 158 PICFLAG="-fPIC" 159 C_FLAG_REORDER='' 160 CXX_FLAG_REORDER='' 161 162 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 163 # Linking is different on MacOSX 164 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG" 165 SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.' 166 SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN" 167 SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 168 SET_SHARED_LIBRARY_MAPFILE='' 169 else 170 # Default works for linux, might work on other platforms as well. 171 SHARED_LIBRARY_FLAGS='-shared' 172 SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1' 173 SET_SHARED_LIBRARY_ORIGIN="-Xlinker -z -Xlinker origin $SET_EXECUTABLE_ORIGIN" 174 SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1' 175 SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1' 176 fi 177 elif test "x$TOOLCHAIN_TYPE" = xclang; then 178 PICFLAG='' 179 C_FLAG_REORDER='' 180 CXX_FLAG_REORDER='' 181 182 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 183 # Linking is different on MacOSX 184 SHARED_LIBRARY_FLAGS="-dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $PICFLAG" 185 SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker @loader_path/.' 186 SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN" 187 SET_SHARED_LIBRARY_NAME='-Xlinker -install_name -Xlinker @rpath/[$]1' 188 SET_SHARED_LIBRARY_MAPFILE='' 189 else 190 # Default works for linux, might work on other platforms as well. 191 SHARED_LIBRARY_FLAGS='-shared' 192 SET_EXECUTABLE_ORIGIN='-Xlinker -rpath -Xlinker \$$$$ORIGIN[$]1' 193 SET_SHARED_LIBRARY_ORIGIN="-Xlinker -z -Xlinker origin $SET_EXECUTABLE_ORIGIN" 194 SET_SHARED_LIBRARY_NAME='-Xlinker -soname=[$]1' 195 SET_SHARED_LIBRARY_MAPFILE='-Xlinker -version-script=[$]1' 196 fi 197 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then 198 PICFLAG="-KPIC" 199 C_FLAG_REORDER='-xF' 200 CXX_FLAG_REORDER='-xF' 201 SHARED_LIBRARY_FLAGS="-G" 202 SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1' 203 SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN" 204 SET_SHARED_LIBRARY_NAME='' 205 SET_SHARED_LIBRARY_MAPFILE='-M[$]1' 206 elif test "x$TOOLCHAIN_TYPE" = xxlc; then 207 PICFLAG="-qpic=large" 208 C_FLAG_REORDER='' 209 CXX_FLAG_REORDER='' 210 SHARED_LIBRARY_FLAGS="-qmkshrobj" 211 SET_EXECUTABLE_ORIGIN="" 212 SET_SHARED_LIBRARY_ORIGIN='' 213 SET_SHARED_LIBRARY_NAME='' 214 SET_SHARED_LIBRARY_MAPFILE='' 215 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 216 PICFLAG="" 217 C_FLAG_REORDER='' 218 CXX_FLAG_REORDER='' 219 SHARED_LIBRARY_FLAGS="-LD" 220 SET_EXECUTABLE_ORIGIN='' 221 SET_SHARED_LIBRARY_ORIGIN='' 222 SET_SHARED_LIBRARY_NAME='' 223 SET_SHARED_LIBRARY_MAPFILE='' 224 fi 225 226 AC_SUBST(C_FLAG_REORDER) 227 AC_SUBST(CXX_FLAG_REORDER) 228 AC_SUBST(SHARED_LIBRARY_FLAGS) 229 AC_SUBST(SET_EXECUTABLE_ORIGIN) 230 AC_SUBST(SET_SHARED_LIBRARY_ORIGIN) 231 AC_SUBST(SET_SHARED_LIBRARY_NAME) 232 AC_SUBST(SET_SHARED_LIBRARY_MAPFILE) 233 234 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 235 CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__" 236 CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__" 237 CFLAGS_JDKLIB_EXTRA='-xstrconst' 238 fi 239 # The (cross) compiler is now configured, we can now test capabilities 240 # of the target platform. 241]) 242 243# Documentation on common flags used for solstudio in HIGHEST. 244# 245# WARNING: Use of OPTIMIZATION_LEVEL=HIGHEST in your Makefile needs to be 246# done with care, there are some assumptions below that need to 247# be understood about the use of pointers, and IEEE behavior. 248# 249# -fns: Use non-standard floating point mode (not IEEE 754) 250# -fsimple: Do some simplification of floating point arithmetic (not IEEE 754) 251# -fsingle: Use single precision floating point with 'float' 252# -xalias_level=basic: Assume memory references via basic pointer types do not alias 253# (Source with excessing pointer casting and data access with mixed 254# pointer types are not recommended) 255# -xbuiltin=%all: Use intrinsic or inline versions for math/std functions 256# (If you expect perfect errno behavior, do not use this) 257# -xdepend: Loop data dependency optimizations (need -xO3 or higher) 258# -xrestrict: Pointer parameters to functions do not overlap 259# (Similar to -xalias_level=basic usage, but less obvious sometimes. 260# If you pass in multiple pointers to the same data, do not use this) 261# -xlibmil: Inline some library routines 262# (If you expect perfect errno behavior, do not use this) 263# -xlibmopt: Use optimized math routines (CURRENTLY DISABLED) 264# (If you expect perfect errno behavior, do not use this) 265# Can cause undefined external on Solaris 8 X86 on __sincos, removing for now 266 267 # FIXME: this will never happen since sparc != sparcv9, ie 32 bit, which we don't build anymore. 268 # Bug? 269 #if test "x$OPENJDK_TARGET_CPU" = xsparc; then 270 # CFLAGS_JDK="${CFLAGS_JDK} -xmemalign=4s" 271 # CXXFLAGS_JDK="${CXXFLAGS_JDK} -xmemalign=4s" 272 #fi 273 274AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], 275[ 276 277 ############################################################################### 278 # 279 # Setup the opt flags for different compilers 280 # and different operating systems. 281 # 282 283 # FIXME: this was indirectly the old default, but just inherited. 284 # if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 285 # C_FLAG_DEPS="-MMD -MF" 286 # fi 287 288 # Generate make dependency files 289 if test "x$TOOLCHAIN_TYPE" = xgcc; then 290 C_FLAG_DEPS="-MMD -MF" 291 elif test "x$TOOLCHAIN_TYPE" = xclang; then 292 C_FLAG_DEPS="-MMD -MF" 293 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then 294 C_FLAG_DEPS="-xMMD -xMF" 295 elif test "x$TOOLCHAIN_TYPE" = xxlc; then 296 C_FLAG_DEPS="-qmakedep=gcc -MF" 297 fi 298 CXX_FLAG_DEPS="$C_FLAG_DEPS" 299 AC_SUBST(C_FLAG_DEPS) 300 AC_SUBST(CXX_FLAG_DEPS) 301 302 # Debug symbols 303 if test "x$TOOLCHAIN_TYPE" = xgcc; then 304 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then 305 CFLAGS_DEBUG_SYMBOLS="-g1" 306 CXXFLAGS_DEBUG_SYMBOLS="-g1" 307 else 308 CFLAGS_DEBUG_SYMBOLS="-g" 309 CXXFLAGS_DEBUG_SYMBOLS="-g" 310 fi 311 elif test "x$TOOLCHAIN_TYPE" = xclang; then 312 CFLAGS_DEBUG_SYMBOLS="-g" 313 CXXFLAGS_DEBUG_SYMBOLS="-g" 314 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then 315 CFLAGS_DEBUG_SYMBOLS="-g -xs" 316 CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs" 317 elif test "x$TOOLCHAIN_TYPE" = xxlc; then 318 CFLAGS_DEBUG_SYMBOLS="-g" 319 CXXFLAGS_DEBUG_SYMBOLS="-g" 320 fi 321 AC_SUBST(CFLAGS_DEBUG_SYMBOLS) 322 AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS) 323 324 # Optimization levels 325 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then 326 CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil" 327 328 if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then 329 # FIXME: seems we always set -xregs=no%frameptr; put it elsewhere more global? 330 C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr" 331 C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr" 332 C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr" 333 C_O_FLAG_NONE="-xregs=no%frameptr" 334 CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr" 335 CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr" 336 CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr" 337 CXX_O_FLAG_NONE="-xregs=no%frameptr" 338 if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then 339 C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium" 340 CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_HIGHEST -xchip=pentium" 341 fi 342 elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then 343 C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra" 344 C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0" 345 C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0" 346 C_O_FLAG_NONE="" 347 CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra" 348 CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" 349 CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" 350 CXX_O_FLAG_NONE="" 351 fi 352 else 353 # The remaining toolchains share opt flags between CC and CXX; 354 # setup for C and duplicate afterwards. 355 if test "x$TOOLCHAIN_TYPE" = xgcc; then 356 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 357 # On MacOSX we optimize for size, something 358 # we should do for all platforms? 359 C_O_FLAG_HIGHEST="-Os" 360 C_O_FLAG_HI="-Os" 361 C_O_FLAG_NORM="-Os" 362 C_O_FLAG_NONE="" 363 else 364 C_O_FLAG_HIGHEST="-O3" 365 C_O_FLAG_HI="-O3" 366 C_O_FLAG_NORM="-O2" 367 C_O_FLAG_NONE="-O0" 368 fi 369 elif test "x$TOOLCHAIN_TYPE" = xclang; then 370 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 371 # On MacOSX we optimize for size, something 372 # we should do for all platforms? 373 C_O_FLAG_HIGHEST="-Os" 374 C_O_FLAG_HI="-Os" 375 C_O_FLAG_NORM="-Os" 376 C_O_FLAG_NONE="" 377 else 378 C_O_FLAG_HIGHEST="-O3" 379 C_O_FLAG_HI="-O3" 380 C_O_FLAG_NORM="-O2" 381 C_O_FLAG_NONE="-O0" 382 fi 383 elif test "x$TOOLCHAIN_TYPE" = xxlc; then 384 C_O_FLAG_HIGHEST="-O3" 385 C_O_FLAG_HI="-O3 -qstrict" 386 C_O_FLAG_NORM="-O2" 387 C_O_FLAG_NONE="" 388 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 389 C_O_FLAG_HIGHEST="-O2" 390 C_O_FLAG_HI="-O1" 391 C_O_FLAG_NORM="-O1" 392 C_O_FLAG_NONE="-Od" 393 fi 394 CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST" 395 CXX_O_FLAG_HI="$C_O_FLAG_HI" 396 CXX_O_FLAG_NORM="$C_O_FLAG_NORM" 397 CXX_O_FLAG_NONE="$C_O_FLAG_NONE" 398 fi 399 400 AC_SUBST(C_O_FLAG_HIGHEST) 401 AC_SUBST(C_O_FLAG_HI) 402 AC_SUBST(C_O_FLAG_NORM) 403 AC_SUBST(C_O_FLAG_NONE) 404 AC_SUBST(CXX_O_FLAG_HIGHEST) 405 AC_SUBST(CXX_O_FLAG_HI) 406 AC_SUBST(CXX_O_FLAG_NORM) 407 AC_SUBST(CXX_O_FLAG_NONE) 408]) 409 410AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], 411[ 412 # Special extras... 413 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then 414 if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then 415 CFLAGS_JDKLIB_EXTRA="${CFLAGS_JDKLIB_EXTRA} -xregs=no%appl" 416 CXXFLAGS_JDKLIB_EXTRA="${CXXFLAGS_JDKLIB_EXTRA} -xregs=no%appl" 417 fi 418 elif test "x$TOOLCHAIN_TYPE" = xxlc; then 419 LDFLAGS_JDK="${LDFLAGS_JDK} -q64 -brtl -bnolibpath -liconv -bexpall" 420 CFLAGS_JDK="${CFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt" 421 CXXFLAGS_JDK="${CXXFLAGS_JDK} -qchars=signed -q64 -qfullpath -qsaveopt" 422 fi 423 424 if test "x$CFLAGS" != "x${ADDED_CFLAGS}"; then 425 AC_MSG_WARN([Ignoring CFLAGS($CFLAGS) found in environment. Use --with-extra-cflags]) 426 fi 427 428 if test "x$CXXFLAGS" != "x${ADDED_CXXFLAGS}"; then 429 AC_MSG_WARN([Ignoring CXXFLAGS($CXXFLAGS) found in environment. Use --with-extra-cxxflags]) 430 fi 431 432 if test "x$LDFLAGS" != "x${ADDED_LDFLAGS}"; then 433 AC_MSG_WARN([Ignoring LDFLAGS($LDFLAGS) found in environment. Use --with-extra-ldflags]) 434 fi 435 436 AC_ARG_WITH(extra-cflags, [AS_HELP_STRING([--with-extra-cflags], 437 [extra flags to be used when compiling jdk c-files])]) 438 439 AC_ARG_WITH(extra-cxxflags, [AS_HELP_STRING([--with-extra-cxxflags], 440 [extra flags to be used when compiling jdk c++-files])]) 441 442 AC_ARG_WITH(extra-ldflags, [AS_HELP_STRING([--with-extra-ldflags], 443 [extra flags to be used when linking jdk])]) 444 445 CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags" 446 CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags" 447 LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags" 448 449 # Hotspot needs these set in their legacy form 450 LEGACY_EXTRA_CFLAGS="$LEGACY_EXTRA_CFLAGS $with_extra_cflags" 451 LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $with_extra_cxxflags" 452 LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $with_extra_ldflags" 453 454 AC_SUBST(LEGACY_EXTRA_CFLAGS) 455 AC_SUBST(LEGACY_EXTRA_CXXFLAGS) 456 AC_SUBST(LEGACY_EXTRA_LDFLAGS) 457 458 ############################################################################### 459 # 460 # Now setup the CFLAGS and LDFLAGS for the JDK build. 461 # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build. 462 # 463 464 # Setup compiler/platform specific flags to CFLAGS_JDK, 465 # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?) 466 if test "x$TOOLCHAIN_TYPE" = xgcc; then 467 # these options are used for both C and C++ compiles 468 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ 469 -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" 470 case $OPENJDK_TARGET_CPU_ARCH in 471 arm ) 472 # on arm we don't prevent gcc to omit frame pointer but do prevent strict aliasing 473 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" 474 ;; 475 ppc ) 476 # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing 477 ;; 478 * ) 479 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer" 480 CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" 481 ;; 482 esac 483 elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then 484 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" 485 if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then 486 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" 487 CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE" 488 fi 489 490 CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal" 491 CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib" 492 elif test "x$TOOLCHAIN_TYPE" = xxlc; then 493 CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" 494 CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" 495 elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 496 CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ 497 -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \ 498 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \ 499 -DWIN32 -DIAL" 500 if test "x$OPENJDK_TARGET_CPU" = xx86_64; then 501 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64" 502 else 503 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86" 504 fi 505 fi 506 507 ############################################################################### 508 509 # Adjust flags according to debug level. 510 case $DEBUG_LEVEL in 511 fastdebug ) 512 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" 513 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" 514 C_O_FLAG_HI="$C_O_FLAG_NORM" 515 C_O_FLAG_NORM="$C_O_FLAG_NORM" 516 CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" 517 CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM" 518 JAVAC_FLAGS="$JAVAC_FLAGS -g" 519 ;; 520 slowdebug ) 521 CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" 522 CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" 523 C_O_FLAG_HI="$C_O_FLAG_NONE" 524 C_O_FLAG_NORM="$C_O_FLAG_NONE" 525 CXX_O_FLAG_HI="$CXX_O_FLAG_NONE" 526 CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE" 527 JAVAC_FLAGS="$JAVAC_FLAGS -g" 528 ;; 529 esac 530 531 # Setup LP64 532 CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64" 533 534 # Set some common defines. These works for all compilers, but assume 535 # -D is universally accepted. 536 537 # Setup endianness 538 if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then 539 # The macro _LITTLE_ENDIAN needs to be defined the same to avoid the 540 # Sun C compiler warning message: warning: macro redefined: _LITTLE_ENDIAN 541 # (The Solaris X86 system defines this in file /usr/include/sys/isa_defs.h). 542 # Note: -Dmacro is the same as #define macro 1 543 # -Dmacro= is the same as #define macro 544 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 545 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" 546 else 547 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN" 548 fi 549 else 550 # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they 551 # are defined in the system? 552 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 553 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN=" 554 else 555 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN" 556 fi 557 fi 558 559 # Setup target OS define. Use OS target name but in upper case. 560 OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` 561 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" 562 563 # Setup target CPU 564 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" 565 566 # Setup debug/release defines 567 if test "x$DEBUG_LEVEL" = xrelease; then 568 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG" 569 if test "x$OPENJDK_TARGET_OS" = xsolaris; then 570 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED" 571 fi 572 else 573 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG" 574 fi 575 576 # Setup release name 577 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" 578 579 580 # Set some additional per-OS defines. 581 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 582 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" 583 elif test "x$OPENJDK_TARGET_OS" = xaix; then 584 # FIXME: PPC64 should not be here. 585 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64" 586 elif test "x$OPENJDK_TARGET_OS" = xbsd; then 587 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE" 588 fi 589 590 # Additional macosx handling 591 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 592 if test "x$TOOLCHAIN_TYPE" = xgcc; then 593 # FIXME: This needs to be exported in spec.gmk due to closed legacy code. 594 # FIXME: clean this up, and/or move it elsewhere. 595 596 # Setting these parameters makes it an error to link to macosx APIs that are 597 # newer than the given OS version and makes the linked binaries compatible 598 # even if built on a newer version of the OS. 599 # The expected format is X.Y.Z 600 MACOSX_VERSION_MIN=10.7.0 601 AC_SUBST(MACOSX_VERSION_MIN) 602 603 # The macro takes the version with no dots, ex: 1070 604 # Let the flags variables get resolved in make for easier override on make 605 # command line. 606 CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" 607 LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" 608 fi 609 fi 610 611 # Setup some hard coded includes 612 CCXXFLAGS_JDK="$CCXXFLAGS_JDK \ 613 -I${JDK_OUTPUTDIR}/include \ 614 -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \ 615 -I${JDK_TOPDIR}/src/share/javavm/export \ 616 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \ 617 -I${JDK_TOPDIR}/src/share/native/common \ 618 -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common" 619 620 # The shared libraries are compiled using the picflag. 621 CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" 622 CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " 623 624 # Executable flags 625 CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK" 626 CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK" 627 628 AC_SUBST(CFLAGS_JDKLIB) 629 AC_SUBST(CFLAGS_JDKEXE) 630 AC_SUBST(CXXFLAGS_JDKLIB) 631 AC_SUBST(CXXFLAGS_JDKEXE) 632 633 # Setup LDFLAGS et al. 634 # 635 # Now this is odd. The JDK native libraries have to link against libjvm.so 636 # On 32-bit machines there is normally two distinct libjvm.so:s, client and server. 637 # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library 638 # is identical for client and server? Yes. Which is picked at runtime (client or server)? 639 # Neither, since the chosen libjvm.so has already been loaded by the launcher, all the following 640 # libraries will link to whatever is in memory. Yuck. 641 # 642 # Thus we offer the compiler to find libjvm.so first in server then in client. It works. Ugh. 643 if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 644 LDFLAGS_JDK="$LDFLAGS_JDK -nologo -opt:ref -incremental:no" 645 if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then 646 LDFLAGS_JDK="$LDFLAGS_JDK -safeseh" 647 fi 648 # TODO: make -debug optional "--disable-full-debug-symbols" 649 LDFLAGS_JDK="$LDFLAGS_JDK -debug" 650 LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib" 651 LDFLAGS_JDKLIB_SUFFIX="" 652 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then 653 LDFLAGS_STACK_SIZE=1048576 654 else 655 LDFLAGS_STACK_SIZE=327680 656 fi 657 LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE" 658 else 659 if test "x$TOOLCHAIN_TYPE" = xgcc; then 660 # If this is a --hash-style=gnu system, use --hash-style=both, why? 661 # We have previously set HAS_GNU_HASH if this is the case 662 if test -n "$HAS_GNU_HASH"; then 663 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both " 664 fi 665 if test "x$OPENJDK_TARGET_OS" = xlinux; then 666 # And since we now know that the linker is gnu, then add -z defs, to forbid 667 # undefined symbols in object files. 668 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" 669 if test "x$DEBUG_LEVEL" = "xrelease"; then 670 # When building release libraries, tell the linker optimize them. 671 # Should this be supplied to the OSS linker as well? 672 LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" 673 fi 674 fi 675 fi 676 677 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then 678 LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" 679 LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" 680 fi 681 682 LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \ 683 -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" 684 685 # On some platforms (mac) the linker warns about non existing -L dirs. 686 # Add server first if available. Linking aginst client does not always produce the same results. 687 # Only add client dir if client is being built. Add minimal (note not minimal1) if only building minimal1. 688 # Default to server for other variants. 689 if test "x$JVM_VARIANT_SERVER" = xtrue; then 690 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server" 691 elif test "x$JVM_VARIANT_CLIENT" = xtrue; then 692 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/client" 693 elif test "x$JVM_VARIANT_MINIMAL1" = xtrue; then 694 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/minimal" 695 else 696 LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}/server" 697 fi 698 699 LDFLAGS_JDKLIB_SUFFIX="-ljava -ljvm" 700 if test "x$TOOLCHAIN_TYPE" = xsolstudio; then 701 LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc" 702 fi 703 704 LDFLAGS_JDKEXE="${LDFLAGS_JDK}" 705 if test "x$OPENJDK_TARGET_OS" = xlinux; then 706 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" 707 fi 708 fi 709 AC_SUBST(LDFLAGS_JDKLIB) 710 AC_SUBST(LDFLAGS_JDKEXE) 711 AC_SUBST(LDFLAGS_JDKLIB_SUFFIX) 712 AC_SUBST(LDFLAGS_JDKEXE_SUFFIX) 713 AC_SUBST(LDFLAGS_CXX_JDK) 714]) 715 716 717# FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], 718# [RUN-IF-FALSE]) 719# ------------------------------------------------------------ 720# Check that the c and c++ compilers support an argument 721AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], 722[ 723 AC_MSG_CHECKING([if compiler supports "$1"]) 724 supports=yes 725 726 saved_cflags="$CFLAGS" 727 CFLAGS="$CFLAGS $1" 728 AC_LANG_PUSH([C]) 729 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 730 [supports=no]) 731 AC_LANG_POP([C]) 732 CFLAGS="$saved_cflags" 733 734 saved_cxxflags="$CXXFLAGS" 735 CXXFLAGS="$CXXFLAG $1" 736 AC_LANG_PUSH([C++]) 737 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], 738 [supports=no]) 739 AC_LANG_POP([C++]) 740 CXXFLAGS="$saved_cxxflags" 741 742 AC_MSG_RESULT([$supports]) 743 if test "x$supports" = "xyes" ; then 744 m4_ifval([$2], [$2], [:]) 745 else 746 m4_ifval([$3], [$3], [:]) 747 fi 748]) 749 750AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC], 751[ 752 # Some Zero and Shark settings. 753 # ZERO_ARCHFLAG tells the compiler which mode to build for 754 case "${OPENJDK_TARGET_CPU}" in 755 s390) 756 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}31" 757 ;; 758 *) 759 ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}" 760 esac 761 FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""]) 762 AC_SUBST(ZERO_ARCHFLAG) 763 764 # Check that the compiler supports -mX (or -qX on AIX) flags 765 # Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does 766 FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}], 767 [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true], 768 [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false]) 769 AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG) 770 771 case "${TOOLCHAIN_TYPE}" in 772 microsoft) 773 CFLAGS_WARNINGS_ARE_ERRORS="/WX" 774 ;; 775 solstudio) 776 CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all" 777 ;; 778 gcc) 779 CFLAGS_WARNINGS_ARE_ERRORS="-Werror" 780 ;; 781 clang) 782 CFLAGS_WARNINGS_ARE_ERRORS="-Werror" 783 ;; 784 esac 785 AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS) 786]) 787