On Tue, 28 Apr 2026 14:42:56 GMT, Matthias Baesken <[email protected]> wrote:
> Currently we use objcopy to generate debuginfo files. > It would be sometimes helpful to generate debuginfo files with compressed > content (e.g. objcopy --compress-debug-sections=zlib-gnu). > > This could be supported by an additional configure flag. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This is what the '--enable-objcopy-debuginfo-compression' patch could look like, should we go for this ? It is a little less flexible because it can only set at the moment zlib-gnu compression (but afaik this is the best supported/most common mode). diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 89fcbc88521..585356fb6fd 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -323,6 +323,22 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], AC_SUBST(COPY_DEBUG_SYMBOLS) AC_SUBST(ZIP_EXTERNAL_DEBUG_SYMBOLS) + # Should we enable objcopy debuginfo compression ? + AC_ARG_ENABLE(objcopy-debuginfo-compression, AS_HELP_STRING( + [--enable-objcopy-debuginfo-compression], + [Set to enable compression in the debuginfo files])) + + AC_MSG_CHECKING([if debuginfo compression with objcopy is done]) + if test "x$enable_objcopy_debuginfo_compression" = "xno"; then + ENABLE_OBJCOPY_DEBUGINFO_COMPRESSION="false" + elif test "x$enable_objcopy_debuginfo_compression" = "xyes"; then + ENABLE_OBJCOPY_DEBUGINFO_COMPRESSION="true" + else + ENABLE_OBJCOPY_DEBUGINFO_COMPRESSION="false" + fi + + AC_SUBST(ENABLE_OBJCOPY_DEBUGINFO_COMPRESSION) + # Should we add external native debug symbols to the shipped bundles? AC_MSG_CHECKING([if we should add external native debug symbols to the shipped bundles]) AC_ARG_WITH([external-symbols-in-bundles], diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template index 2a3f2793a32..52147aeeb09 100644 --- a/make/autoconf/spec.gmk.template +++ b/make/autoconf/spec.gmk.template @@ -635,6 +635,7 @@ METALLIB := @METALLIB@ COMPILE_WITH_DEBUG_SYMBOLS := @COMPILE_WITH_DEBUG_SYMBOLS@ COPY_DEBUG_SYMBOLS := @COPY_DEBUG_SYMBOLS@ ZIP_EXTERNAL_DEBUG_SYMBOLS := @ZIP_EXTERNAL_DEBUG_SYMBOLS@ +ENABLE_OBJCOPY_DEBUGINFO_COMPRESSION := @ENABLE_OBJCOPY_DEBUGINFO_COMPRESSION@ CFLAGS_DEBUG_SYMBOLS := @CFLAGS_DEBUG_SYMBOLS@ ASFLAGS_DEBUG_SYMBOLS := @ASFLAGS_DEBUG_SYMBOLS@ diff --git a/make/common/native/Link.gmk b/make/common/native/Link.gmk index 855e50bddfb..9f920f360df 100644 --- a/make/common/native/Link.gmk +++ b/make/common/native/Link.gmk @@ -146,6 +146,11 @@ define CreateStaticLibrary $$(ECHO) $$(strip $$($1_LIBS) $$($1_EXTRA_LIBS)) > $$($1_TARGET).lib-flags.txt endef +# Compress DWARF debug sections using zlib +ifeq ($(ENABLE_OBJCOPY_DEBUGINFO_COMPRESSION), true) + OBJCOPY_COMPRESS_FLAG := --compress-debug-sections=zlib-gnu +endif + ################################################################################ define CreateDynamicLibraryOrExecutable # A shared dynamic library or an executable binary has been specified @@ -189,7 +194,7 @@ define CreateDynamicLibraryOrExecutable # This cannot be run separately since it updates the original target # file. $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_create_debuginfo, \ - $$($1_OBJCOPY) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES)) + $$($1_OBJCOPY) $(OBJCOPY_COMPRESS_FLAG) --only-keep-debug $$($1_TARGET) $$($1_DEBUGINFO_FILES)) $$(CHMOD) -x $$($1_DEBUGINFO_FILES) else ifeq ($(call isTargetOs, aix), true) # AIX does not provide the equivalent of objcopy to extract debug ------------- PR Comment: https://git.openjdk.org/jdk/pull/30971#issuecomment-4352871635
