mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 23:54:04 +08:00
9f8fe64779
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>
45 lines
1.1 KiB
Makefile
45 lines
1.1 KiB
Makefile
DEBUG_CFLAGS :=
|
|
DEBUG_RUSTFLAGS :=
|
|
|
|
debug-flags-y := -g
|
|
|
|
ifdef CONFIG_DEBUG_INFO_SPLIT
|
|
DEBUG_CFLAGS += -gsplit-dwarf
|
|
endif
|
|
|
|
debug-flags-$(CONFIG_DEBUG_INFO_DWARF4) += -gdwarf-4
|
|
debug-flags-$(CONFIG_DEBUG_INFO_DWARF5) += -gdwarf-5
|
|
ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_AS_IS_GNU),yy)
|
|
# Clang does not pass -g or -gdwarf-* option down to GAS.
|
|
# Add -Wa, prefix to explicitly specify the flags.
|
|
KBUILD_AFLAGS += $(addprefix -Wa$(comma), $(debug-flags-y))
|
|
endif
|
|
DEBUG_CFLAGS += $(debug-flags-y)
|
|
KBUILD_AFLAGS += $(debug-flags-y)
|
|
|
|
ifdef CONFIG_DEBUG_INFO_REDUCED
|
|
DEBUG_CFLAGS += -fno-var-tracking
|
|
DEBUG_RUSTFLAGS += -Cdebuginfo=1
|
|
ifdef CONFIG_CC_IS_GCC
|
|
DEBUG_CFLAGS += -femit-struct-debug-baseonly
|
|
endif
|
|
else
|
|
DEBUG_RUSTFLAGS += -Cdebuginfo=2
|
|
endif
|
|
|
|
ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZLIB
|
|
DEBUG_CFLAGS += -gz=zlib
|
|
KBUILD_AFLAGS += -gz=zlib
|
|
KBUILD_LDFLAGS += --compress-debug-sections=zlib
|
|
else ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZSTD
|
|
DEBUG_CFLAGS += -gz=zstd
|
|
KBUILD_AFLAGS += -gz=zstd
|
|
KBUILD_LDFLAGS += --compress-debug-sections=zstd
|
|
endif
|
|
|
|
KBUILD_CFLAGS += $(DEBUG_CFLAGS)
|
|
export DEBUG_CFLAGS
|
|
|
|
KBUILD_RUSTFLAGS += $(DEBUG_RUSTFLAGS)
|
|
export DEBUG_RUSTFLAGS
|