Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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) <sedat.dilek@dhl.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Nick Desaulniers and committed by
Masahiro Yamada
9f8fe647 0d2573a2

+32 -3
+27 -2
lib/Kconfig.debug
··· 312 312 DEBUG_INFO build and compile times are reduced too. 313 313 Only works with newer gcc versions. 314 314 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" 317 330 depends on $(cc-option,-gz=zlib) 318 331 depends on $(ld-option,--compress-debug-sections=zlib) 319 332 help ··· 339 326 recompressed with a different compression scheme. But this is still 340 327 preferable to setting $KDEB_COMPRESS to "none" which would be even 341 328 larger. 329 + 330 + config DEBUG_INFO_COMPRESSED_ZSTD 331 + bool "Compress debugging information with zstd" 332 + depends on $(cc-option,-gz=zstd) 333 + depends on $(ld-option,--compress-debug-sections=zstd) 334 + help 335 + Compress the debug information using zstd. This may provide better 336 + compression than zlib, for about the same time costs, but requires newer 337 + toolchain support. Requires GCC 13.0+ or Clang 16.0+, binutils 2.40+, and 338 + zstd. 339 + 340 + endchoice # "Compressed Debug information" 342 341 343 342 config DEBUG_INFO_SPLIT 344 343 bool "Produce split debuginfo in .dwo files"
+5 -1
scripts/Makefile.debug
··· 27 27 DEBUG_RUSTFLAGS += -Cdebuginfo=2 28 28 endif 29 29 30 - ifdef CONFIG_DEBUG_INFO_COMPRESSED 30 + ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZLIB 31 31 DEBUG_CFLAGS += -gz=zlib 32 32 KBUILD_AFLAGS += -gz=zlib 33 33 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 34 38 endif 35 39 36 40 KBUILD_CFLAGS += $(DEBUG_CFLAGS)