1DEBUG_CFLAGS := 2DEBUG_RUSTFLAGS := 3 4debug-flags-y := -g 5 6ifdef CONFIG_DEBUG_INFO_SPLIT 7DEBUG_CFLAGS += -gsplit-dwarf 8endif 9 10debug-flags-$(CONFIG_DEBUG_INFO_DWARF4) += -gdwarf-4 11debug-flags-$(CONFIG_DEBUG_INFO_DWARF5) += -gdwarf-5 12ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_AS_IS_GNU),yy) 13# Clang does not pass -g or -gdwarf-* option down to GAS. 14# Add -Wa, prefix to explicitly specify the flags. 15KBUILD_AFLAGS += $(addprefix -Wa$(comma), $(debug-flags-y)) 16endif 17DEBUG_CFLAGS += $(debug-flags-y) 18KBUILD_AFLAGS += $(debug-flags-y) 19 20ifdef CONFIG_DEBUG_INFO_DWARF4 21DEBUG_RUSTFLAGS += -Zdwarf-version=4 22else ifdef CONFIG_DEBUG_INFO_DWARF5 23DEBUG_RUSTFLAGS += -Zdwarf-version=5 24endif 25 26ifdef CONFIG_DEBUG_INFO_REDUCED 27DEBUG_CFLAGS += -fno-var-tracking 28DEBUG_RUSTFLAGS += -Cdebuginfo=1 29ifdef CONFIG_CC_IS_GCC 30DEBUG_CFLAGS += -femit-struct-debug-baseonly 31endif 32else 33DEBUG_RUSTFLAGS += -Cdebuginfo=2 34endif 35 36ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZLIB 37DEBUG_CFLAGS += -gz=zlib 38KBUILD_AFLAGS += -gz=zlib 39KBUILD_LDFLAGS += --compress-debug-sections=zlib 40else ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZSTD 41DEBUG_CFLAGS += -gz=zstd 42KBUILD_AFLAGS += -gz=zstd 43KBUILD_LDFLAGS += --compress-debug-sections=zstd 44endif 45 46KBUILD_CFLAGS += $(DEBUG_CFLAGS) 47export DEBUG_CFLAGS 48 49KBUILD_RUSTFLAGS += $(DEBUG_RUSTFLAGS) 50export DEBUG_RUSTFLAGS 51