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.
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.
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).
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.
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
26
###############################################################################
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],
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" ])
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@:>@])],
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.])
49
AC_MSG_RESULT([$DEBUG_LEVEL])
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])
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"
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'
80
AC_SUBST(HOTSPOT_DEBUG_LEVEL)
84
###############################################################################
86
# Should we build only OpenJDK even if closed sources are present?
88
AC_DEFUN_ONCE([JDKOPT_SETUP_OPEN_OR_CUSTOM],
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)])
96
AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
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)
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
109
LINKTIME_GC_DEFAULT=false
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)
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
124
AC_MSG_RESULT([no, cannot generate full docs])
125
FULL_DOCS_AVAILABLE=false
128
AC_MSG_CHECKING([for pandoc])
129
if test "x$ENABLE_PANDOC" = "xtrue"; then
132
AC_MSG_RESULT([no, cannot generate full docs])
133
FULL_DOCS_AVAILABLE=false
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)
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])
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])
154
AC_MSG_RESULT([$CACERTS_FILE])
156
AC_SUBST(CACERTS_FILE)
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])])
162
AC_MSG_CHECKING([for cacerts source])
163
if test "x$with_cacerts_src" == x; then
164
AC_MSG_RESULT([default])
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])
171
AC_MSG_RESULT([$CACERTS_SRC])
173
AC_SUBST(CACERTS_SRC)
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)
180
# Should we build the serviceability agent (SA)?
182
if HOTSPOT_CHECK_JVM_VARIANT(zero); then
185
if test "x$OPENJDK_TARGET_OS" = xaix ; then
188
if test "x$OPENJDK_TARGET_CPU" = xs390x ; then
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=auto
206
AC_SUBST(COMPRESS_JARS)
208
# Setup default copyright year. Mostly overridden when building close to a new year.
209
AC_ARG_WITH(copyright-year, [AS_HELP_STRING([--with-copyright-year],
210
[Set copyright year value for build @<:@current year/source-date@:>@])])
211
if test "x$with_copyright_year" = xyes; then
212
AC_MSG_ERROR([Copyright year must have a value])
213
elif test "x$with_copyright_year" != x; then
214
COPYRIGHT_YEAR="$with_copyright_year"
215
elif test "x$SOURCE_DATE" != xupdated; then
216
if test "x$IS_GNU_DATE" = xyes; then
217
COPYRIGHT_YEAR=`$DATE --date=@$SOURCE_DATE +%Y`
219
COPYRIGHT_YEAR=`$DATE -j -f %s $SOURCE_DATE +%Y`
222
COPYRIGHT_YEAR=`$DATE +'%Y'`
224
AC_SUBST(COPYRIGHT_YEAR)
226
# Override default library path
227
AC_ARG_WITH([jni-libpath], [AS_HELP_STRING([--with-jni-libpath],
228
[override default JNI library search path])])
229
AC_MSG_CHECKING([for jni library path])
230
if test "x${with_jni_libpath}" = "x" || test "x${with_jni_libpath}" = "xno"; then
231
AC_MSG_RESULT([default])
232
elif test "x${with_jni_libpath}" = "xyes"; then
233
AC_MSG_RESULT([invalid])
234
AC_MSG_ERROR([The --with-jni-libpath option requires an argument.])
236
HOTSPOT_OVERRIDE_LIBPATH=${with_jni_libpath}
237
if test "x$OPENJDK_TARGET_OS" != "xlinux" &&
238
test "x$OPENJDK_TARGET_OS" != "xbsd" &&
239
test "x$OPENJDK_TARGET_OS" != "xaix"; then
240
AC_MSG_RESULT([fail])
241
AC_MSG_ERROR([Overriding JNI library path is supported only on Linux, BSD and AIX.])
243
AC_MSG_RESULT(${HOTSPOT_OVERRIDE_LIBPATH})
245
AC_SUBST(HOTSPOT_OVERRIDE_LIBPATH)
249
###############################################################################
251
AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
254
# Native debug symbols.
255
# This must be done after the toolchain is setup, since we're looking at objcopy.
257
AC_MSG_CHECKING([what type of native debug symbols to use])
258
AC_ARG_WITH([native-debug-symbols],
259
[AS_HELP_STRING([--with-native-debug-symbols],
260
[set the native debug symbol configuration (none, internal, external, zipped) @<:@varying@:>@])],
262
if test "x$OPENJDK_TARGET_OS" = xwindows; then
263
if test "x$withval" = xinternal; then
264
AC_MSG_ERROR([Windows does not support the parameter 'internal' for --with-native-debug-symbols])
269
with_native_debug_symbols="external"
271
AC_MSG_RESULT([$with_native_debug_symbols])
273
if test "x$with_native_debug_symbols" = xnone; then
274
COMPILE_WITH_DEBUG_SYMBOLS=false
275
COPY_DEBUG_SYMBOLS=false
276
ZIP_EXTERNAL_DEBUG_SYMBOLS=false
277
elif test "x$with_native_debug_symbols" = xinternal; then
278
COMPILE_WITH_DEBUG_SYMBOLS=true
279
COPY_DEBUG_SYMBOLS=false
280
ZIP_EXTERNAL_DEBUG_SYMBOLS=false
281
elif test "x$with_native_debug_symbols" = xexternal; then
283
if test "x$OPENJDK_TARGET_OS" = xlinux; then
284
if test "x$OBJCOPY" = x; then
285
# enabling of enable-debug-symbols and can't find objcopy
287
AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
291
COMPILE_WITH_DEBUG_SYMBOLS=true
292
COPY_DEBUG_SYMBOLS=true
293
ZIP_EXTERNAL_DEBUG_SYMBOLS=false
294
elif test "x$with_native_debug_symbols" = xzipped; then
296
if test "x$OPENJDK_TARGET_OS" = xlinux; then
297
if test "x$OBJCOPY" = x; then
298
# enabling of enable-debug-symbols and can't find objcopy
300
AC_MSG_ERROR([Unable to find objcopy, cannot enable native debug symbols])
304
COMPILE_WITH_DEBUG_SYMBOLS=true
305
COPY_DEBUG_SYMBOLS=true
306
ZIP_EXTERNAL_DEBUG_SYMBOLS=true
308
AC_MSG_ERROR([Allowed native debug symbols are: none, internal, external, zipped])
311
AC_SUBST(COMPILE_WITH_DEBUG_SYMBOLS)
312
AC_SUBST(COPY_DEBUG_SYMBOLS)
313
AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS)
315
# Should we add external native debug symbols to the shipped bundles?
316
AC_MSG_CHECKING([if we should add external native debug symbols to the shipped bundles])
317
AC_ARG_WITH([external-symbols-in-bundles],
318
[AS_HELP_STRING([--with-external-symbols-in-bundles],
319
[which type of external native debug symbol information shall be shipped in product bundles (none, public, full)
320
(e.g. ship full/stripped pdbs on Windows) @<:@none@:>@])])
322
if test "x$with_external_symbols_in_bundles" = x || test "x$with_external_symbols_in_bundles" = xnone ; then
324
elif test "x$with_external_symbols_in_bundles" = xfull || test "x$with_external_symbols_in_bundles" = xpublic ; then
325
if test "x$OPENJDK_TARGET_OS" != xwindows ; then
326
AC_MSG_ERROR([--with-external-symbols-in-bundles currently only works on windows!])
327
elif test "x$COPY_DEBUG_SYMBOLS" != xtrue ; then
328
AC_MSG_ERROR([--with-external-symbols-in-bundles only works when --with-native-debug-symbols=external is used!])
329
elif test "x$with_external_symbols_in_bundles" = xfull ; then
330
AC_MSG_RESULT([full])
331
SHIP_DEBUG_SYMBOLS=full
333
AC_MSG_RESULT([public])
334
SHIP_DEBUG_SYMBOLS=public
337
AC_MSG_ERROR([$with_external_symbols_in_bundles is an unknown value for --with-external-symbols-in-bundles])
340
AC_SUBST(SHIP_DEBUG_SYMBOLS)
343
################################################################################
345
# Native and Java code coverage
347
AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE],
349
UTIL_ARG_ENABLE(NAME: native-coverage, DEFAULT: false, RESULT: GCOV_ENABLED,
350
DESC: [enable native compilation with code coverage data],
352
AC_MSG_CHECKING([if native coverage is available])
353
if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
354
test "x$TOOLCHAIN_TYPE" = "xclang"; then
362
GCOV_CFLAGS="-fprofile-arcs -ftest-coverage -fno-inline"
363
GCOV_LDFLAGS="-fprofile-arcs"
364
JVM_CFLAGS="$JVM_CFLAGS $GCOV_CFLAGS"
365
JVM_LDFLAGS="$JVM_LDFLAGS $GCOV_LDFLAGS"
366
CFLAGS_JDKLIB="$CFLAGS_JDKLIB $GCOV_CFLAGS"
367
CFLAGS_JDKEXE="$CFLAGS_JDKEXE $GCOV_CFLAGS"
368
CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $GCOV_CFLAGS"
369
CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS"
370
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS"
371
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS"
373
AC_SUBST(GCOV_ENABLED)
375
AC_ARG_WITH(jcov, [AS_HELP_STRING([--with-jcov],
376
[jcov library location])])
377
AC_ARG_WITH(jcov-input-jdk, [AS_HELP_STRING([--with-jcov-input-jdk],
378
[jdk image to instrument])])
379
AC_ARG_WITH(jcov-filters, [AS_HELP_STRING([--with-jcov-filters],
380
[filters to limit code for jcov instrumentation and report generation])])
385
if test "x$with_jcov" = "x" ; then
388
JCOV_HOME="$with_jcov"
389
if test ! -f "$JCOV_HOME/lib/jcov.jar"; then
390
AC_MSG_RESULT([fail])
391
AC_MSG_ERROR([Invalid JCov bundle: "$JCOV_HOME/lib/jcov.jar" does not exist])
394
UTIL_FIXUP_PATH(JCOV_HOME)
395
if test "x$with_jcov_input_jdk" != "x" ; then
396
JCOV_INPUT_JDK="$with_jcov_input_jdk"
397
if test ! -f "$JCOV_INPUT_JDK/bin/java" && test ! -f "$JCOV_INPUT_JDK/bin/java.exe"; then
398
AC_MSG_RESULT([fail])
399
AC_MSG_ERROR([Invalid JDK bundle: "$JCOV_INPUT_JDK/bin/java" does not exist])
401
UTIL_FIXUP_PATH(JCOV_INPUT_JDK)
403
if test "x$with_jcov_filters" != "x" ; then
404
JCOV_FILTERS="$with_jcov_filters"
407
AC_SUBST(JCOV_ENABLED)
409
AC_SUBST(JCOV_INPUT_JDK)
410
AC_SUBST(JCOV_FILTERS)
413
###############################################################################
417
AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
419
UTIL_ARG_ENABLE(NAME: asan, DEFAULT: false, RESULT: ASAN_ENABLED,
420
DESC: [enable AddressSanitizer],
422
AC_MSG_CHECKING([if AddressSanitizer (asan) is available])
423
if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
424
test "x$TOOLCHAIN_TYPE" = "xclang" ||
425
test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
433
if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
434
test "x$TOOLCHAIN_TYPE" = "xclang"; then
435
# ASan is simply incompatible with gcc -Wstringop-truncation. See
436
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85650
437
# It's harmless to be suppressed in clang as well.
438
ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
439
ASAN_LDFLAGS="-fsanitize=address"
440
# detect_stack_use_after_return causes ASAN to offload stack-local
441
# variables to c-heap and therefore breaks assumptions in hotspot
442
# that rely on data (e.g. Marks) living in thread stacks.
443
if test "x$TOOLCHAIN_TYPE" = "xgcc"; then
444
ASAN_CFLAGS="$ASAN_CFLAGS --param asan-use-after-return=0"
446
if test "x$TOOLCHAIN_TYPE" = "xclang"; then
447
ASAN_CFLAGS="$ASAN_CFLAGS -fsanitize-address-use-after-return=never"
449
elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
450
# -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang.
451
ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER"
452
# MSVC produces a warning if you pass -fsanitize=address to the linker. It also complains
453
$ if -DEBUG is not passed to the linker when building with ASan.
454
ASAN_LDFLAGS="-debug"
455
# -fsanitize-address-use-after-return is off by default in MS Visual Studio 22 (19.37.32824).
456
# cl : Command line warning D9002 : ignoring unknown option '-fno-sanitize-address-use-after-return'
458
JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
459
JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
460
CFLAGS_JDKLIB="$CFLAGS_JDKLIB $ASAN_CFLAGS"
461
CFLAGS_JDKEXE="$CFLAGS_JDKEXE $ASAN_CFLAGS"
462
CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $ASAN_CFLAGS"
463
CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $ASAN_CFLAGS"
464
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $ASAN_LDFLAGS"
465
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $ASAN_LDFLAGS"
467
AC_SUBST(ASAN_ENABLED)
470
###############################################################################
474
AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER],
476
UTIL_ARG_ENABLE(NAME: lsan, DEFAULT: false, RESULT: LSAN_ENABLED,
477
DESC: [enable LeakSanitizer],
479
AC_MSG_CHECKING([if LeakSanitizer (lsan) is available])
480
if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
481
test "x$TOOLCHAIN_TYPE" = "xclang"; then
489
LSAN_CFLAGS="-fsanitize=leak -fno-omit-frame-pointer -DLEAK_SANITIZER"
490
LSAN_LDFLAGS="-fsanitize=leak"
491
JVM_CFLAGS="$JVM_CFLAGS $LSAN_CFLAGS"
492
JVM_LDFLAGS="$JVM_LDFLAGS $LSAN_LDFLAGS"
493
CFLAGS_JDKLIB="$CFLAGS_JDKLIB $LSAN_CFLAGS"
494
CFLAGS_JDKEXE="$CFLAGS_JDKEXE $LSAN_CFLAGS"
495
CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $LSAN_CFLAGS"
496
CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $LSAN_CFLAGS"
497
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $LSAN_LDFLAGS"
498
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $LSAN_LDFLAGS"
500
AC_SUBST(LSAN_ENABLED)
503
###############################################################################
505
# UndefinedBehaviorSanitizer
507
AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER],
509
UTIL_ARG_WITH(NAME: additional-ubsan-checks, TYPE: string,
511
DESC: [Customizes the ubsan checks],
514
# GCC reports lots of likely false positives for stringop-truncation and format-overflow.
515
# Silence them for now.
516
UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment \
517
$ADDITIONAL_UBSAN_CHECKS"
518
UBSAN_CFLAGS="$UBSAN_CHECKS -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER"
519
UBSAN_LDFLAGS="$UBSAN_CHECKS"
520
UTIL_ARG_ENABLE(NAME: ubsan, DEFAULT: false, RESULT: UBSAN_ENABLED,
521
DESC: [enable UndefinedBehaviorSanitizer],
523
AC_MSG_CHECKING([if UndefinedBehaviorSanitizer (ubsan) is available])
524
if test "x$TOOLCHAIN_TYPE" = "xgcc" ||
525
test "x$TOOLCHAIN_TYPE" = "xclang"; then
533
JVM_CFLAGS="$JVM_CFLAGS $UBSAN_CFLAGS"
534
JVM_LDFLAGS="$JVM_LDFLAGS $UBSAN_LDFLAGS"
535
CFLAGS_JDKLIB="$CFLAGS_JDKLIB $UBSAN_CFLAGS"
536
CFLAGS_JDKEXE="$CFLAGS_JDKEXE $UBSAN_CFLAGS"
537
CXXFLAGS_JDKLIB="$CXXFLAGS_JDKLIB $UBSAN_CFLAGS"
538
CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $UBSAN_CFLAGS"
539
LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $UBSAN_LDFLAGS"
540
LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $UBSAN_LDFLAGS"
542
if test "x$UBSAN_ENABLED" = xfalse; then
546
AC_SUBST(UBSAN_CFLAGS)
547
AC_SUBST(UBSAN_LDFLAGS)
548
AC_SUBST(UBSAN_ENABLED)
551
################################################################################
553
# Static build support. When enabled will generate static
554
# libraries instead of shared libraries for all JDK libs.
556
AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_BUILD],
558
UTIL_DEPRECATED_ARG_ENABLE(static-build)
561
################################################################################
565
AC_DEFUN_ONCE([JDKOPT_SETUP_JMOD_OPTIONS],
567
# Final JMODs are recompiled often during development, and java.base JMOD
568
# includes the JVM libraries. In release mode, prefer to compress JMODs fully.
569
# In debug mode, pay with a little extra space, but win a lot of CPU time back
570
# with the lightest (but still some) compression.
571
if test "x$DEBUG_LEVEL" = xrelease; then
572
DEFAULT_JMOD_COMPRESS="zip-6"
574
DEFAULT_JMOD_COMPRESS="zip-1"
577
UTIL_ARG_WITH(NAME: jmod-compress, TYPE: literal,
578
VALID_VALUES: [zip-0 zip-1 zip-2 zip-3 zip-4 zip-5 zip-6 zip-7 zip-8 zip-9],
579
DEFAULT: $DEFAULT_JMOD_COMPRESS,
580
CHECKING_MSG: [for JMOD compression type],
581
DESC: [specify JMOD compression type (zip-[0-9])]
583
AC_SUBST(JMOD_COMPRESS)
586
################################################################################
589
# We always keep packaged modules in JDK image.
591
AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
593
UTIL_ARG_ENABLE(NAME: keep-packaged-modules, DEFAULT: true,
594
RESULT: JLINK_KEEP_PACKAGED_MODULES,
595
DESC: [enable keeping of packaged modules in jdk image],
596
CHECKING_MSG: [if packaged modules are kept])
597
AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
600
################################################################################
602
# Enable or disable generation of the classlist at build time
604
AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST],
606
# In GenerateLinkOptData.gmk, DumpLoadedClassList is used to generate the
607
# classlist file. It never will work if CDS is disabled, since the VM will report
608
# an error for DumpLoadedClassList.
609
UTIL_ARG_ENABLE(NAME: generate-classlist, DEFAULT: auto,
610
RESULT: ENABLE_GENERATE_CLASSLIST, AVAILABLE: $ENABLE_CDS,
611
DESC: [enable generation of a CDS classlist at build time],
612
DEFAULT_DESC: [enabled if the JVM feature 'cds' is enabled for all JVM variants],
613
CHECKING_MSG: [if the CDS classlist generation should be enabled])
614
AC_SUBST(ENABLE_GENERATE_CLASSLIST)
617
################################################################################
619
# Optionally filter resource translations
621
AC_DEFUN([JDKOPT_EXCLUDE_TRANSLATIONS],
623
AC_ARG_WITH([exclude-translations], [AS_HELP_STRING([--with-exclude-translations],
624
[a comma separated list of locales to exclude translations for. Default is
625
to include all translations present in the source.])])
627
EXCLUDE_TRANSLATIONS=""
628
AC_MSG_CHECKING([if any translations should be excluded])
629
if test "x$with_exclude_translations" != "x"; then
630
EXCLUDE_TRANSLATIONS="${with_exclude_translations//,/ }"
631
AC_MSG_RESULT([yes: $EXCLUDE_TRANSLATIONS])
636
AC_SUBST(EXCLUDE_TRANSLATIONS)
639
################################################################################
641
# Optionally disable man pages
643
AC_DEFUN([JDKOPT_ENABLE_DISABLE_MANPAGES],
645
UTIL_ARG_ENABLE(NAME: manpages, DEFAULT: true, RESULT: BUILD_MANPAGES,
646
DESC: [enable copying of static man pages],
647
CHECKING_MSG: [if static man pages should be copied])
648
AC_SUBST(BUILD_MANPAGES)
651
################################################################################
653
# Disable the default CDS archive generation
655
AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE],
657
UTIL_ARG_ENABLE(NAME: cds-archive, DEFAULT: auto, RESULT: BUILD_CDS_ARCHIVE,
658
DESC: [enable generation of a default CDS archive in the product image],
659
DEFAULT_DESC: [enabled if possible],
660
CHECKING_MSG: [if a default CDS archive should be generated],
662
AC_MSG_CHECKING([if CDS archive is available])
663
if test "x$ENABLE_CDS" = "xfalse"; then
664
AC_MSG_RESULT([no (CDS is disabled)])
666
elif test "x$COMPILE_TYPE" = "xcross"; then
667
AC_MSG_RESULT([no (not possible with cross compilation)])
673
AC_SUBST(BUILD_CDS_ARCHIVE)
676
################################################################################
678
# Enable the alternative CDS core region alignment
680
AC_DEFUN([JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT],
682
UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: $COMPATIBLE_CDS_ALIGNMENT_DEFAULT,
683
RESULT: ENABLE_COMPATIBLE_CDS_ALIGNMENT,
684
DESC: [enable use alternative compatible cds core region alignment],
685
DEFAULT_DESC: [disabled except on linux-aarch64],
686
CHECKING_MSG: [if compatible cds region alignment enabled],
688
AC_MSG_CHECKING([if CDS archive is available])
689
if test "x$ENABLE_CDS" = "xfalse"; then
691
AC_MSG_RESULT([no (CDS is disabled)])
697
AC_SUBST(ENABLE_COMPATIBLE_CDS_ALIGNMENT)
700
################################################################################
702
# Disallow any output from containing absolute paths from the build system.
703
# This setting defaults to allowed on debug builds and not allowed on release
706
AC_DEFUN([JDKOPT_ALLOW_ABSOLUTE_PATHS_IN_OUTPUT],
708
AC_ARG_ENABLE([absolute-paths-in-output],
709
[AS_HELP_STRING([--disable-absolute-paths-in-output],
710
[Set to disable to prevent any absolute paths from the build to end up in
711
any of the build output. @<:@disabled in release builds, otherwise enabled@:>@])
714
AC_MSG_CHECKING([if absolute paths should be allowed in the build output])
715
if test "x$enable_absolute_paths_in_output" = "xno"; then
716
AC_MSG_RESULT([no, forced])
717
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false"
718
elif test "x$enable_absolute_paths_in_output" = "xyes"; then
719
AC_MSG_RESULT([yes, forced])
720
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true"
721
elif test "x$DEBUG_LEVEL" = "xrelease"; then
722
AC_MSG_RESULT([no, release build])
723
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="false"
725
AC_MSG_RESULT([yes, debug build])
726
ALLOW_ABSOLUTE_PATHS_IN_OUTPUT="true"
729
AC_SUBST(ALLOW_ABSOLUTE_PATHS_IN_OUTPUT)
732
################################################################################
734
# Check and set options related to reproducible builds.
736
AC_DEFUN_ONCE([JDKOPT_SETUP_REPRODUCIBLE_BUILD],
738
AC_ARG_WITH([source-date], [AS_HELP_STRING([--with-source-date],
739
[how to set SOURCE_DATE_EPOCH ('updated', 'current', 'version' a timestamp or an ISO-8601 date) @<:@current/value of SOURCE_DATE_EPOCH@:>@])],
740
[with_source_date_present=true], [with_source_date_present=false])
742
if test "x$SOURCE_DATE_EPOCH" != x && test "x$with_source_date" != x; then
743
AC_MSG_WARN([--with-source-date will override SOURCE_DATE_EPOCH])
746
AC_MSG_CHECKING([what source date to use])
748
if test "x$with_source_date" = xyes; then
749
AC_MSG_ERROR([--with-source-date must have a value])
750
elif test "x$with_source_date" = x; then
751
if test "x$SOURCE_DATE_EPOCH" != x; then
752
SOURCE_DATE=$SOURCE_DATE_EPOCH
753
with_source_date_present=true
754
AC_MSG_RESULT([$SOURCE_DATE, from SOURCE_DATE_EPOCH])
756
# Tell makefiles to take the time from configure
757
SOURCE_DATE=$($DATE +"%s")
758
AC_MSG_RESULT([$SOURCE_DATE, from 'current' (default)])
760
elif test "x$with_source_date" = xupdated; then
762
AC_MSG_RESULT([determined at build time, from 'updated'])
763
elif test "x$with_source_date" = xcurrent; then
764
# Set the current time
765
SOURCE_DATE=$($DATE +"%s")
766
AC_MSG_RESULT([$SOURCE_DATE, from 'current'])
767
elif test "x$with_source_date" = xversion; then
768
# Use the date from version-numbers.conf
769
UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $DEFAULT_VERSION_DATE)
770
if test "x$SOURCE_DATE" = x; then
771
AC_MSG_RESULT([unavailable])
772
AC_MSG_ERROR([Cannot convert DEFAULT_VERSION_DATE to timestamp])
774
AC_MSG_RESULT([$SOURCE_DATE, from 'version'])
776
# It's a timestamp, an ISO-8601 date, or an invalid string
777
# Additional [] needed to keep m4 from mangling shell constructs.
778
if [ [[ "$with_source_date" =~ ^[0-9][0-9]*$ ]] ] ; then
779
SOURCE_DATE=$with_source_date
780
AC_MSG_RESULT([$SOURCE_DATE, from timestamp on command line])
782
UTIL_GET_EPOCH_TIMESTAMP(SOURCE_DATE, $with_source_date)
783
if test "x$SOURCE_DATE" != x; then
784
AC_MSG_RESULT([$SOURCE_DATE, from ISO-8601 date on command line])
786
AC_MSG_RESULT([unavailable])
787
AC_MSG_ERROR([Cannot parse date string "$with_source_date"])
792
ISO_8601_FORMAT_STRING="%Y-%m-%dT%H:%M:%SZ"
793
if test "x$SOURCE_DATE" != xupdated; then
794
# If we have a fixed value for SOURCE_DATE, we need to set SOURCE_DATE_EPOCH
795
# for the rest of configure.
796
SOURCE_DATE_EPOCH="$SOURCE_DATE"
797
if test "x$IS_GNU_DATE" = xyes; then
798
SOURCE_DATE_ISO_8601=`$DATE --utc --date="@$SOURCE_DATE" +"$ISO_8601_FORMAT_STRING" 2> /dev/null`
800
SOURCE_DATE_ISO_8601=`$DATE -u -j -f "%s" "$SOURCE_DATE" +"$ISO_8601_FORMAT_STRING" 2> /dev/null`
804
AC_SUBST(SOURCE_DATE)
805
AC_SUBST(ISO_8601_FORMAT_STRING)
806
AC_SUBST(SOURCE_DATE_ISO_8601)
808
UTIL_DEPRECATED_ARG_ENABLE(reproducible-build)
811
################################################################################
813
# Setup signing on macOS. This can either be setup to sign with a real identity
814
# and enabling the hardened runtime, or it can simply add the debug entitlement
815
# com.apple.security.get-task-allow without actually signing any binaries. The
816
# latter is needed to be able to debug processes and dump core files on modern
817
# versions of macOS. It can also be skipped completely.
819
# Check if codesign will run with the given parameters
820
# $1: Parameters to run with
821
# $2: Checking message
822
# Sets CODESIGN_SUCCESS=true/false
823
AC_DEFUN([JDKOPT_CHECK_CODESIGN_PARAMS],
827
CODESIGN_TESTFILE="$CONFIGURESUPPORT_OUTPUTDIR/codesign-testfile"
828
$RM "$CODESIGN_TESTFILE"
829
$TOUCH "$CODESIGN_TESTFILE"
830
CODESIGN_SUCCESS=false
832
$ECHO "check codesign, calling $CODESIGN $PARAMS $CODESIGN_TESTFILE" >&AS_MESSAGE_LOG_FD
834
eval \"$CODESIGN\" $PARAMS \"$CODESIGN_TESTFILE\" 2>&AS_MESSAGE_LOG_FD \
835
>&AS_MESSAGE_LOG_FD && CODESIGN_SUCCESS=true
836
$RM "$CODESIGN_TESTFILE"
837
AC_MSG_CHECKING([$MESSAGE])
838
if test "x$CODESIGN_SUCCESS" = "xtrue"; then
845
AC_DEFUN([JDKOPT_CHECK_CODESIGN_HARDENED],
847
JDKOPT_CHECK_CODESIGN_PARAMS([-s \"$MACOSX_CODESIGN_IDENTITY\" --option runtime],
848
[if codesign with hardened runtime is possible])
851
AC_DEFUN([JDKOPT_CHECK_CODESIGN_DEBUG],
853
JDKOPT_CHECK_CODESIGN_PARAMS([-s -], [if debug mode codesign is possible])
856
AC_DEFUN([JDKOPT_SETUP_MACOSX_SIGNING],
858
MACOSX_CODESIGN_MODE=disabled
859
if test "x$OPENJDK_TARGET_OS" = "xmacosx" && test "x$CODESIGN" != "x"; then
861
UTIL_ARG_WITH(NAME: macosx-codesign, TYPE: literal, OPTIONAL: true,
862
VALID_VALUES: [hardened debug auto], DEFAULT: auto,
863
ENABLED_DEFAULT: true,
864
CHECKING_MSG: [for macosx code signing mode],
865
DESC: [set the macosx code signing mode (hardened, debug, auto)]
868
if test "x$MACOSX_CODESIGN_ENABLED" = "xtrue"; then
870
# Check for user provided code signing identity.
871
UTIL_ARG_WITH(NAME: macosx-codesign-identity, TYPE: string,
872
DEFAULT: openjdk_codesign, CHECK_VALUE: [UTIL_CHECK_STRING_NON_EMPTY],
873
DESC: [specify the macosx code signing identity],
874
CHECKING_MSG: [for macosx code signing identity]
876
AC_SUBST(MACOSX_CODESIGN_IDENTITY)
878
if test "x$MACOSX_CODESIGN" = "xauto"; then
879
# Only try to default to hardened signing on release builds
880
if test "x$DEBUG_LEVEL" = "xrelease"; then
881
JDKOPT_CHECK_CODESIGN_HARDENED
882
if test "x$CODESIGN_SUCCESS" = "xtrue"; then
883
MACOSX_CODESIGN_MODE=hardened
886
if test "x$MACOSX_CODESIGN_MODE" = "xdisabled"; then
887
JDKOPT_CHECK_CODESIGN_DEBUG
888
if test "x$CODESIGN_SUCCESS" = "xtrue"; then
889
MACOSX_CODESIGN_MODE=debug
892
AC_MSG_CHECKING([for macosx code signing mode])
893
AC_MSG_RESULT([$MACOSX_CODESIGN_MODE])
894
elif test "x$MACOSX_CODESIGN" = "xhardened"; then
895
JDKOPT_CHECK_CODESIGN_HARDENED
896
if test "x$CODESIGN_SUCCESS" = "xfalse"; then
897
AC_MSG_ERROR([Signing with hardened runtime is not possible])
899
MACOSX_CODESIGN_MODE=hardened
900
elif test "x$MACOSX_CODESIGN" = "xdebug"; then
901
JDKOPT_CHECK_CODESIGN_DEBUG
902
if test "x$CODESIGN_SUCCESS" = "xfalse"; then
903
AC_MSG_ERROR([Signing in debug mode is not possible])
905
MACOSX_CODESIGN_MODE=debug
907
AC_MSG_ERROR([unknown value for --with-macosx-codesign: $MACOSX_CODESIGN])
911
AC_SUBST(MACOSX_CODESIGN_IDENTITY)
912
AC_SUBST(MACOSX_CODESIGN_MODE)
915
################################################################################
919
AC_DEFUN_ONCE([JDKOPT_SETUP_FALLBACK_LINKER],
921
FALLBACK_LINKER_DEFAULT=false
923
if HOTSPOT_CHECK_JVM_VARIANT(zero); then
924
FALLBACK_LINKER_DEFAULT=true
927
UTIL_ARG_ENABLE(NAME: fallback-linker, DEFAULT: $FALLBACK_LINKER_DEFAULT,
928
RESULT: ENABLE_FALLBACK_LINKER,
929
DESC: [enable libffi-based fallback implementation of java.lang.foreign.Linker],
930
CHECKING_MSG: [if fallback linker enabled])
931
AC_SUBST(ENABLE_FALLBACK_LINKER)