Merge tag 'riscv-for-linus-6.5-mw2' of git://git.kernel.org/pub/scm/linux/kernel...
[platform/kernel/linux-starfive.git] / scripts / Makefile.debug
1 DEBUG_CFLAGS    :=
2 DEBUG_RUSTFLAGS :=
3
4 debug-flags-y   := -g
5
6 ifdef CONFIG_DEBUG_INFO_SPLIT
7 DEBUG_CFLAGS    += -gsplit-dwarf
8 endif
9
10 debug-flags-$(CONFIG_DEBUG_INFO_DWARF4) += -gdwarf-4
11 debug-flags-$(CONFIG_DEBUG_INFO_DWARF5) += -gdwarf-5
12 ifeq ($(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.
15 KBUILD_AFLAGS   += $(addprefix -Wa$(comma), $(debug-flags-y))
16 endif
17 DEBUG_CFLAGS    += $(debug-flags-y)
18 KBUILD_AFLAGS   += $(debug-flags-y)
19
20 ifdef CONFIG_DEBUG_INFO_REDUCED
21 DEBUG_CFLAGS    += -fno-var-tracking
22 DEBUG_RUSTFLAGS += -Cdebuginfo=1
23 ifdef CONFIG_CC_IS_GCC
24 DEBUG_CFLAGS    += -femit-struct-debug-baseonly
25 endif
26 else
27 DEBUG_RUSTFLAGS += -Cdebuginfo=2
28 endif
29
30 ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZLIB
31 DEBUG_CFLAGS    += -gz=zlib
32 KBUILD_AFLAGS   += -gz=zlib
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
38 endif
39
40 KBUILD_CFLAGS   += $(DEBUG_CFLAGS)
41 export DEBUG_CFLAGS
42
43 KBUILD_RUSTFLAGS += $(DEBUG_RUSTFLAGS)
44 export DEBUG_RUSTFLAGS