Skip to content

Commit 9f8fe64

Browse files
nickdesaulniersmasahir0y
authored andcommitted
Makefile.debug: support for -gz=zstd
Make DEBUG_INFO_COMPRESSED a choice; DEBUG_INFO_COMPRESSED_NONE is the default, DEBUG_INFO_COMPRESSED_ZLIB uses zlib, DEBUG_INFO_COMPRESSED_ZSTD uses zstd. This renames the existing KConfig option DEBUG_INFO_COMPRESSED to DEBUG_INFO_COMPRESSED_ZLIB so users upgrading may need to reset the new Kconfigs. Some quick N=1 measurements with du, /usr/bin/time -v, and bloaty: clang-16, x86_64 defconfig plus CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_COMPRESSED_NONE=y: Elapsed (wall clock) time (h:mm:ss or m:ss): 0:55.43 488M vmlinux 27.6% 136Mi 0.0% 0 .debug_info 6.1% 30.2Mi 0.0% 0 .debug_str_offsets 3.5% 17.2Mi 0.0% 0 .debug_line 3.3% 16.3Mi 0.0% 0 .debug_loclists 0.9% 4.62Mi 0.0% 0 .debug_str clang-16, x86_64 defconfig plus CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_COMPRESSED_ZLIB=y: Elapsed (wall clock) time (h:mm:ss or m:ss): 1:00.35 385M vmlinux 21.8% 85.4Mi 0.0% 0 .debug_info 2.1% 8.26Mi 0.0% 0 .debug_str_offsets 2.1% 8.24Mi 0.0% 0 .debug_loclists 1.9% 7.48Mi 0.0% 0 .debug_line 0.5% 1.94Mi 0.0% 0 .debug_str clang-16, x86_64 defconfig plus CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_COMPRESSED_ZSTD=y: Elapsed (wall clock) time (h:mm:ss or m:ss): 0:59.69 373M vmlinux 21.4% 81.4Mi 0.0% 0 .debug_info 2.3% 8.85Mi 0.0% 0 .debug_loclists 1.5% 5.71Mi 0.0% 0 .debug_line 0.5% 1.95Mi 0.0% 0 .debug_str_offsets 0.4% 1.62Mi 0.0% 0 .debug_str That's only a 3.11% overall binary size savings over zlib, but at no performance regression. Link: https://maskray.me/blog/2022-09-09-zstd-compressed-debug-sections Link: https://maskray.me/blog/2022-01-23-compressed-debug-sections Suggested-by: Sedat Dilek (DHL Supply Chain) <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 0d2573a commit 9f8fe64

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

lib/Kconfig.debug

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,21 @@ config DEBUG_INFO_REDUCED
312312
DEBUG_INFO build and compile times are reduced too.
313313
Only works with newer gcc versions.
314314

315-
config DEBUG_INFO_COMPRESSED
316-
bool "Compressed debugging information"
315+
choice
316+
prompt "Compressed Debug information"
317+
help
318+
Compress the resulting debug info. Results in smaller debug info sections,
319+
but requires that consumers are able to decompress the results.
320+
321+
If unsure, choose DEBUG_INFO_COMPRESSED_NONE.
322+
323+
config DEBUG_INFO_COMPRESSED_NONE
324+
bool "Don't compress debug information"
325+
help
326+
Don't compress debug info sections.
327+
328+
config DEBUG_INFO_COMPRESSED_ZLIB
329+
bool "Compress debugging information with zlib"
317330
depends on $(cc-option,-gz=zlib)
318331
depends on $(ld-option,--compress-debug-sections=zlib)
319332
help
@@ -327,6 +340,18 @@ config DEBUG_INFO_COMPRESSED
327340
preferable to setting $KDEB_COMPRESS to "none" which would be even
328341
larger.
329342

343+
config DEBUG_INFO_COMPRESSED_ZSTD
344+
bool "Compress debugging information with zstd"
345+
depends on $(cc-option,-gz=zstd)
346+
depends on $(ld-option,--compress-debug-sections=zstd)
347+
help
348+
Compress the debug information using zstd. This may provide better
349+
compression than zlib, for about the same time costs, but requires newer
350+
toolchain support. Requires GCC 13.0+ or Clang 16.0+, binutils 2.40+, and
351+
zstd.
352+
353+
endchoice # "Compressed Debug information"
354+
330355
config DEBUG_INFO_SPLIT
331356
bool "Produce split debuginfo in .dwo files"
332357
depends on $(cc-option,-gsplit-dwarf)

scripts/Makefile.debug

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ else
2727
DEBUG_RUSTFLAGS += -Cdebuginfo=2
2828
endif
2929

30-
ifdef CONFIG_DEBUG_INFO_COMPRESSED
30+
ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZLIB
3131
DEBUG_CFLAGS += -gz=zlib
3232
KBUILD_AFLAGS += -gz=zlib
3333
KBUILD_LDFLAGS += --compress-debug-sections=zlib
34+
else ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZSTD
35+
DEBUG_CFLAGS += -gz=zstd
36+
KBUILD_AFLAGS += -gz=zstd
37+
KBUILD_LDFLAGS += --compress-debug-sections=zstd
3438
endif
3539

3640
KBUILD_CFLAGS += $(DEBUG_CFLAGS)

0 commit comments

Comments
 (0)