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