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 or disable the default CDS archive generation for Compact Object Headers 673 # 674 AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH], 675 [ 676 UTIL_ARG_ENABLE(NAME: cds-archive-coh, DEFAULT: auto, RESULT: BUILD_CDS_ARCHIVE_COH, 677 DESC: [enable generation of default CDS archives for compact object headers (requires --enable-cds-archive)], 678 DEFAULT_DESC: [auto], 679 CHECKING_MSG: [if default CDS archives for compact object headers should be generated], 680 CHECK_AVAILABLE: [ 681 AC_MSG_CHECKING([if CDS archive with compact object headers is available]) 682 if test "x$BUILD_CDS_ARCHIVE" = "xfalse"; then 683 AC_MSG_RESULT([no (CDS default archive generation is disabled)]) 684 AVAILABLE=false 685 elif test "x$OPENJDK_TARGET_CPU" != "xx86_64" && 686 test "x$OPENJDK_TARGET_CPU" != "xaarch64"; then 687 AC_MSG_RESULT([no (compact object headers not supported for this platform)]) 688 AVAILABLE=false 689 else 690 AC_MSG_RESULT([yes]) 691 AVAILABLE=true 692 fi 693 ]) 694 AC_SUBST(BUILD_CDS_ARCHIVE_COH) 695 ]) 696 697 ################################################################################ 698 # 699 # Enable the alternative CDS core region alignment 700 # 701 AC_DEFUN([JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT], 702 [ 703 UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: false, 704 RESULT: ENABLE_COMPATIBLE_CDS_ALIGNMENT, 705 DESC: [enable use alternative compatible cds core region alignment], 706 DEFAULT_DESC: [disabled], 707 CHECKING_MSG: [if compatible cds region alignment enabled], 708 CHECK_AVAILABLE: [ 709 AC_MSG_CHECKING([if CDS archive is available]) 710 if test "x$ENABLE_CDS" = "xfalse"; then 711 AVAILABLE=false 712 AC_MSG_RESULT([no (CDS is disabled)]) 713 else 714 AVAILABLE=true 715 AC_MSG_RESULT([yes]) 716 fi 717 ]) 718 AC_SUBST(ENABLE_COMPATIBLE_CDS_ALIGNMENT) 719 ]) 720 721 ################################################################################ 722 # 723 # Disallow any output from containing absolute paths from the build system. 724 # This setting defaults to allowed on debug builds and not allowed on release 725 # builds. 726 # 727 AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT], 728 [ 729 AC_ARG_ENABLE([absolute-paths-in-output], 730 [AS_HELP_STRING([--disable-absolute-paths-in-output], 731 [Set to disable to prevent any absolute paths from the build to end up in 732 any of the build output. @<:@disabled in release builds, otherwise enabled@:>@]) 733 ]) 734 735 AC_MSG_CHECKING([if absolute paths should be allowed in the build output]) 736 if test "x$enable_absolute_paths_in_output" = "xno"; then 737 AC_MSG_RESULT([no, forced]) 738 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false" 739 elif test "x$enable_absolute_paths_in_output" = "xyes"; then 740 AC_MSG_RESULT([yes, forced]) 741 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true" 742 elif test "x$DEBUG_LEVEL" = "xrelease"; then 743 AC_MSG_RESULT([no, release build]) 744 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false" 745 else 746 AC_MSG_RESULT([yes, debug build]) 747 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true" 748 fi 749 750 AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT) 751 ]) 752 753 ################################################################################ 754 # 755 # Check and set options related to reproducible builds. 756 # 757 AC_DEFUN_ONCE([JDKOPT_SETUP_REPRODUCIBLE_BUILD], 758 [ 759 AC_ARG_WITH([source-date], [AS_HELP_STRING([--with-source-date], 760 [how to set SOURCE_DATE_EPOCH ('updated', 'current', 'version' a timestamp or an ISO-8601 date) @<:@current/value of SOURCE_DATE_EPOCH@:>@])], 761 [with_source_date_present=true], [with_source_date_present=false]) 762 763 if test "x$SOURCE_DATE_EPOCH" != x && test "x$with_source_date" != x; then 764 AC_MSG_WARN([--with-source-date will override SOURCE_DATE_EPOCH]) 765 fi 766 767 AC_MSG_CHECKING([what source date to use]) 768 769 if test "x$with_source_date" = xyes; then 770 AC_MSG_ERROR([--with-source-date must have a value]) 771 elif test "x$with_source_date" = x; then 772 if test "x$SOURCE_DATE_EPOCH" != x; then 773 SOURCE_DATE=$SOURCE_DATE_EPOCH 774 with_source_date_present=true 775 AC_MSG_RESULT([$SOURCE_DATE, from SOURCE_DATE_EPOCH]) 776 else 777 # Tell makefiles to take the time from configure 778 SOURCE_DATE=$($DATE +"%s") 779 AC_MSG_RESULT([$SOURCE_DATE, from 'current' (default)]) 780 fi 781 elif test "x$with_source_date" = xupdated; then 782 SOURCE_DATE=updated 783 AC_MSG_RESULT([determined at build time, from 'updated']) 784 elif test "x$with_source_date" = xcurrent; then 785 # Set the current time 786 SOURCE_DATE=$($DATE +"%s") 787 AC_MSG_RESULT([$SOURCE_DATE, from 'current']) 788 elif test "x$with_source_date" = xversion; then 789 # Use the date from version-numbers.conf 790 UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $DEFAULT_VERSION_DATE) 791 if test "x$SOURCE_DATE" = x; then 792 AC_MSG_RESULT([unavailable]) 793 AC_MSG_ERROR([Cannot convert DEFAULT_VERSION_DATE to timestamp]) 794 fi 795 AC_MSG_RESULT([$SOURCE_DATE, from 'version']) 796 else 797 # It's a timestamp, an ISO-8601 date, or an invalid string 798 # Additional [] needed to keep m4 from mangling shell constructs. 799 if [ [[ "$with_source_date" =~ ^[0-9][0-9]*$ ]] ] ; then 800 SOURCE_DATE=$with_source_date 801 AC_MSG_RESULT([$SOURCE_DATE, from timestamp on command line]) 802 else 803 UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $with_source_date) 804 if test "x$SOURCE_DATE" != x; then 805 AC_MSG_RESULT([$SOURCE_DATE, from ISO-8601 date on command line]) 806 else 807 AC_MSG_RESULT([unavailable]) 808 AC_MSG_ERROR([Cannot parse date string "$with_source_date"]) 809 fi 810 fi 811 fi 812 813 ISO_8601_FORMAT_STRING="%Y-%m-%dT%H:%M:%SZ" 814 if test "x$SOURCE_DATE" != xupdated; then 815 # If we have a fixed value for SOURCE_DATE, we need to set SOURCE_DATE_EPOCH 816 # for the rest of configure. 817 SOURCE_DATE_EPOCH="$SOURCE_DATE" 818 if test "x$IS_GNU_DATE" = xyes; then 819 SOURCE_DATE_ISO_8601=`$DATE --utc --date="@$SOURCE_DATE" +"$ISO_8601_FORMAT_STRING" 2> /dev/null` 820 else 821 SOURCE_DATE_ISO_8601=`$DATE -u -j -f "%s" "$SOURCE_DATE" +"$ISO_8601_FORMAT_STRING" 2> /dev/null` 822 fi 823 fi 824 825 AC_SUBST(SOURCE_DATE) 826 AC_SUBST(ISO_8601_FORMAT_STRING) 827 AC_SUBST(SOURCE_DATE_ISO_8601) 828 829 UTIL_DEPRECATED_ARG_ENABLE(reproducible-build) 830 ]) 831 832 ################################################################################ 833 # 834 # Setup signing on macOS. This can either be setup to sign with a real identity 835 # and enabling the hardened runtime, or it can simply add the debug entitlement 836 # com.apple.security.get-task-allow without actually signing any binaries. The 837 # latter is needed to be able to debug processes and dump core files on modern 838 # versions of macOS. It can also be skipped completely. 839 # 840 # Check if codesign will run with the given parameters 841 # $1: Parameters to run with 842 # $2: Checking message 843 # Sets CODESIGN_SUCCESS=true/false 844 AC_DEFUN([JDKOPT_CHECK_CODESIGN_PARAMS], 845 [ 846 PARAMS="$1" 847 MESSAGE="$2" 848 CODESIGN_TESTFILE="$CONFIGURESUPPORT_OUTPUTDIR/codesign-testfile" 849 $RM "$CODESIGN_TESTFILE" 850 $TOUCH "$CODESIGN_TESTFILE" 851 CODESIGN_SUCCESS=false 852 853 $ECHO "check codesign, calling $CODESIGN $PARAMS $CODESIGN_TESTFILE" >&AS_MESSAGE_LOG_FD 854 855 eval \"$CODESIGN\" $PARAMS \"$CODESIGN_TESTFILE\" 2>&AS_MESSAGE_LOG_FD \ 856 >&AS_MESSAGE_LOG_FD && CODESIGN_SUCCESS=true 857 $RM "$CODESIGN_TESTFILE" 858 AC_MSG_CHECKING([$MESSAGE]) 859 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 860 AC_MSG_RESULT([yes]) 861 else 862 AC_MSG_RESULT([no]) 863 fi 864 ]) 865 866 AC_DEFUN([JDKOPT_CHECK_CODESIGN_HARDENED], 867 [ 868 JDKOPT_CHECK_CODESIGN_PARAMS([-s \"$MACOSX_CODESIGN_IDENTITY\" --option runtime], 869 [if codesign with hardened runtime is possible]) 870 ]) 871 872 AC_DEFUN([JDKOPT_CHECK_CODESIGN_DEBUG], 873 [ 874 JDKOPT_CHECK_CODESIGN_PARAMS([-s -], [if debug mode codesign is possible]) 875 ]) 876 877 AC_DEFUN([JDKOPT_SETUP_MACOSX_SIGNING], 878 [ 879 ENABLE_CODESIGN=false 880 if test "x$OPENJDK_TARGET_OS" = "xmacosx" && test "x$CODESIGN" != "x"; then 881 882 UTIL_ARG_WITH(NAME: macosx-codesign, TYPE: literal, OPTIONAL: true, 883 VALID_VALUES: [hardened debug auto], DEFAULT: auto, 884 ENABLED_DEFAULT: true, 885 CHECKING_MSG: [for macosx code signing mode], 886 DESC: [set the macosx code signing mode (hardened, debug, auto)] 887 ) 888 889 MACOSX_CODESIGN_MODE=disabled 890 if test "x$MACOSX_CODESIGN_ENABLED" = "xtrue"; then 891 892 # Check for user provided code signing identity. 893 UTIL_ARG_WITH(NAME: macosx-codesign-identity, TYPE: string, 894 DEFAULT: openjdk_codesign, CHECK_VALUE: [UTIL_CHECK_STRING_NON_EMPTY], 895 DESC: [specify the macosx code signing identity], 896 CHECKING_MSG: [for macosx code signing identity] 897 ) 898 AC_SUBST(MACOSX_CODESIGN_IDENTITY) 899 900 if test "x$MACOSX_CODESIGN" = "xauto"; then 901 # Only try to default to hardened signing on release builds 902 if test "x$DEBUG_LEVEL" = "xrelease"; then 903 JDKOPT_CHECK_CODESIGN_HARDENED 904 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 905 MACOSX_CODESIGN_MODE=hardened 906 fi 907 fi 908 if test "x$MACOSX_CODESIGN_MODE" = "xdisabled"; then 909 JDKOPT_CHECK_CODESIGN_DEBUG 910 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 911 MACOSX_CODESIGN_MODE=debug 912 fi 913 fi 914 AC_MSG_CHECKING([for macosx code signing mode]) 915 AC_MSG_RESULT([$MACOSX_CODESIGN_MODE]) 916 elif test "x$MACOSX_CODESIGN" = "xhardened"; then 917 JDKOPT_CHECK_CODESIGN_HARDENED 918 if test "x$CODESIGN_SUCCESS" = "xfalse"; then 919 AC_MSG_ERROR([Signing with hardened runtime is not possible]) 920 fi 921 MACOSX_CODESIGN_MODE=hardened 922 elif test "x$MACOSX_CODESIGN" = "xdebug"; then 923 JDKOPT_CHECK_CODESIGN_DEBUG 924 if test "x$CODESIGN_SUCCESS" = "xfalse"; then 925 AC_MSG_ERROR([Signing in debug mode is not possible]) 926 fi 927 MACOSX_CODESIGN_MODE=debug 928 else 929 AC_MSG_ERROR([unknown value for --with-macosx-codesign: $MACOSX_CODESIGN]) 930 fi 931 fi 932 AC_SUBST(MACOSX_CODESIGN_IDENTITY) 933 AC_SUBST(MACOSX_CODESIGN_MODE) 934 fi 935 ]) 936 937 ################################################################################ 938 # 939 # fallback linker 940 # 941 AC_DEFUN_ONCE([JDKOPT_SETUP_FALLBACK_LINKER], 942 [ 943 FALLBACK_LINKER_DEFAULT=false 944 945 if HOTSPOT_CHECK_JVM_VARIANT(zero); then 946 FALLBACK_LINKER_DEFAULT=true 947 fi 948 949 UTIL_ARG_ENABLE(NAME: fallback-linker, DEFAULT: $FALLBACK_LINKER_DEFAULT, 950 RESULT: ENABLE_FALLBACK_LINKER, 951 DESC: [enable libffi-based fallback implementation of java.lang.foreign.Linker], 952 CHECKING_MSG: [if fallback linker enabled]) 953 AC_SUBST(ENABLE_FALLBACK_LINKER) 954 ])