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