1 # 2 # Copyright (c) 2011, 2026, 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 # Avoid headless-only on macOS and Windows, it is not supported there 106 if test "x$ENABLE_HEADLESS_ONLY" = xtrue; then 107 if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then 108 AC_MSG_ERROR([headless-only is not supported on macOS and Windows]) 109 fi 110 fi 111 112 # should we linktime gc unused code sections in the JDK build ? 113 if test "x$OPENJDK_TARGET_OS" = "xlinux"; then 114 if test "x$OPENJDK_TARGET_CPU" = "xs390x" || test "x$OPENJDK_TARGET_CPU" = "xppc64le"; then 115 LINKTIME_GC_DEFAULT=true 116 else 117 LINKTIME_GC_DEFAULT=false 118 fi 119 else 120 LINKTIME_GC_DEFAULT=false 121 fi 122 123 UTIL_ARG_ENABLE(NAME: linktime-gc, DEFAULT: $LINKTIME_GC_DEFAULT, 124 DEFAULT_DESC: [auto], RESULT: ENABLE_LINKTIME_GC, 125 DESC: [use link time gc on unused code sections in the JDK build], 126 CHECKING_MSG: [if linker should clean out unused code (linktime-gc)]) 127 AC_SUBST(ENABLE_LINKTIME_GC) 128 129 # Check for full doc dependencies 130 FULL_DOCS_AVAILABLE=true 131 AC_MSG_CHECKING([for graphviz dot]) 132 if test "x$DOT" != "x"; then 133 AC_MSG_RESULT([yes]) 134 else 135 AC_MSG_RESULT([no, cannot generate full docs or man pages]) 136 FULL_DOCS_AVAILABLE=false 137 fi 138 139 AC_MSG_CHECKING([for pandoc]) 140 if test "x$ENABLE_PANDOC" = "xtrue"; then 141 AC_MSG_RESULT([yes]) 142 else 143 AC_MSG_RESULT([no, cannot generate full docs or man pages]) 144 FULL_DOCS_AVAILABLE=false 145 fi 146 147 # Should we build the complete docs, or just a lightweight version? 148 UTIL_ARG_ENABLE(NAME: full-docs, DEFAULT: auto, RESULT: ENABLE_FULL_DOCS, 149 AVAILABLE: $FULL_DOCS_AVAILABLE, DESC: [build complete documentation], 150 DEFAULT_DESC: [enabled if all tools found]) 151 AC_SUBST(ENABLE_FULL_DOCS) 152 153 # Choose cacerts source file 154 AC_ARG_WITH(cacerts-file, [AS_HELP_STRING([--with-cacerts-file], 155 [specify alternative cacerts file])]) 156 AC_MSG_CHECKING([for cacerts file]) 157 if test "x$with_cacerts_file" == x; then 158 AC_MSG_RESULT([default]) 159 else 160 CACERTS_FILE=$with_cacerts_file 161 if test ! -f "$CACERTS_FILE"; then 162 AC_MSG_RESULT([fail]) 163 AC_MSG_ERROR([Specified cacerts file "$CACERTS_FILE" does not exist]) 164 fi 165 AC_MSG_RESULT([$CACERTS_FILE]) 166 fi 167 AC_SUBST(CACERTS_FILE) 168 169 # Choose cacerts source folder for user provided PEM files 170 AC_ARG_WITH(cacerts-src, [AS_HELP_STRING([--with-cacerts-src], 171 [specify alternative cacerts source folder containing certificates])]) 172 CACERTS_SRC="" 173 AC_MSG_CHECKING([for cacerts source]) 174 if test "x$with_cacerts_src" == x; then 175 AC_MSG_RESULT([default]) 176 else 177 CACERTS_SRC=$with_cacerts_src 178 if test ! -d "$CACERTS_SRC"; then 179 AC_MSG_RESULT([fail]) 180 AC_MSG_ERROR([Specified cacerts source folder "$CACERTS_SRC" does not exist]) 181 fi 182 AC_MSG_RESULT([$CACERTS_SRC]) 183 fi 184 AC_SUBST(CACERTS_SRC) 185 186 # Enable or disable unlimited crypto 187 UTIL_ARG_ENABLE(NAME: unlimited-crypto, DEFAULT: true, RESULT: UNLIMITED_CRYPTO, 188 DESC: [enable unlimited crypto policy]) 189 AC_SUBST(UNLIMITED_CRYPTO) 190 191 # Should we build the serviceability agent (SA)? 192 INCLUDE_SA=true 193 if HOTSPOT_CHECK_JVM_VARIANT(zero); then 194 INCLUDE_SA=false 195 fi 196 if test "x$OPENJDK_TARGET_OS" = xaix ; then 197 INCLUDE_SA=false 198 fi 199 if test "x$OPENJDK_TARGET_CPU" = xs390x ; then 200 INCLUDE_SA=false 201 fi 202 AC_SUBST(INCLUDE_SA) 203 204 # Setup default CDS alignment. On platforms where one build may run on machines with different 205 # page sizes, the JVM choses a compatible alignment to fit all possible page sizes. This slightly 206 # increases archive size. 207 # The only platform having this problem at the moment is Linux on aarch64, which may encounter 208 # three different page sizes: 4K, 64K, and if run on Mac m1 hardware, 16K. 209 COMPATIBLE_CDS_ALIGNMENT_DEFAULT=false 210 if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then 211 COMPATIBLE_CDS_ALIGNMENT_DEFAULT=auto 212 fi 213 214 # Compress jars 215 COMPRESS_JARS=false 216 217 AC_SUBST(COMPRESS_JARS) 218 219 # Setup default copyright year. Mostly overridden when building close to a new year. 220 AC_ARG_WITH(copyright-year, [AS_HELP_STRING([--with-copyright-year], 221 [Set copyright year value for build @<:@current year/source-date@:>@])]) 222 if test "x$with_copyright_year" = xyes; then 223 AC_MSG_ERROR([Copyright year must have a value]) 224 elif test "x$with_copyright_year" != x; then 225 COPYRIGHT_YEAR="$with_copyright_year" 226 elif test "x$SOURCE_DATE" != xupdated; then 227 if test "x$IS_GNU_DATE" = xyes; then 228 COPYRIGHT_YEAR=`$DATE --date=@$SOURCE_DATE +%Y` 229 else 230 COPYRIGHT_YEAR=`$DATE -j -f %s $SOURCE_DATE +%Y` 231 fi 232 else 233 COPYRIGHT_YEAR=`$DATE +'%Y'` 234 fi 235 AC_SUBST(COPYRIGHT_YEAR) 236 237 # Override default library path 238 AC_ARG_WITH([jni-libpath], [AS_HELP_STRING([--with-jni-libpath], 239 [override default JNI library search path])]) 240 AC_MSG_CHECKING([for jni library path]) 241 if test "x${with_jni_libpath}" = "x" || test "x${with_jni_libpath}" = "xno"; then 242 AC_MSG_RESULT([default]) 243 elif test "x${with_jni_libpath}" = "xyes"; then 244 AC_MSG_RESULT([invalid]) 245 AC_MSG_ERROR([The --with-jni-libpath option requires an argument.]) 246 else 247 HOTSPOT_OVERRIDE_LIBPATH=${with_jni_libpath} 248 if test "x$OPENJDK_TARGET_OS" != "xlinux" && 249 test "x$OPENJDK_TARGET_OS" != "xbsd" && 250 test "x$OPENJDK_TARGET_OS" != "xaix"; then 251 AC_MSG_RESULT([fail]) 252 AC_MSG_ERROR([Overriding JNI library path is supported only on Linux, BSD and AIX.]) 253 fi 254 AC_MSG_RESULT(${HOTSPOT_OVERRIDE_LIBPATH}) 255 fi 256 AC_SUBST(HOTSPOT_OVERRIDE_LIBPATH) 257 258 ]) 259 260 ################################################################################ 261 262 AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], 263 [ 264 # 265 # Native debug symbols. 266 # This must be done after the toolchain is setup, since we're looking at objcopy. 267 # 268 AC_MSG_CHECKING([what type of native debug symbols to use]) 269 AC_ARG_WITH([native-debug-symbols], 270 [AS_HELP_STRING([--with-native-debug-symbols], 271 [set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])], 272 [ 273 if test "x$OPENJDK_TARGET_OS" = xwindows; then 274 if test "x$withval" = xinternal; then 275 AC_MSG_ERROR([Windows does not support the parameter 'internal' for --with-native-debug-symbols]) 276 fi 277 fi 278 ], 279 [ 280 with_native_debug_symbols="external" 281 ]) 282 AC_MSG_RESULT([$with_native_debug_symbols]) 283 284 if test "x$with_native_debug_symbols" = xnone; then 285 COMPILE_WITH_DEBUG_SYMBOLS=false 286 COPY_DEBUG_SYMBOLS=false 287 ZIP_EXTERNAL_DEBUG_SYMBOLS=false 288 elif test "x$with_native_debug_symbols" = xinternal; then 289 COMPILE_WITH_DEBUG_SYMBOLS=true 290 COPY_DEBUG_SYMBOLS=false 291 ZIP_EXTERNAL_DEBUG_SYMBOLS=false 292 elif test "x$with_native_debug_symbols" = xexternal; then 293 294 if test "x$OPENJDK_TARGET_OS" = xlinux; then 295 if test "x$OBJCOPY" = x; then 296 # enabling of enable-debug-symbols and can't find objcopy 297 # this is an error 298 AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols]) 299 fi 300 fi 301 302 COMPILE_WITH_DEBUG_SYMBOLS=true 303 COPY_DEBUG_SYMBOLS=true 304 ZIP_EXTERNAL_DEBUG_SYMBOLS=false 305 elif test "x$with_native_debug_symbols" = xzipped; then 306 307 if test "x$OPENJDK_TARGET_OS" = xlinux; then 308 if test "x$OBJCOPY" = x; then 309 # enabling of enable-debug-symbols and can't find objcopy 310 # this is an error 311 AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols]) 312 fi 313 fi 314 315 COMPILE_WITH_DEBUG_SYMBOLS=true 316 COPY_DEBUG_SYMBOLS=true 317 ZIP_EXTERNAL_DEBUG_SYMBOLS=true 318 else 319 AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped]) 320 fi 321 322 AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS) 323 AC_SUBST(COPY_DEBUG_SYMBOLS) 324 AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS) 325 326 # Should we add external native debug symbols to the shipped bundles? 327 AC_MSG_CHECKING([if we should add external native debug symbols to the shipped bundles]) 328 AC_ARG_WITH([external-symbols-in-bundles], 329 [AS_HELP_STRING([--with-external-symbols-in-bundles], 330 [which type of external native debug symbol information shall be shipped with bundles/images (none, public, full). 331 @<:@none in release builds, full otherwise. --with-native-debug-symbols=external/zipped is a prerequisite. public is only supported on Windows@:>@])], 332 [], 333 [with_external_symbols_in_bundles=default]) 334 335 if test "x$with_external_symbols_in_bundles" = x || test "x$with_external_symbols_in_bundles" = xnone ; then 336 AC_MSG_RESULT([no]) 337 elif test "x$with_external_symbols_in_bundles" = xfull || test "x$with_external_symbols_in_bundles" = xpublic ; then 338 if test "x$COPY_DEBUG_SYMBOLS" != xtrue ; then 339 AC_MSG_ERROR([--with-external-symbols-in-bundles only works when --with-native-debug-symbols=external/zipped is used!]) 340 elif test "x$with_external_symbols_in_bundles" = xpublic && test "x$OPENJDK_TARGET_OS" != xwindows ; then 341 AC_MSG_ERROR([--with-external-symbols-in-bundles=public is only supported on Windows!]) 342 fi 343 344 if test "x$with_external_symbols_in_bundles" = xfull ; then 345 AC_MSG_RESULT([full]) 346 SHIP_DEBUG_SYMBOLS=full 347 else 348 AC_MSG_RESULT([public]) 349 SHIP_DEBUG_SYMBOLS=public 350 fi 351 elif test "x$with_external_symbols_in_bundles" = xdefault ; then 352 if test "x$DEBUG_LEVEL" = xrelease ; then 353 AC_MSG_RESULT([no (default)]) 354 elif test "x$COPY_DEBUG_SYMBOLS" = xtrue ; then 355 AC_MSG_RESULT([full (default)]) 356 SHIP_DEBUG_SYMBOLS=full 357 else 358 AC_MSG_RESULT([no (default, native debug symbols are not external/zipped)]) 359 fi 360 else 361 AC_MSG_ERROR([$with_external_symbols_in_bundles is an unknown value for --with-external-symbols-in-bundles]) 362 fi 363 364 AC_SUBST(SHIP_DEBUG_SYMBOLS) 365 ]) 366 367 ################################################################################ 368 # 369 # Native and Java code coverage 370 # 371 AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE], 372 [ 373 UTIL_ARG_ENABLE(NAME: native-coverage, DEFAULT: false, RESULT: GCOV_ENABLED, 374 DESC: [enable native compilation with code coverage data], 375 CHECK_AVAILABLE: [ 376 AC_MSG_CHECKING([if native coverage is available]) 377 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 378 test "x$TOOLCHAIN_TYPE" = "xclang"; then 379 AC_MSG_RESULT([yes]) 380 else 381 AC_MSG_RESULT([no]) 382 AVAILABLE=false 383 fi 384 ], 385 IF_ENABLED: [ 386 GCOV_CFLAGS="-fprofile-arcs -ftest-coverage -fno-inline" 387 GCOV_LDFLAGS="-fprofile-arcs" 388 JVM_CFLAGS="$JVM_CFLAGS $GCOV_CFLAGS" 389 JVM_LDFLAGS="$JVM_LDFLAGS $GCOV_LDFLAGS" 390 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $GCOV_CFLAGS" 391 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $GCOV_CFLAGS" 392 CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $GCOV_CFLAGS" 393 CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS" 394 LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS" 395 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS" 396 LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $GCOV_LDFLAGS" 397 ]) 398 AC_SUBST(GCOV_ENABLED) 399 400 AC_ARG_WITH(jcov, [AS_HELP_STRING([--with-jcov], 401 [jcov library location])]) 402 AC_ARG_WITH(jcov-input-jdk, [AS_HELP_STRING([--with-jcov-input-jdk], 403 [jdk image to instrument])]) 404 AC_ARG_WITH(jcov-filters, [AS_HELP_STRING([--with-jcov-filters], 405 [filters to limit code for jcov instrumentation and report generation])]) 406 JCOV_HOME= 407 JCOV_INPUT_JDK= 408 JCOV_ENABLED= 409 JCOV_FILTERS= 410 if test "x$with_jcov" = "x" ; then 411 JCOV_ENABLED="false" 412 else 413 JCOV_HOME="$with_jcov" 414 if test ! -f "$JCOV_HOME/lib/jcov.jar"; then 415 AC_MSG_RESULT([fail]) 416 AC_MSG_ERROR([Invalid JCov bundle: "$JCOV_HOME/lib/jcov.jar" does not exist]) 417 fi 418 JCOV_ENABLED="true" 419 UTIL_FIXUP_PATH(JCOV_HOME) 420 if test "x$with_jcov_input_jdk" != "x" ; then 421 JCOV_INPUT_JDK="$with_jcov_input_jdk" 422 if test ! -f "$JCOV_INPUT_JDK/bin/java" && test ! -f "$JCOV_INPUT_JDK/bin/java.exe"; then 423 AC_MSG_RESULT([fail]) 424 AC_MSG_ERROR([Invalid JDK bundle: "$JCOV_INPUT_JDK/bin/java" does not exist]) 425 fi 426 UTIL_FIXUP_PATH(JCOV_INPUT_JDK) 427 fi 428 if test "x$with_jcov_filters" != "x" ; then 429 JCOV_FILTERS="$with_jcov_filters" 430 fi 431 fi 432 433 UTIL_ARG_WITH(NAME: jcov-modules, TYPE: string, 434 DEFAULT: [], RESULT: JCOV_MODULES_COMMMA_SEPARATED, 435 DESC: [which modules to include in jcov (comma-separated)], 436 OPTIONAL: true) 437 438 # Replace "," with " ". 439 JCOV_MODULES=${JCOV_MODULES_COMMMA_SEPARATED//,/ } 440 AC_SUBST(JCOV_ENABLED) 441 AC_SUBST(JCOV_HOME) 442 AC_SUBST(JCOV_INPUT_JDK) 443 AC_SUBST(JCOV_FILTERS) 444 AC_SUBST(JCOV_MODULES) 445 ]) 446 447 ################################################################################ 448 # 449 # AddressSanitizer 450 # 451 AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER], 452 [ 453 UTIL_ARG_ENABLE(NAME: asan, DEFAULT: false, RESULT: ASAN_ENABLED, 454 DESC: [enable AddressSanitizer], 455 CHECK_AVAILABLE: [ 456 AC_MSG_CHECKING([if AddressSanitizer (asan) is available]) 457 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 458 test "x$TOOLCHAIN_TYPE" = "xclang" || 459 test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then 460 AC_MSG_RESULT([yes]) 461 else 462 AC_MSG_RESULT([no]) 463 AVAILABLE=false 464 fi 465 ], 466 IF_ENABLED: [ 467 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 468 test "x$TOOLCHAIN_TYPE" = "xclang"; then 469 # ASan is simply incompatible with gcc -Wstringop-truncation. See 470 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85650 471 # It's harmless to be suppressed in clang as well. 472 ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER" 473 ASAN_LDFLAGS="-fsanitize=address" 474 # detect_stack_use_after_return causes ASAN to offload stack-local 475 # variables to c-heap and therefore breaks assumptions in hotspot 476 # that rely on data (e.g. Marks) living in thread stacks. 477 if test "x$TOOLCHAIN_TYPE" = "xgcc"; then 478 ASAN_CFLAGS="$ASAN_CFLAGS --param asan-use-after-return=0" 479 fi 480 if test "x$TOOLCHAIN_TYPE" = "xclang"; then 481 ASAN_CFLAGS="$ASAN_CFLAGS -fsanitize-address-use-after-return=never" 482 ASAN_LDFLAGS="$ASAN_LDFLAGS -shared-libasan" 483 fi 484 elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then 485 # -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang. 486 ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER" 487 # MSVC produces a warning if you pass -fsanitize=address to the linker. It also complains 488 $ if -DEBUG is not passed to the linker when building with ASan. 489 ASAN_LDFLAGS="-debug" 490 # -fsanitize-address-use-after-return is off by default in MS Visual Studio 22 (19.37.32824). 491 # cl : Command line warning D9002 : ignoring unknown option '-fno-sanitize-address-use-after-return' 492 fi 493 JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS" 494 JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS" 495 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $ASAN_CFLAGS" 496 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $ASAN_CFLAGS" 497 CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $ASAN_CFLAGS" 498 CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $ASAN_CFLAGS" 499 LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $ASAN_LDFLAGS" 500 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $ASAN_LDFLAGS" 501 LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $ASAN_LDFLAGS" 502 ]) 503 AC_SUBST(ASAN_ENABLED) 504 ]) 505 506 ################################################################################ 507 # 508 # Static analyzer 509 # 510 AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_ANALYZER], 511 [ 512 UTIL_ARG_ENABLE(NAME: static-analyzer, DEFAULT: false, RESULT: STATIC_ANALYZER_ENABLED, 513 DESC: [enable the GCC static analyzer], 514 CHECK_AVAILABLE: [ 515 AC_MSG_CHECKING([if static analyzer is available]) 516 if test "x$TOOLCHAIN_TYPE" = "xgcc"; then 517 AC_MSG_RESULT([yes]) 518 else 519 AC_MSG_RESULT([no]) 520 AVAILABLE=false 521 fi 522 ], 523 IF_ENABLED: [ 524 STATIC_ANALYZER_CFLAGS="-fanalyzer -Wno-analyzer-fd-leak" 525 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $STATIC_ANALYZER_CFLAGS" 526 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $STATIC_ANALYZER_CFLAGS" 527 ]) 528 AC_SUBST(STATIC_ANALYZER_ENABLED) 529 ]) 530 531 ################################################################################ 532 # 533 # LeakSanitizer 534 # 535 AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER], 536 [ 537 UTIL_ARG_ENABLE(NAME: lsan, DEFAULT: false, RESULT: LSAN_ENABLED, 538 DESC: [enable LeakSanitizer], 539 CHECK_AVAILABLE: [ 540 AC_MSG_CHECKING([if LeakSanitizer (lsan) is available]) 541 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 542 test "x$TOOLCHAIN_TYPE" = "xclang"; then 543 AC_MSG_RESULT([yes]) 544 else 545 AC_MSG_RESULT([no]) 546 AVAILABLE=false 547 fi 548 ], 549 IF_ENABLED: [ 550 LSAN_CFLAGS="-fsanitize=leak -fno-omit-frame-pointer -DLEAK_SANITIZER" 551 LSAN_LDFLAGS="-fsanitize=leak" 552 JVM_CFLAGS="$JVM_CFLAGS $LSAN_CFLAGS" 553 JVM_LDFLAGS="$JVM_LDFLAGS $LSAN_LDFLAGS" 554 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $LSAN_CFLAGS" 555 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $LSAN_CFLAGS" 556 CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $LSAN_CFLAGS" 557 CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $LSAN_CFLAGS" 558 LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $LSAN_LDFLAGS" 559 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $LSAN_LDFLAGS" 560 LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $LSAN_LDFLAGS" 561 ]) 562 AC_SUBST(LSAN_ENABLED) 563 ]) 564 565 ################################################################################ 566 # 567 # UndefinedBehaviorSanitizer 568 # 569 AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER], 570 [ 571 UTIL_ARG_WITH(NAME: additional-ubsan-checks, TYPE: string, 572 DEFAULT: [], 573 DESC: [Customizes the ubsan checks], 574 OPTIONAL: true) 575 576 # GCC reports lots of likely false positives for stringop-truncation and format-overflow. 577 # GCC 13 also for array-bounds and stringop-overflow 578 # Silence them for now. 579 UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment \ 580 $ADDITIONAL_UBSAN_CHECKS" 581 UBSAN_CFLAGS="$UBSAN_CHECKS -Wno-array-bounds -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER" 582 if test "x$TOOLCHAIN_TYPE" = "xgcc"; then 583 UBSAN_CFLAGS="$UBSAN_CFLAGS -Wno-format-overflow -Wno-stringop-overflow -Wno-stringop-truncation" 584 fi 585 UBSAN_LDFLAGS="$UBSAN_CHECKS" 586 # On AIX, the llvm_symbolizer is not found out of the box, so we have to provide the 587 # full qualified llvm_symbolizer path in the __ubsan_default_options() function in 588 # make/data/ubsan/ubsan_default_options.c. To get it there we compile our sources 589 # with an additional define LLVM_SYMBOLIZER, which we set here. 590 # To calculate the correct llvm_symbolizer path we can use the location of the compiler, because 591 # their relation is fixed. 592 # In the ubsan case we have to link every binary with the C++-compiler as linker, because inherently 593 # the C-Compiler and the C++-compiler used as linker provide a different set of ubsan exports. 594 # Linking an executable with the C-compiler and one of its shared libraries with the C++-compiler 595 # leeds to unresolved symbols. 596 if test "x$TOOLCHAIN_TYPE" = "xclang" && test "x$OPENJDK_TARGET_OS" = "xaix"; then 597 UBSAN_CFLAGS="$UBSAN_CFLAGS -DLLVM_SYMBOLIZER=$(dirname $(dirname $CC))/tools/ibm-llvm-symbolizer" 598 UBSAN_LDFLAGS="$UBSAN_LDFLAGS -Wl,-bbigtoc" 599 LD="$LDCXX" 600 fi 601 UTIL_ARG_ENABLE(NAME: ubsan, DEFAULT: false, RESULT: UBSAN_ENABLED, 602 DESC: [enable UndefinedBehaviorSanitizer], 603 CHECK_AVAILABLE: [ 604 AC_MSG_CHECKING([if UndefinedBehaviorSanitizer (ubsan) is available]) 605 if test "x$TOOLCHAIN_TYPE" = "xgcc" || 606 test "x$TOOLCHAIN_TYPE" = "xclang"; then 607 AC_MSG_RESULT([yes]) 608 else 609 AC_MSG_RESULT([no]) 610 AVAILABLE=false 611 fi 612 ], 613 IF_ENABLED: [ 614 JVM_CFLAGS="$JVM_CFLAGS $UBSAN_CFLAGS" 615 JVM_LDFLAGS="$JVM_LDFLAGS $UBSAN_LDFLAGS" 616 CFLAGS_JDKLIB="$CFLAGS_JDKLIB $UBSAN_CFLAGS" 617 CFLAGS_JDKEXE="$CFLAGS_JDKEXE $UBSAN_CFLAGS" 618 CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $UBSAN_CFLAGS" 619 CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $UBSAN_CFLAGS" 620 LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $UBSAN_LDFLAGS" 621 LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $UBSAN_LDFLAGS" 622 LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $UBSAN_LDFLAGS" 623 ]) 624 if test "x$UBSAN_ENABLED" = xfalse; then 625 UBSAN_CFLAGS="" 626 UBSAN_LDFLAGS="" 627 fi 628 AC_SUBST(UBSAN_CFLAGS) 629 AC_SUBST(UBSAN_LDFLAGS) 630 AC_SUBST(UBSAN_ENABLED) 631 ]) 632 633 ################################################################################ 634 # 635 # jmod options. 636 # 637 AC_DEFUN_ONCE([JDKOPT_SETUP_JMOD_OPTIONS], 638 [ 639 # Final JMODs are recompiled often during development, and java.base JMOD 640 # includes the JVM libraries. In release mode, prefer to compress JMODs fully. 641 # In debug mode, pay with a little extra space, but win a lot of CPU time back 642 # with the lightest (but still some) compression. 643 if test "x$DEBUG_LEVEL" = xrelease; then 644 DEFAULT_JMOD_COMPRESS="zip-6" 645 else 646 DEFAULT_JMOD_COMPRESS="zip-1" 647 fi 648 649 UTIL_ARG_WITH(NAME: jmod-compress, TYPE: literal, 650 VALID_VALUES: [zip-0 zip-1 zip-2 zip-3 zip-4 zip-5 zip-6 zip-7 zip-8 zip-9], 651 DEFAULT: $DEFAULT_JMOD_COMPRESS, 652 CHECKING_MSG: [for JMOD compression type], 653 DESC: [specify JMOD compression type (zip-[0-9])] 654 ) 655 AC_SUBST(JMOD_COMPRESS) 656 ]) 657 658 ################################################################################ 659 # 660 # jlink options. 661 # 662 AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS], 663 [ 664 665 ################################################################################ 666 # 667 # Configure option for building a JDK that is suitable for linking from the 668 # run-time image without JMODs. 669 # 670 # Determines whether or not a suitable run-time image is being produced from 671 # packaged modules. If set to 'true, changes the *default* of packaged 672 # modules to 'false'. 673 # 674 UTIL_ARG_ENABLE(NAME: linkable-runtime, DEFAULT: false, 675 RESULT: JLINK_PRODUCE_LINKABLE_RUNTIME, 676 DESC: [enable a JDK build suitable for linking from the run-time image], 677 CHECKING_MSG: [whether or not a JDK suitable for linking from the run-time image should be produced]) 678 AC_SUBST(JLINK_PRODUCE_LINKABLE_RUNTIME) 679 680 if test "x$JLINK_PRODUCE_LINKABLE_RUNTIME" = xtrue; then 681 DEFAULT_PACKAGED_MODULES=false 682 else 683 DEFAULT_PACKAGED_MODULES=true 684 fi 685 686 ################################################################################ 687 # 688 # Configure option for packaged modules 689 # 690 # We keep packaged modules in the JDK image unless --enable-linkable-runtime is 691 # requested. 692 # 693 UTIL_ARG_ENABLE(NAME: keep-packaged-modules, DEFAULT: $DEFAULT_PACKAGED_MODULES, 694 RESULT: JLINK_KEEP_PACKAGED_MODULES, 695 DESC: [enable keeping of packaged modules in jdk image], 696 DEFAULT_DESC: [enabled by default unless --enable-linkable-runtime is set], 697 CHECKING_MSG: [if packaged modules are kept]) 698 AC_SUBST(JLINK_KEEP_PACKAGED_MODULES) 699 700 ################################################################################ 701 # 702 # Extra jlink options to be (optionally) passed to the JDK build 703 # 704 UTIL_ARG_WITH(NAME: extra-jlink-flags, TYPE: string, 705 DEFAULT: [], 706 DESC: [extra flags to be passed to jlink during the build], 707 OPTIONAL: true) 708 709 JLINK_USER_EXTRA_FLAGS="$EXTRA_JLINK_FLAGS" 710 AC_SUBST(JLINK_USER_EXTRA_FLAGS) 711 ]) 712 713 ################################################################################ 714 # 715 # Enable or disable generation of the classlist at build time 716 # 717 AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST], 718 [ 719 # In GenerateLinkOptData.gmk, DumpLoadedClassList is used to generate the 720 # classlist file. It never will work if CDS is disabled, since the VM will report 721 # an error for DumpLoadedClassList. 722 UTIL_ARG_ENABLE(NAME: generate-classlist, DEFAULT: auto, 723 RESULT: ENABLE_GENERATE_CLASSLIST, AVAILABLE: $ENABLE_CDS, 724 DESC: [enable generation of a CDS classlist at build time], 725 DEFAULT_DESC: [enabled if the JVM feature 'cds' is enabled for all JVM variants], 726 CHECKING_MSG: [if the CDS classlist generation should be enabled]) 727 AC_SUBST(ENABLE_GENERATE_CLASSLIST) 728 ]) 729 730 ################################################################################ 731 # 732 # Optionally filter resource translations 733 # 734 AC_DEFUN([JDKOPT_EXCLUDE_TRANSLATIONS], 735 [ 736 AC_ARG_WITH([exclude-translations], [AS_HELP_STRING([--with-exclude-translations], 737 [a comma separated list of locales to exclude translations for. Default is 738 to include all translations present in the source.])]) 739 740 EXCLUDE_TRANSLATIONS="" 741 AC_MSG_CHECKING([if any translations should be excluded]) 742 if test "x$with_exclude_translations" != "x"; then 743 EXCLUDE_TRANSLATIONS="${with_exclude_translations//,/ }" 744 AC_MSG_RESULT([yes: $EXCLUDE_TRANSLATIONS]) 745 else 746 AC_MSG_RESULT([no]) 747 fi 748 749 AC_SUBST(EXCLUDE_TRANSLATIONS) 750 ]) 751 752 ################################################################################ 753 # 754 # Disable the default CDS archive generation 755 # 756 AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE], 757 [ 758 UTIL_ARG_ENABLE(NAME: cds-archive, DEFAULT: auto, RESULT: BUILD_CDS_ARCHIVE, 759 DESC: [enable generation of a default CDS archive in the product image], 760 DEFAULT_DESC: [enabled if possible], 761 CHECKING_MSG: [if a default CDS archive should be generated], 762 CHECK_AVAILABLE: [ 763 AC_MSG_CHECKING([if CDS archive is available]) 764 if test "x$ENABLE_CDS" = "xfalse"; then 765 AC_MSG_RESULT([no (CDS is disabled)]) 766 AVAILABLE=false 767 elif test "x$COMPILE_TYPE" = "xcross"; then 768 AC_MSG_RESULT([no (not possible with cross compilation)]) 769 AVAILABLE=false 770 else 771 AC_MSG_RESULT([yes]) 772 fi 773 ]) 774 AC_SUBST(BUILD_CDS_ARCHIVE) 775 ]) 776 777 ################################################################################ 778 # 779 # Enable or disable the default CDS archive generation for Compact Object Headers 780 # 781 # Default disabled within Valhalla until support added (JDK-8348568) 782 # 783 AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH], 784 [ 785 UTIL_ARG_ENABLE(NAME: cds-archive-coh, DEFAULT: auto, RESULT: BUILD_CDS_ARCHIVE_COH, 786 DESC: [enable generation of default CDS archives for compact object headers (requires --enable-cds-archive)], 787 DEFAULT_DESC: [auto], 788 CHECKING_MSG: [if default CDS archives for compact object headers should be generated], 789 CHECK_AVAILABLE: [ 790 AC_MSG_CHECKING([if CDS archive with compact object headers is available]) 791 if test "x$BUILD_CDS_ARCHIVE" = "xfalse"; then 792 AC_MSG_RESULT([no (CDS default archive generation is disabled)]) 793 AVAILABLE=false 794 elif test "x$OPENJDK_TARGET_CPU" != "xx86_64" && 795 test "x$OPENJDK_TARGET_CPU" != "xaarch64" && 796 test "x$OPENJDK_TARGET_CPU" != "xppc64" && 797 test "x$OPENJDK_TARGET_CPU" != "xppc64le" && 798 test "x$OPENJDK_TARGET_CPU" != "xriscv64" && 799 test "x$OPENJDK_TARGET_CPU" != "xs390x"; then 800 AC_MSG_RESULT([no (compact object headers not supported for this platform)]) 801 AVAILABLE=false 802 else 803 AC_MSG_RESULT([yes]) 804 AVAILABLE=true 805 fi 806 ]) 807 AC_SUBST(BUILD_CDS_ARCHIVE_COH) 808 ]) 809 810 ################################################################################ 811 # 812 # Enable the alternative CDS core region alignment 813 # 814 AC_DEFUN([JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT], 815 [ 816 UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: $COMPATIBLE_CDS_ALIGNMENT_DEFAULT, 817 RESULT: ENABLE_COMPATIBLE_CDS_ALIGNMENT, 818 DESC: [enable use alternative compatible cds core region alignment], 819 DEFAULT_DESC: [disabled except on linux-aarch64], 820 CHECKING_MSG: [if compatible cds region alignment enabled], 821 CHECK_AVAILABLE: [ 822 AC_MSG_CHECKING([if CDS archive is available]) 823 if test "x$ENABLE_CDS" = "xfalse"; then 824 AVAILABLE=false 825 AC_MSG_RESULT([no (CDS is disabled)]) 826 else 827 AVAILABLE=true 828 AC_MSG_RESULT([yes]) 829 fi 830 ]) 831 AC_SUBST(ENABLE_COMPATIBLE_CDS_ALIGNMENT) 832 ]) 833 834 ################################################################################ 835 # 836 # Disallow any output from containing absolute paths from the build system. 837 # This setting defaults to allowed on debug builds and not allowed on release 838 # builds. 839 # 840 AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT], 841 [ 842 AC_ARG_ENABLE([absolute-paths-in-output], 843 [AS_HELP_STRING([--disable-absolute-paths-in-output], 844 [Set to disable to prevent any absolute paths from the build to end up in 845 any of the build output. @<:@disabled in release builds, otherwise enabled@:>@])]) 846 847 AC_MSG_CHECKING([if absolute paths should be allowed in the build output]) 848 if test "x$enable_absolute_paths_in_output" = "xno"; then 849 AC_MSG_RESULT([no, forced]) 850 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false" 851 elif test "x$enable_absolute_paths_in_output" = "xyes"; then 852 AC_MSG_RESULT([yes, forced]) 853 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true" 854 elif test "x$DEBUG_LEVEL" = "xrelease"; then 855 AC_MSG_RESULT([no, release build]) 856 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false" 857 else 858 AC_MSG_RESULT([yes, debug build]) 859 ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true" 860 fi 861 862 AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT) 863 ]) 864 865 ################################################################################ 866 # 867 # Check and set options related to reproducible builds. 868 # 869 AC_DEFUN_ONCE([JDKOPT_SETUP_REPRODUCIBLE_BUILD], 870 [ 871 AC_ARG_WITH([source-date], [AS_HELP_STRING([--with-source-date], 872 [how to set SOURCE_DATE_EPOCH ('updated', 'current', 'version' a timestamp or an ISO-8601 date) @<:@current/value of SOURCE_DATE_EPOCH@:>@])], 873 [with_source_date_present=true], [with_source_date_present=false]) 874 875 if test "x$SOURCE_DATE_EPOCH" != x && test "x$with_source_date" != x; then 876 AC_MSG_WARN([--with-source-date will override SOURCE_DATE_EPOCH]) 877 fi 878 879 AC_MSG_CHECKING([what source date to use]) 880 881 if test "x$with_source_date" = xyes; then 882 AC_MSG_ERROR([--with-source-date must have a value]) 883 elif test "x$with_source_date" = x; then 884 if test "x$SOURCE_DATE_EPOCH" != x; then 885 SOURCE_DATE=$SOURCE_DATE_EPOCH 886 with_source_date_present=true 887 AC_MSG_RESULT([$SOURCE_DATE, from SOURCE_DATE_EPOCH]) 888 else 889 # Tell makefiles to take the time from configure 890 SOURCE_DATE=$($DATE +"%s") 891 AC_MSG_RESULT([$SOURCE_DATE, from 'current' (default)]) 892 fi 893 elif test "x$with_source_date" = xupdated; then 894 SOURCE_DATE=updated 895 AC_MSG_RESULT([determined at build time, from 'updated']) 896 elif test "x$with_source_date" = xcurrent; then 897 # Set the current time 898 SOURCE_DATE=$($DATE +"%s") 899 AC_MSG_RESULT([$SOURCE_DATE, from 'current']) 900 elif test "x$with_source_date" = xversion; then 901 # Use the date from version-numbers.conf 902 UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $DEFAULT_VERSION_DATE) 903 if test "x$SOURCE_DATE" = x; then 904 AC_MSG_RESULT([unavailable]) 905 AC_MSG_ERROR([Cannot convert DEFAULT_VERSION_DATE to timestamp]) 906 fi 907 AC_MSG_RESULT([$SOURCE_DATE, from 'version']) 908 else 909 # It's a timestamp, an ISO-8601 date, or an invalid string 910 # Additional [] needed to keep m4 from mangling shell constructs. 911 if [ [[ "$with_source_date" =~ ^[0-9][0-9]*$ ]] ] ; then 912 SOURCE_DATE=$with_source_date 913 AC_MSG_RESULT([$SOURCE_DATE, from timestamp on command line]) 914 else 915 UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $with_source_date) 916 if test "x$SOURCE_DATE" != x; then 917 AC_MSG_RESULT([$SOURCE_DATE, from ISO-8601 date on command line]) 918 else 919 AC_MSG_RESULT([unavailable]) 920 AC_MSG_ERROR([Cannot parse date string "$with_source_date"]) 921 fi 922 fi 923 fi 924 925 ISO_8601_FORMAT_STRING="%Y-%m-%dT%H:%M:%SZ" 926 if test "x$SOURCE_DATE" != xupdated; then 927 # If we have a fixed value for SOURCE_DATE, we need to set SOURCE_DATE_EPOCH 928 # for the rest of configure. 929 SOURCE_DATE_EPOCH="$SOURCE_DATE" 930 if test "x$IS_GNU_DATE" = xyes; then 931 SOURCE_DATE_ISO_8601=`$DATE --utc --date="@$SOURCE_DATE" +"$ISO_8601_FORMAT_STRING" 2> /dev/null` 932 else 933 SOURCE_DATE_ISO_8601=`$DATE -u -j -f "%s" "$SOURCE_DATE" +"$ISO_8601_FORMAT_STRING" 2> /dev/null` 934 fi 935 fi 936 937 AC_SUBST(SOURCE_DATE) 938 AC_SUBST(ISO_8601_FORMAT_STRING) 939 AC_SUBST(SOURCE_DATE_ISO_8601) 940 ]) 941 942 ################################################################################ 943 # 944 # Setup signing on macOS. This can either be setup to sign with a real identity 945 # and enabling the hardened runtime, or it can simply add the debug entitlement 946 # com.apple.security.get-task-allow without actually signing any binaries. The 947 # latter is needed to be able to debug processes and dump core files on modern 948 # versions of macOS. It can also be skipped completely. 949 # 950 # Check if codesign will run with the given parameters 951 # $1: Parameters to run with 952 # $2: Checking message 953 # Sets CODESIGN_SUCCESS=true/false 954 AC_DEFUN([JDKOPT_CHECK_CODESIGN_PARAMS], 955 [ 956 PARAMS="$1" 957 MESSAGE="$2" 958 CODESIGN_TESTFILE="$CONFIGURESUPPORT_OUTPUTDIR/codesign-testfile" 959 $RM "$CODESIGN_TESTFILE" 960 $TOUCH "$CODESIGN_TESTFILE" 961 CODESIGN_SUCCESS=false 962 963 $ECHO "check codesign, calling $CODESIGN $PARAMS $CODESIGN_TESTFILE" >&AS_MESSAGE_LOG_FD 964 965 eval \"$CODESIGN\" $PARAMS \"$CODESIGN_TESTFILE\" 2>&AS_MESSAGE_LOG_FD \ 966 >&AS_MESSAGE_LOG_FD && CODESIGN_SUCCESS=true 967 $RM "$CODESIGN_TESTFILE" 968 AC_MSG_CHECKING([$MESSAGE]) 969 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 970 AC_MSG_RESULT([yes]) 971 else 972 AC_MSG_RESULT([no]) 973 fi 974 ]) 975 976 AC_DEFUN([JDKOPT_CHECK_CODESIGN_HARDENED], 977 [ 978 JDKOPT_CHECK_CODESIGN_PARAMS([-s \"$MACOSX_CODESIGN_IDENTITY\" --option runtime], 979 [if codesign with hardened runtime is possible]) 980 ]) 981 982 AC_DEFUN([JDKOPT_CHECK_CODESIGN_DEBUG], 983 [ 984 JDKOPT_CHECK_CODESIGN_PARAMS([-s -], [if debug mode codesign is possible]) 985 ]) 986 987 AC_DEFUN([JDKOPT_SETUP_MACOSX_SIGNING], 988 [ 989 MACOSX_CODESIGN_MODE=disabled 990 if test "x$OPENJDK_TARGET_OS" = "xmacosx" && test "x$CODESIGN" != "x"; then 991 992 UTIL_ARG_WITH(NAME: macosx-codesign, TYPE: literal, OPTIONAL: true, 993 VALID_VALUES: [hardened debug auto], DEFAULT: auto, 994 ENABLED_DEFAULT: true, 995 CHECKING_MSG: [for macosx code signing mode], 996 DESC: [set the macosx code signing mode (hardened, debug, auto)] 997 ) 998 999 if test "x$MACOSX_CODESIGN_ENABLED" = "xtrue"; then 1000 1001 # Check for user provided code signing identity. 1002 UTIL_ARG_WITH(NAME: macosx-codesign-identity, TYPE: string, 1003 DEFAULT: openjdk_codesign, CHECK_VALUE: [UTIL_CHECK_STRING_NON_EMPTY], 1004 DESC: [specify the macosx code signing identity], 1005 CHECKING_MSG: [for macosx code signing identity] 1006 ) 1007 AC_SUBST(MACOSX_CODESIGN_IDENTITY) 1008 1009 if test "x$MACOSX_CODESIGN" = "xauto"; then 1010 # Only try to default to hardened signing on release builds 1011 if test "x$DEBUG_LEVEL" = "xrelease"; then 1012 JDKOPT_CHECK_CODESIGN_HARDENED 1013 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 1014 MACOSX_CODESIGN_MODE=hardened 1015 fi 1016 fi 1017 if test "x$MACOSX_CODESIGN_MODE" = "xdisabled"; then 1018 JDKOPT_CHECK_CODESIGN_DEBUG 1019 if test "x$CODESIGN_SUCCESS" = "xtrue"; then 1020 MACOSX_CODESIGN_MODE=debug 1021 fi 1022 fi 1023 AC_MSG_CHECKING([for macosx code signing mode]) 1024 AC_MSG_RESULT([$MACOSX_CODESIGN_MODE]) 1025 elif test "x$MACOSX_CODESIGN" = "xhardened"; then 1026 JDKOPT_CHECK_CODESIGN_HARDENED 1027 if test "x$CODESIGN_SUCCESS" = "xfalse"; then 1028 AC_MSG_ERROR([Signing with hardened runtime is not possible]) 1029 fi 1030 MACOSX_CODESIGN_MODE=hardened 1031 elif test "x$MACOSX_CODESIGN" = "xdebug"; then 1032 JDKOPT_CHECK_CODESIGN_DEBUG 1033 if test "x$CODESIGN_SUCCESS" = "xfalse"; then 1034 AC_MSG_ERROR([Signing in debug mode is not possible]) 1035 fi 1036 MACOSX_CODESIGN_MODE=debug 1037 else 1038 AC_MSG_ERROR([unknown value for --with-macosx-codesign: $MACOSX_CODESIGN]) 1039 fi 1040 fi 1041 fi 1042 AC_SUBST(MACOSX_CODESIGN_IDENTITY) 1043 AC_SUBST(MACOSX_CODESIGN_MODE) 1044 ]) 1045 1046 ################################################################################ 1047 # 1048 # Setup a hook to invoke a script that runs for file produced by the native 1049 # compilation steps, after linking. 1050 # Parameter is the path to the script to be called. 1051 # 1052 AC_DEFUN([JDKOPT_SETUP_SIGNING_HOOK], 1053 [ 1054 UTIL_ARG_WITH(NAME: signing-hook, TYPE: executable, 1055 OPTIONAL: true, DEFAULT: "", 1056 DESC: [specify path to script used to code sign native binaries] 1057 ) 1058 1059 AC_MSG_CHECKING([for signing hook]) 1060 if test "x$SIGNING_HOOK" != x; then 1061 UTIL_FIXUP_EXECUTABLE(SIGNING_HOOK) 1062 AC_MSG_RESULT([$SIGNING_HOOK]) 1063 else 1064 AC_MSG_RESULT([none]) 1065 fi 1066 AC_SUBST(SIGNING_HOOK) 1067 ]) 1068 1069 ################################################################################ 1070 # 1071 # Setup how javac should handle warnings. 1072 # 1073 AC_DEFUN([JDKOPT_SETUP_JAVA_WARNINGS], 1074 [ 1075 UTIL_ARG_ENABLE(NAME: java-warnings-as-errors, DEFAULT: true, 1076 RESULT: JAVA_WARNINGS_AS_ERRORS, 1077 DESC: [consider java warnings to be an error]) 1078 AC_SUBST(JAVA_WARNINGS_AS_ERRORS) 1079 ]) 1080 1081 ################################################################################ 1082 # 1083 # fallback linker 1084 # 1085 AC_DEFUN_ONCE([JDKOPT_SETUP_FALLBACK_LINKER], 1086 [ 1087 FALLBACK_LINKER_DEFAULT=false 1088 1089 if HOTSPOT_CHECK_JVM_VARIANT(zero); then 1090 FALLBACK_LINKER_DEFAULT=true 1091 fi 1092 1093 UTIL_ARG_ENABLE(NAME: fallback-linker, DEFAULT: $FALLBACK_LINKER_DEFAULT, 1094 RESULT: ENABLE_FALLBACK_LINKER, 1095 DESC: [enable libffi-based fallback implementation of java.lang.foreign.Linker], 1096 CHECKING_MSG: [if fallback linker enabled]) 1097 AC_SUBST(ENABLE_FALLBACK_LINKER) 1098 ]) --- EOF ---