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