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