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