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