1 # 2 # Copyright (c) 2011, 2023, 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 ############################################################################### 27 # Set the debug level 28 # release: no debug information, all optimizations, no asserts. 29 # optimized: no debug information, all optimizations, no asserts, HotSpot target is 'optimized'. 30 # fastdebug: debug information (-g), all optimizations, all asserts 31 # slowdebug: debug information (-g), no optimizations, all asserts 32 AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_LEVEL], 33 [ 34 DEBUG_LEVEL="release" 35 36 UTIL_ARG_ENABLE(NAME: debug, DEFAULT: false, RESULT: ENABLE_DEBUG, 37 DESC: [enable debugging (shorthand for --with-debug-level=fastdebug)], 38 IF_ENABLED: [ DEBUG_LEVEL="fastdebug" ]) 39 40 AC_MSG_CHECKING([which debug level to use]) 41 AC_ARG_WITH([debug-level], [AS_HELP_STRING([--with-debug-level], 42 [set the debug level (release, fastdebug, slowdebug, optimized) @<:@release@:>@])], 43 [ 44 DEBUG_LEVEL="${withval}" 45 if test "x$ENABLE_DEBUG" = xtrue; then 46 AC_MSG_ERROR([You cannot use both --enable-debug and --with-debug-level at the same time.]) 47 fi 48 ]) 49 AC_MSG_RESULT([$DEBUG_LEVEL]) 50 51 if test "x$DEBUG_LEVEL" != xrelease && \ 52 test "x$DEBUG_LEVEL" != xoptimized && \ 53 test "x$DEBUG_LEVEL" != xfastdebug && \ 54 test "x$DEBUG_LEVEL" != xslowdebug; then 55 AC_MSG_ERROR([Allowed debug levels are: release, fastdebug, slowdebug and optimized]) 56 fi 57 58 # Translate DEBUG_LEVEL to debug level used by Hotspot 59 HOTSPOT_DEBUG_LEVEL="$DEBUG_LEVEL" 60 if test "x$DEBUG_LEVEL" = xrelease; then 61 HOTSPOT_DEBUG_LEVEL="product" 62 elif test "x$DEBUG_LEVEL" = xslowdebug; then 63 HOTSPOT_DEBUG_LEVEL="debug" 64 fi 65 66 if test "x$DEBUG_LEVEL" = xoptimized; then 67 # The debug level 'optimized' is a little special because it is currently only 68 # applicable to the HotSpot build where it means to build a completely 69 # optimized version of the VM without any debugging code (like for the 70 # 'release' debug level which is called 'product' in the HotSpot build) but 71 # with the exception that it can contain additional code which is otherwise 72 # protected by '#ifndef PRODUCT' macros. These 'optimized' builds are used to 73 # test new and/or experimental features which are not intended for customer 74 # shipment. Because these new features need to be tested and benchmarked in 75 # real world scenarios, we want to build the containing JDK at the 'release' 76 # debug level. 77 DEBUG_LEVEL="release" 78 fi 79 80 AC_SUBST(HOTSPOT_DEBUG_LEVEL) 81 AC_SUBST(DEBUG_LEVEL) 82 ]) 83 84 ############################################################################### 85 # 86 # Should we build only OpenJDK even if closed sources are present? 87 # 88 AC_DEFUN_ONCE([JDKOPT_SETUP_OPEN_OR_CUSTOM], 89 [ 90 UTIL_ARG_ENABLE(NAME: openjdk-only, DEFAULT: false, 91 RESULT: SUPPRESS_CUSTOM_EXTENSIONS, 92 DESC: [suppress building custom source even if present], 93 CHECKING_MSG: [if custom source is suppressed (openjdk-only)]) 94 ]) 95 96 AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS], 97 [ 98 # Should we build a JDK without a graphical UI? 99 UTIL_ARG_ENABLE(NAME: headless-only, DEFAULT: false, 100 RESULT: ENABLE_HEADLESS_ONLY, 101 DESC: [only build headless (no GUI) support], 102 CHECKING_MSG: [if we should build headless-only (no GUI)]) 103 AC_SUBST(ENABLE_HEADLESS_ONLY) 104 105 # should we linktime gc unused code sections in the JDK build ? 106 if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = xs390x; then 107 LINKTIME_GC_DEFAULT=true 108 else 109 LINKTIME_GC_DEFAULT=false 110 fi 111 112 UTIL_ARG_ENABLE(NAME: linktime-gc, DEFAULT: $LINKTIME_GC_DEFAULT, 113 DEFAULT_DESC: [auto], RESULT: ENABLE_LINKTIME_GC, 114 DESC: [use link time gc on unused code sections in the JDK build], 115 CHECKING_MSG: [if linker should clean out unused code (linktime-gc)]) 116 AC_SUBST(ENABLE_LINKTIME_GC) 117 118 # Check for full doc dependencies 119 FULL_DOCS_AVAILABLE=true 120 AC_MSG_CHECKING([for graphviz dot]) 121 if test "x$DOT" != "x"; then 122 AC_MSG_RESULT([yes]) 123 else 124 AC_MSG_RESULT([no, cannot generate full docs]) 125 FULL_DOCS_AVAILABLE=false 126 fi 127 128 AC_MSG_CHECKING([for pandoc]) 129 if test "x$ENABLE_PANDOC" = "xtrue"; then 130 AC_MSG_RESULT([yes]) 131 else 132 AC_MSG_RESULT([no, cannot generate full docs]) 133 FULL_DOCS_AVAILABLE=false 134 fi 135 136 # Should we build the complete docs, or just a lightweight version? 137 UTIL_ARG_ENABLE(NAME: full-docs, DEFAULT: auto, RESULT: ENABLE_FULL_DOCS, 138 AVAILABLE: $FULL_DOCS_AVAILABLE, DESC: [build complete documentation], 139 DEFAULT_DESC: [enabled if all tools found]) 140 AC_SUBST(ENABLE_FULL_DOCS) 141 142 # Choose cacerts source file 143 AC_ARG_WITH(cacerts-file, [AS_HELP_STRING([--with-cacerts-file], 144 [specify alternative cacerts file])]) 145 AC_MSG_CHECKING([for cacerts file]) 146 if test "x$with_cacerts_file" == x; then 147 AC_MSG_RESULT([default]) 148 else 149 CACERTS_FILE=$with_cacerts_file 150 if test ! -f "$CACERTS_FILE"; then 151 AC_MSG_RESULT([fail]) 152 AC_MSG_ERROR([Specified cacerts file "$CACERTS_FILE" does not exist]) 153 fi 154 AC_MSG_RESULT([$CACERTS_FILE]) 155 fi 156 AC_SUBST(CACERTS_FILE) 157 158 # Choose cacerts source folder for user provided PEM files 159 AC_ARG_WITH(cacerts-src, [AS_HELP_STRING([--with-cacerts-src], 160 [specify alternative cacerts source folder containing certificates])]) 161 CACERTS_SRC="" 162 AC_MSG_CHECKING([for cacerts source]) 163 if test "x$with_cacerts_src" == x; then 164 AC_MSG_RESULT([default]) 165 else 166 CACERTS_SRC=$with_cacerts_src 167 if test ! -d "$CACERTS_SRC"; then 168 AC_MSG_RESULT([fail]) 169 AC_MSG_ERROR([Specified cacerts source folder "$CACERTS_SRC" does not exist]) 170 fi 171 AC_MSG_RESULT([$CACERTS_SRC]) 172 fi 173 AC_SUBST(CACERTS_SRC) 174 175 # Enable or disable unlimited crypto 176 UTIL_ARG_ENABLE(NAME: unlimited-crypto, DEFAULT: true, RESULT: UNLIMITED_CRYPTO, 177 DESC: [enable unlimited crypto policy]) 178 AC_SUBST(UNLIMITED_CRYPTO) 179 180 # Should we build the serviceability agent (SA)? 181 INCLUDE_SA=true 182 if HOTSPOT_CHECK_JVM_VARIANT(zero); then 183 INCLUDE_SA=false 184 fi 185 if test "x$OPENJDK_TARGET_OS" = xaix ; then 186 INCLUDE_SA=false 187 fi 188 if test "x$OPENJDK_TARGET_CPU" = xs390x ; then 189 INCLUDE_SA=false 190 fi 191 AC_SUBST(INCLUDE_SA) 192 193 # Compress jars 194 COMPRESS_JARS=false 195 196 AC_SUBST(COMPRESS_JARS) 197 198 # Setup default copyright year. Mostly overridden when building close to a new year. 199 AC_ARG_WITH(copyright-year, [AS_HELP_STRING([--with-copyright-year], 200 [Set copyright year value for build @<:@current year/source-date@:>@])]) 201 if test "x$with_copyright_year" = xyes; then 202 AC_MSG_ERROR([Copyright year must have a value]) 203 elif test "x$with_copyright_year" != x; then 204 COPYRIGHT_YEAR="$with_copyright_year" 205 elif test "x$SOURCE_DATE" != xupdated; then 206 if test "x$IS_GNU_DATE" = xyes; then 207 COPYRIGHT_YEAR=`$DATE --date=@$SOURCE_DATE +%Y` 208 else 209 COPYRIGHT_YEAR=`$DATE -j -f %s $SOURCE_DATE +%Y` 210 fi 211 else 212 COPYRIGHT_YEAR=`$DATE +'%Y'` 213 fi 214 AC_SUBST(COPYRIGHT_YEAR) 215 216 # Override default library path 217 AC_ARG_WITH([jni-libpath], [AS_HELP_STRING([--with-jni-libpath], 218 [override default JNI library search path])]) 219 AC_MSG_CHECKING([for jni library path]) 220 if test "x${with_jni_libpath}" = "x" || test "x${with_jni_libpath}" = "xno"; then 221 AC_MSG_RESULT([default]) 222 elif test "x${with_jni_libpath}" = "xyes"; then 223 AC_MSG_RESULT([invalid]) 224 AC_MSG_ERROR([The --with-jni-libpath option requires an argument.]) 225 else 226 HOTSPOT_OVERRIDE_LIBPATH=${with_jni_libpath} 227 if test "x$OPENJDK_TARGET_OS" != "xlinux" && 228 test "x$OPENJDK_TARGET_OS" != "xbsd" && 229 test "x$OPENJDK_TARGET_OS" != "xaix"; then 230 AC_MSG_RESULT([fail]) 231 AC_MSG_ERROR([Overriding JNI library path is supported only on Linux, BSD and AIX.]) 232 fi 233 AC_MSG_RESULT(${HOTSPOT_OVERRIDE_LIBPATH}) 234 fi 235 AC_SUBST(HOTSPOT_OVERRIDE_LIBPATH) 236 237 ]) 238 239 ############################################################################### 240 241 AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], 242 [ 243 # 244 # Native debug symbols. 245 # This must be done after the toolchain is setup, since we're looking at objcopy. 246 # 247 AC_MSG_CHECKING([what type of native debug symbols to use]) 248 AC_ARG_WITH([native-debug-symbols], 249 [AS_HELP_STRING([--with-native-debug-symbols], 250 [set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])], 251 [ 252 if test "x$OPENJDK_TARGET_OS" = xwindows; then 253 if test "x$withval" = xinternal; then 254 AC_MSG_ERROR([Windows does not support the parameter 'internal' for --with-native-debug-symbols]) 255 fi 256 fi 257 ], 258 [ 259 if test "x$STATIC_BUILD" = xtrue; then 260 with_native_debug_symbols="none" 261 else 262 with_native_debug_symbols="external" 263 fi 264 ]) 265 AC_MSG_RESULT([$with_native_debug_symbols]) 266 267 if test "x$with_native_debug_symbols" = xnone; then 268 COMPILE_WITH_DEBUG_SYMBOLS=false 269 COPY_DEBUG_SYMBOLS=false 270 ZIP_EXTERNAL_DEBUG_SYMBOLS=false 271 elif test "x$with_native_debug_symbols" = xinternal; then 272 COMPILE_WITH_DEBUG_SYMBOLS=true 273 COPY_DEBUG_SYMBOLS=false 274 ZIP_EXTERNAL_DEBUG_SYMBOLS=false 275 elif test "x$with_native_debug_symbols" = xexternal; then 276 277 if test "x$OPENJDK_TARGET_OS" = xlinux; then 278 if test "x$OBJCOPY" = x; then 279 # enabling of enable-debug-symbols and can't find objcopy 280 # this is an error 281 AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols]) 282 fi 283 fi 284 285 COMPILE_WITH_DEBUG_SYMBOLS=true 286 COPY_DEBUG_SYMBOLS=true 287 ZIP_EXTERNAL_DEBUG_SYMBOLS=false 288 elif test "x$with_native_debug_symbols" = xzipped; then 289 290 if test "x$OPENJDK_TARGET_OS" = xlinux; then 291 if test "x$OBJCOPY" = x; then 292 # enabling of enable-debug-symbols and can't find objcopy 293 # this is an error 294 AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols]) 295 fi 296 fi 297 298 COMPILE_WITH_DEBUG_SYMBOLS=true 299 COPY_DEBUG_SYMBOLS=true 300 ZIP_EXTERNAL_DEBUG_SYMBOLS=true 301 else 302 AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped]) 303 fi 304 305 AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS) 306 AC_SUBST(COPY_DEBUG_SYMBOLS) 307 AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS) 308 309 # Should we add external native debug symbols to the shipped bundles? 310 AC_MSG_CHECKING([if we should add external native debug symbols to the shipped bundles]) 311 AC_ARG_WITH([external-symbols-in-bundles], 312 [AS_HELP_STRING([--with-external-symbols-in-bundles], 313 [which type of external native debug symbol information shall be shipped in product bundles (none, public, full) 314 (e.g. ship full/stripped pdbs on Windows) @<:@none@:>@])]) 315 316 if test "x$with_external_symbols_in_bundles" = x || test "x$with_external_symbols_in_bundles" = xnone ; then 317 AC_MSG_RESULT([no]) 318 elif test "x$with_external_symbols_in_bundles" = xfull || test "x$with_external_symbols_in_bundles" = xpublic ; then 319 if test "x$OPENJDK_TARGET_OS" != xwindows ; then 320 AC_MSG_ERROR([--with-external-symbols-in-bundles currently only works on windows!]) 321 elif test "x$COPY_DEBUG_SYMBOLS" != xtrue ; then 322 AC_MSG_ERROR([--with-external-symbols-in-bundles only works when --with-native-debug-symbols=external is used!]) 323 elif test "x$with_external_symbols_in_bundles" = xfull ; then 324 AC_MSG_RESULT([full]) 325 SHIP_DEBUG_SYMBOLS=full 326 else 327 AC_MSG_RESULT([public]) 328 SHIP_DEBUG_SYMBOLS=public 329 fi 330 else 331 AC_MSG_ERROR([$with_external_symbols_in_bundles is an unknown value for --with-external-symbols-in-bundles]) 332 fi 333 334 AC_SUBST(SHIP_DEBUG_SYMBOLS) 335 ]) 336 337 ################################################################################ 338 # 339 # Native and Java code coverage 340 # 341 AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE], 342 [ 343 UTIL_ARG_ENABLE(NAME: native-coverage, DEFAULT: false, RESULT: GCOV_ENABLED, 344 DESC: [enable native compilation with code coverage data], 345 CHECK_AVAILABLE: [ 346 AC_MSG_CHECKING([if native coverage is available]) 347 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 348 test "x$TOOLCHAIN_TYPE" = "xclang"; then 349 AC_MSG_RESULT([yes]) 350 else 351 AC_MSG_RESULT([no]) 352 AVAILABLE=false 353 fi 354 ], 355 IF_ENABLED: [ 356 GCOV_CFLAGS="-fprofile-arcs -ftest-coverage -fno-inline" 357 GCOV_LDFLAGS="-fprofile-arcs" 358 JVM_CFLAGS="$JVM_CFLAGS $GCOV_CFLAGS" 359 JVM_LDFLAGS="$JVM_LDFLAGS $GCOV_LDFLAGS" 360 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $GCOV_CFLAGS" 361 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $GCOV_CFLAGS" 362 CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $GCOV_CFLAGS" 363 CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS" 364 LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS" 365 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS" 366 ]) 367 AC_SUBST(GCOV_ENABLED) 368 369 AC_ARG_WITH(jcov, [AS_HELP_STRING([--with-jcov], 370 [jcov library location])]) 371 AC_ARG_WITH(jcov-input-jdk, [AS_HELP_STRING([--with-jcov-input-jdk], 372 [jdk image to instrument])]) 373 AC_ARG_WITH(jcov-filters, [AS_HELP_STRING([--with-jcov-filters], 374 [filters to limit code for jcov instrumentation and report generation])]) 375 JCOV_HOME= 376 JCOV_INPUT_JDK= 377 JCOV_ENABLED= 378 JCOV_FILTERS= 379 if test "x$with_jcov" = "x" ; then 380 JCOV_ENABLED="false" 381 else 382 JCOV_HOME="$with_jcov" 383 if test ! -f "$JCOV_HOME/lib/jcov.jar"; then 384 AC_MSG_RESULT([fail]) 385 AC_MSG_ERROR([Invalid JCov bundle: "$JCOV_HOME/lib/jcov.jar" does not exist]) 386 fi 387 JCOV_ENABLED="true" 388 UTIL_FIXUP_PATH(JCOV_HOME) 389 if test "x$with_jcov_input_jdk" != "x" ; then 390 JCOV_INPUT_JDK="$with_jcov_input_jdk" 391 if test ! -f "$JCOV_INPUT_JDK/bin/java" && test ! -f "$JCOV_INPUT_JDK/bin/java.exe"; then 392 AC_MSG_RESULT([fail]) 393 AC_MSG_ERROR([Invalid JDK bundle: "$JCOV_INPUT_JDK/bin/java" does not exist]) 394 fi 395 UTIL_FIXUP_PATH(JCOV_INPUT_JDK) 396 fi 397 if test "x$with_jcov_filters" != "x" ; then 398 JCOV_FILTERS="$with_jcov_filters" 399 fi 400 fi 401 AC_SUBST(JCOV_ENABLED) 402 AC_SUBST(JCOV_HOME) 403 AC_SUBST(JCOV_INPUT_JDK) 404 AC_SUBST(JCOV_FILTERS) 405 ]) 406 407 ############################################################################### 408 # 409 # AddressSanitizer 410 # 411 AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER], 412 [ 413 UTIL_ARG_ENABLE(NAME: asan, DEFAULT: false, RESULT: ASAN_ENABLED, 414 DESC: [enable AddressSanitizer], 415 CHECK_AVAILABLE: [ 416 AC_MSG_CHECKING([if AddressSanitizer (asan) is available]) 417 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 418 test "x$TOOLCHAIN_TYPE" = "xclang" || 419 test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then 420 AC_MSG_RESULT([yes]) 421 else 422 AC_MSG_RESULT([no]) 423 AVAILABLE=false 424 fi 425 ], 426 IF_ENABLED: [ 427 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 428 test "x$TOOLCHAIN_TYPE" = "xclang"; then 429 # ASan is simply incompatible with gcc -Wstringop-truncation. See 430 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85650 431 # It's harmless to be suppressed in clang as well. 432 ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER" 433 ASAN_LDFLAGS="-fsanitize=address" 434 elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then 435 # -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang. 436 ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER" 437 # MSVC produces a warning if you pass -fsanitize=address to the linker. It also complains 438 $ if -DEBUG is not passed to the linker when building with ASan. 439 ASAN_LDFLAGS="-debug" 440 fi 441 JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS" 442 JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS" 443 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $ASAN_CFLAGS" 444 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $ASAN_CFLAGS" 445 CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $ASAN_CFLAGS" 446 CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $ASAN_CFLAGS" 447 LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $ASAN_LDFLAGS" 448 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $ASAN_LDFLAGS" 449 ]) 450 AC_SUBST(ASAN_ENABLED) 451 ]) 452 453 ############################################################################### 454 # 455 # LeakSanitizer 456 # 457 AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER], 458 [ 459 UTIL_ARG_ENABLE(NAME: lsan, DEFAULT: false, RESULT: LSAN_ENABLED, 460 DESC: [enable LeakSanitizer], 461 CHECK_AVAILABLE: [ 462 AC_MSG_CHECKING([if LeakSanitizer (lsan) is available]) 463 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 464 test "x$TOOLCHAIN_TYPE" = "xclang"; then 465 AC_MSG_RESULT([yes]) 466 else 467 AC_MSG_RESULT([no]) 468 AVAILABLE=false 469 fi 470 ], 471 IF_ENABLED: [ 472 LSAN_CFLAGS="-fsanitize=leak -fno-omit-frame-pointer -DLEAK_SANITIZER" 473 LSAN_LDFLAGS="-fsanitize=leak" 474 JVM_CFLAGS="$JVM_CFLAGS $LSAN_CFLAGS" 475 JVM_LDFLAGS="$JVM_LDFLAGS $LSAN_LDFLAGS" 476 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $LSAN_CFLAGS" 477 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $LSAN_CFLAGS" 478 CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $LSAN_CFLAGS" 479 CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $LSAN_CFLAGS" 480 LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $LSAN_LDFLAGS" 481 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $LSAN_LDFLAGS" 482 ]) 483 AC_SUBST(LSAN_ENABLED) 484 ]) 485 486 ############################################################################### 487 # 488 # UndefinedBehaviorSanitizer 489 # 490 AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER], 491 [ 492 # GCC reports lots of likely false positives for stringop-truncation and format-overflow. 493 # Silence them for now. 494 UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base" 495 UBSAN_CFLAGS="$UBSAN_CHECKS -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER" 496 UBSAN_LDFLAGS="$UBSAN_CHECKS" 497 UTIL_ARG_ENABLE(NAME: ubsan, DEFAULT: false, RESULT: UBSAN_ENABLED, 498 DESC: [enable UndefinedBehaviorSanitizer], 499 CHECK_AVAILABLE: [ 500 AC_MSG_CHECKING([if UndefinedBehaviorSanitizer (ubsan) is available]) 501 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 502 test "x$TOOLCHAIN_TYPE" = "xclang"; then 503 AC_MSG_RESULT([yes]) 504 else 505 AC_MSG_RESULT([no]) 506 AVAILABLE=false 507 fi 508 ], 509 IF_ENABLED: [ 510 JVM_CFLAGS="$JVM_CFLAGS $UBSAN_CFLAGS" 511 JVM_LDFLAGS="$JVM_LDFLAGS $UBSAN_LDFLAGS" 512 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $UBSAN_CFLAGS" 513 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $UBSAN_CFLAGS" 514 CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $UBSAN_CFLAGS" 515 CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $UBSAN_CFLAGS" 516 LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $UBSAN_LDFLAGS" 517 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $UBSAN_LDFLAGS" 518 ]) 519 if test "x$UBSAN_ENABLED" = xfalse; then 520 UBSAN_CFLAGS="" 521 UBSAN_LDFLAGS="" 522 fi 523 AC_SUBST(UBSAN_CFLAGS) 524 AC_SUBST(UBSAN_LDFLAGS) 525 AC_SUBST(UBSAN_ENABLED) 526 ]) 527 528 ################################################################################ 529 # 530 # Static build support. When enabled will generate static 531 # libraries instead of shared libraries for all JDK libs. 532 # 533 AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_BUILD], 534 [ 535 UTIL_ARG_ENABLE(NAME: static-build, DEFAULT: false, RESULT: STATIC_BUILD, 536 DESC: [enable static library build], 537 CHECKING_MSG: [if static build is enabled], 538 CHECK_AVAILABLE: [ 539 AC_MSG_CHECKING([if static build is available]) 540 if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then 541 AC_MSG_RESULT([yes]) 542 else 543 AC_MSG_RESULT([no]) 544 AVAILABLE=false 545 fi 546 ], 547 IF_ENABLED: [ 548 STATIC_BUILD_CFLAGS="-DSTATIC_BUILD=1" 549 CFLAGS_JDKLIB_EXTRA="$CFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS" 550 CXXFLAGS_JDKLIB_EXTRA="$CXXFLAGS_JDKLIB_EXTRA $STATIC_BUILD_CFLAGS" 551 ]) 552 AC_SUBST(STATIC_BUILD) 553 ]) 554 555 ################################################################################ 556 # 557 # jmod options. 558 # 559 AC_DEFUN_ONCE([JDKOPT_SETUP_JMOD_OPTIONS], 560 [ 561 # Final JMODs are recompiled often during development, and java.base JMOD 562 # includes the JVM libraries. In release mode, prefer to compress JMODs fully. 563 # In debug mode, pay with a little extra space, but win a lot of CPU time back 564 # with the lightest (but still some) compression. 565 if test "x$DEBUG_LEVEL" = xrelease; then 566 DEFAULT_JMOD_COMPRESS="zip-6" 567 else 568 DEFAULT_JMOD_COMPRESS="zip-1" 569 fi 570 571 UTIL_ARG_WITH(NAME: jmod-compress, TYPE: literal, 572 VALID_VALUES: [zip-0 zip-1 zip-2 zip-3 zip-4 zip-5 zip-6 zip-7 zip-8 zip-9], 573 DEFAULT: $DEFAULT_JMOD_COMPRESS, 574 CHECKING_MSG: [for JMOD compression type], 575 DESC: [specify JMOD compression type (zip-[0-9])] 576 ) 577 AC_SUBST(JMOD_COMPRESS) 578 ]) 579 580 ################################################################################ 581 # 582 # jlink options. 583 # We always keep packaged modules in JDK image. 584 # 585 AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS], 586 [ 587 UTIL_ARG_ENABLE(NAME: keep-packaged-modules, DEFAULT: true, 588 RESULT: JLINK_KEEP_PACKAGED_MODULES, 589 DESC: [enable keeping of packaged modules in jdk image], 590 CHECKING_MSG: [if packaged modules are kept]) 591 AC_SUBST(JLINK_KEEP_PACKAGED_MODULES) 592 ]) 593 594 ################################################################################ 595 # 596 # Enable or disable generation of the classlist at build time 597 # 598 AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST], 599 [ 600 # In GenerateLinkOptData.gmk, DumpLoadedClassList is used to generate the 601 # classlist file. It never will work if CDS is disabled, since the VM will report 602 # an error for DumpLoadedClassList. 603 UTIL_ARG_ENABLE(NAME: generate-classlist, DEFAULT: auto, 604 RESULT: ENABLE_GENERATE_CLASSLIST, AVAILABLE: $ENABLE_CDS, 605 DESC: [enable generation of a CDS classlist at build time], 606 DEFAULT_DESC: [enabled if the JVM feature 'cds' is enabled for all JVM variants], 607 CHECKING_MSG: [if the CDS classlist generation should be enabled]) 608 AC_SUBST(ENABLE_GENERATE_CLASSLIST) 609 ]) 610 611 ################################################################################ 612 # 613 # Optionally filter resource translations 614 # 615 AC_DEFUN([JDKOPT_EXCLUDE_TRANSLATIONS], 616 [ 617 AC_ARG_WITH([exclude-translations], [AS_HELP_STRING([--with-exclude-translations], 618 [a comma separated list of locales to exclude translations for. Default is 619 to include all translations present in the source.])]) 620 621 EXCLUDE_TRANSLATIONS="" 622 AC_MSG_CHECKING([if any translations should be excluded]) 623 if test "x$with_exclude_translations" != "x"; then 624 EXCLUDE_TRANSLATIONS="${with_exclude_translations//,/ }" 625 AC_MSG_RESULT([yes: $EXCLUDE_TRANSLATIONS]) 626 else 627 AC_MSG_RESULT([no]) 628 fi 629 630 AC_SUBST(EXCLUDE_TRANSLATIONS) 631 ]) 632 633 ################################################################################ 634 # 635 # Optionally disable man pages 636 # 637 AC_DEFUN([JDKOPT_ENABLE_DISABLE_MANPAGES], 638 [ 639 UTIL_ARG_ENABLE(NAME: manpages, DEFAULT: true, RESULT: BUILD_MANPAGES, 640 DESC: [enable copying of static man pages], 641 CHECKING_MSG: [if static man pages should be copied]) 642 AC_SUBST(BUILD_MANPAGES) 643 ]) 644 645 ################################################################################ 646 # 647 # Disable the default CDS archive generation 648 # 649 AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE], 650 [ 651 UTIL_ARG_ENABLE(NAME: cds-archive, DEFAULT: auto, RESULT: BUILD_CDS_ARCHIVE, 652 DESC: [enable generation of a default CDS archive in the product image], 653 DEFAULT_DESC: [enabled if possible], 654 CHECKING_MSG: [if a default CDS archive should be generated], 655 CHECK_AVAILABLE: [ 656 AC_MSG_CHECKING([if CDS archive is available]) 657 if test "x$ENABLE_CDS" = "xfalse"; then 658 AC_MSG_RESULT([no (CDS is disabled)]) 659 AVAILABLE=false 660 elif test "x$COMPILE_TYPE" = "xcross"; then 661 AC_MSG_RESULT([no (not possible with cross compilation)]) 662 AVAILABLE=false 663 else 664 AC_MSG_RESULT([yes]) 665 fi 666 ]) 667 AC_SUBST(BUILD_CDS_ARCHIVE) 668 ]) 669 670 ################################################################################ 671 # 672 # Enable the alternative CDS core region alignment 673 # 674 AC_DEFUN([JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT], 675 [ 676 UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: false, 677 RESULT: ENABLE_COMPATIBLE_CDS_ALIGNMENT, 678 DESC: [enable use alternative compatible cds core region alignment], 679 DEFAULT_DESC: [disabled], 680 CHECKING_MSG: [if compatible cds region alignment enabled], 681 CHECK_AVAILABLE: [ 682 AC_MSG_CHECKING([if CDS archive is available]) 683 if test "x$ENABLE_CDS" = "xfalse"; then 684 AVAILABLE=false 685 AC_MSG_RESULT([no (CDS is disabled)]) 686 else 687 AVAILABLE=true 688 AC_MSG_RESULT([yes]) 689 fi 690 ]) 691 AC_SUBST(ENABLE_COMPATIBLE_CDS_ALIGNMENT) 692 ]) 693 694 ################################################################################ 695 # 696 # Disallow any output from containing absolute paths from the build system. 697 # This setting defaults to allowed on debug builds and not allowed on release 698 # builds. 699 # 700 AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT], 701 [ 702 AC_ARG_ENABLE([absolute-paths-in-output], 703 [AS_HELP_STRING([--disable-absolute-paths-in-output], 704 [Set to disable to prevent any absolute paths from the build to end up in 705 any of the build output. @<:@disabled in release builds, otherwise enabled@:>@]) 706 ]) 707 708 AC_MSG_CHECKING([if absolute paths should be allowed in the build output]) 709 if test "x$enable_absolute_paths_in_output" = "xno"; then 710 AC_MSG_RESULT([no, forced]) 711 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false" 712 elif test "x$enable_absolute_paths_in_output" = "xyes"; then 713 AC_MSG_RESULT([yes, forced]) 714 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true" 715 elif test "x$DEBUG_LEVEL" = "xrelease"; then 716 AC_MSG_RESULT([no, release build]) 717 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false" 718 else 719 AC_MSG_RESULT([yes, debug build]) 720 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true" 721 fi 722 723 AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT) 724 ]) 725 726 ################################################################################ 727 # 728 # Check and set options related to reproducible builds. 729 # 730 AC_DEFUN_ONCE([JDKOPT_SETUP_REPRODUCIBLE_BUILD], 731 [ 732 AC_ARG_WITH([source-date], [AS_HELP_STRING([--with-source-date], 733 [how to set SOURCE_DATE_EPOCH ('updated', 'current', 'version' a timestamp or an ISO-8601 date) @<:@current/value of SOURCE_DATE_EPOCH@:>@])], 734 [with_source_date_present=true], [with_source_date_present=false]) 735 736 if test "x$SOURCE_DATE_EPOCH" != x && test "x$with_source_date" != x; then 737 AC_MSG_WARN([--with-source-date will override SOURCE_DATE_EPOCH]) 738 fi 739 740 AC_MSG_CHECKING([what source date to use]) 741 742 if test "x$with_source_date" = xyes; then 743 AC_MSG_ERROR([--with-source-date must have a value]) 744 elif test "x$with_source_date" = x; then 745 if test "x$SOURCE_DATE_EPOCH" != x; then 746 SOURCE_DATE=$SOURCE_DATE_EPOCH 747 with_source_date_present=true 748 AC_MSG_RESULT([$SOURCE_DATE, from SOURCE_DATE_EPOCH]) 749 else 750 # Tell makefiles to take the time from configure 751 SOURCE_DATE=$($DATE +"%s") 752 AC_MSG_RESULT([$SOURCE_DATE, from 'current' (default)]) 753 fi 754 elif test "x$with_source_date" = xupdated; then 755 SOURCE_DATE=updated 756 AC_MSG_RESULT([determined at build time, from 'updated']) 757 elif test "x$with_source_date" = xcurrent; then 758 # Set the current time 759 SOURCE_DATE=$($DATE +"%s") 760 AC_MSG_RESULT([$SOURCE_DATE, from 'current']) 761 elif test "x$with_source_date" = xversion; then 762 # Use the date from version-numbers.conf 763 UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $DEFAULT_VERSION_DATE) 764 if test "x$SOURCE_DATE" = x; then 765 AC_MSG_RESULT([unavailable]) 766 AC_MSG_ERROR([Cannot convert DEFAULT_VERSION_DATE to timestamp]) 767 fi 768 AC_MSG_RESULT([$SOURCE_DATE, from 'version']) 769 else 770 # It's a timestamp, an ISO-8601 date, or an invalid string 771 # Additional [] needed to keep m4 from mangling shell constructs. 772 if [ [[ "$with_source_date" =~ ^[0-9][0-9]*$ ]] ] ; then 773 SOURCE_DATE=$with_source_date 774 AC_MSG_RESULT([$SOURCE_DATE, from timestamp on command line]) 775 else 776 UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $with_source_date) 777 if test "x$SOURCE_DATE" != x; then 778 AC_MSG_RESULT([$SOURCE_DATE, from ISO-8601 date on command line]) 779 else 780 AC_MSG_RESULT([unavailable]) 781 AC_MSG_ERROR([Cannot parse date string "$with_source_date"]) 782 fi 783 fi 784 fi 785 786 ISO_8601_FORMAT_STRING="%Y-%m-%dT%H:%M:%SZ" 787 if test "x$SOURCE_DATE" != xupdated; then 788 # If we have a fixed value for SOURCE_DATE, we need to set SOURCE_DATE_EPOCH 789 # for the rest of configure. 790 SOURCE_DATE_EPOCH="$SOURCE_DATE" 791 if test "x$IS_GNU_DATE" = xyes; then 792 SOURCE_DATE_ISO_8601=`$DATE --utc --date="@$SOURCE_DATE" +"$ISO_8601_FORMAT_STRING" 2> /dev/null` 793 else 794 SOURCE_DATE_ISO_8601=`$DATE -u -j -f "%s" "$SOURCE_DATE" +"$ISO_8601_FORMAT_STRING" 2> /dev/null` 795 fi 796 fi 797 798 AC_SUBST(SOURCE_DATE) 799 AC_SUBST(ISO_8601_FORMAT_STRING) 800 AC_SUBST(SOURCE_DATE_ISO_8601) 801 802 UTIL_DEPRECATED_ARG_ENABLE(reproducible-build) 803 ]) 804 805 ################################################################################ 806 # 807 # Setup signing on macOS. This can either be setup to sign with a real identity 808 # and enabling the hardened runtime, or it can simply add the debug entitlement 809 # com.apple.security.get-task-allow without actually signing any binaries. The 810 # latter is needed to be able to debug processes and dump core files on modern 811 # versions of macOS. It can also be skipped completely. 812 # 813 # Check if codesign will run with the given parameters 814 # $1: Parameters to run with 815 # $2: Checking message 816 # Sets CODESIGN_SUCCESS=true/false 817 AC_DEFUN([JDKOPT_CHECK_CODESIGN_PARAMS], 818 [ 819 PARAMS="$1" 820 MESSAGE="$2" 821 CODESIGN_TESTFILE="$CONFIGURESUPPORT_OUTPUTDIR/codesign-testfile" 822 $RM "$CODESIGN_TESTFILE" 823 $TOUCH "$CODESIGN_TESTFILE" 824 CODESIGN_SUCCESS=false 825 826 $ECHO "check codesign, calling $CODESIGN $PARAMS $CODESIGN_TESTFILE" >&AS_MESSAGE_LOG_FD 827 828 eval \"$CODESIGN\" $PARAMS \"$CODESIGN_TESTFILE\" 2>&AS_MESSAGE_LOG_FD \ 829 >&AS_MESSAGE_LOG_FD && CODESIGN_SUCCESS=true 830 $RM "$CODESIGN_TESTFILE" 831 AC_MSG_CHECKING([$MESSAGE]) 832 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 833 AC_MSG_RESULT([yes]) 834 else 835 AC_MSG_RESULT([no]) 836 fi 837 ]) 838 839 AC_DEFUN([JDKOPT_CHECK_CODESIGN_HARDENED], 840 [ 841 JDKOPT_CHECK_CODESIGN_PARAMS([-s \"$MACOSX_CODESIGN_IDENTITY\" --option runtime], 842 [if codesign with hardened runtime is possible]) 843 ]) 844 845 AC_DEFUN([JDKOPT_CHECK_CODESIGN_DEBUG], 846 [ 847 JDKOPT_CHECK_CODESIGN_PARAMS([-s -], [if debug mode codesign is possible]) 848 ]) 849 850 AC_DEFUN([JDKOPT_SETUP_MACOSX_SIGNING], 851 [ 852 ENABLE_CODESIGN=false 853 if test "x$OPENJDK_TARGET_OS" = "xmacosx" && test "x$CODESIGN" != "x"; then 854 855 UTIL_ARG_WITH(NAME: macosx-codesign, TYPE: literal, OPTIONAL: true, 856 VALID_VALUES: [hardened debug auto], DEFAULT: auto, 857 ENABLED_DEFAULT: true, 858 CHECKING_MSG: [for macosx code signing mode], 859 DESC: [set the macosx code signing mode (hardened, debug, auto)] 860 ) 861 862 MACOSX_CODESIGN_MODE=disabled 863 if test "x$MACOSX_CODESIGN_ENABLED" = "xtrue"; then 864 865 # Check for user provided code signing identity. 866 UTIL_ARG_WITH(NAME: macosx-codesign-identity, TYPE: string, 867 DEFAULT: openjdk_codesign, CHECK_VALUE: [UTIL_CHECK_STRING_NON_EMPTY], 868 DESC: [specify the macosx code signing identity], 869 CHECKING_MSG: [for macosx code signing identity] 870 ) 871 AC_SUBST(MACOSX_CODESIGN_IDENTITY) 872 873 if test "x$MACOSX_CODESIGN" = "xauto"; then 874 # Only try to default to hardened signing on release builds 875 if test "x$DEBUG_LEVEL" = "xrelease"; then 876 JDKOPT_CHECK_CODESIGN_HARDENED 877 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 878 MACOSX_CODESIGN_MODE=hardened 879 fi 880 fi 881 if test "x$MACOSX_CODESIGN_MODE" = "xdisabled"; then 882 JDKOPT_CHECK_CODESIGN_DEBUG 883 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 884 MACOSX_CODESIGN_MODE=debug 885 fi 886 fi 887 AC_MSG_CHECKING([for macosx code signing mode]) 888 AC_MSG_RESULT([$MACOSX_CODESIGN_MODE]) 889 elif test "x$MACOSX_CODESIGN" = "xhardened"; then 890 JDKOPT_CHECK_CODESIGN_HARDENED 891 if test "x$CODESIGN_SUCCESS" = "xfalse"; then 892 AC_MSG_ERROR([Signing with hardened runtime is not possible]) 893 fi 894 MACOSX_CODESIGN_MODE=hardened 895 elif test "x$MACOSX_CODESIGN" = "xdebug"; then 896 JDKOPT_CHECK_CODESIGN_DEBUG 897 if test "x$CODESIGN_SUCCESS" = "xfalse"; then 898 AC_MSG_ERROR([Signing in debug mode is not possible]) 899 fi 900 MACOSX_CODESIGN_MODE=debug 901 else 902 AC_MSG_ERROR([unknown value for --with-macosx-codesign: $MACOSX_CODESIGN]) 903 fi 904 fi 905 AC_SUBST(MACOSX_CODESIGN_IDENTITY) 906 AC_SUBST(MACOSX_CODESIGN_MODE) 907 fi 908 ]) 909 910 ################################################################################ 911 # 912 # fallback linker 913 # 914 AC_DEFUN_ONCE([JDKOPT_SETUP_FALLBACK_LINKER], 915 [ 916 FALLBACK_LINKER_DEFAULT=false 917 918 if HOTSPOT_CHECK_JVM_VARIANT(zero); then 919 FALLBACK_LINKER_DEFAULT=true 920 fi 921 922 UTIL_ARG_ENABLE(NAME: fallback-linker, DEFAULT: $FALLBACK_LINKER_DEFAULT, 923 RESULT: ENABLE_FALLBACK_LINKER, 924 DESC: [enable libffi-based fallback implementation of java.lang.foreign.Linker], 925 CHECKING_MSG: [if fallback linker enabled]) 926 AC_SUBST(ENABLE_FALLBACK_LINKER) 927 ])