162306a36Sopenharmony_ciDEBUG_CFLAGS	:=
262306a36Sopenharmony_ciDEBUG_RUSTFLAGS	:=
362306a36Sopenharmony_ci
462306a36Sopenharmony_cidebug-flags-y	:= -g
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciifdef CONFIG_DEBUG_INFO_SPLIT
762306a36Sopenharmony_ciDEBUG_CFLAGS	+= -gsplit-dwarf
862306a36Sopenharmony_ciendif
962306a36Sopenharmony_ci
1062306a36Sopenharmony_cidebug-flags-$(CONFIG_DEBUG_INFO_DWARF4)	+= -gdwarf-4
1162306a36Sopenharmony_cidebug-flags-$(CONFIG_DEBUG_INFO_DWARF5)	+= -gdwarf-5
1262306a36Sopenharmony_ciifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_AS_IS_GNU),yy)
1362306a36Sopenharmony_ci# Clang does not pass -g or -gdwarf-* option down to GAS.
1462306a36Sopenharmony_ci# Add -Wa, prefix to explicitly specify the flags.
1562306a36Sopenharmony_ciKBUILD_AFLAGS	+= $(addprefix -Wa$(comma), $(debug-flags-y))
1662306a36Sopenharmony_ciendif
1762306a36Sopenharmony_ciDEBUG_CFLAGS	+= $(debug-flags-y)
1862306a36Sopenharmony_ciKBUILD_AFLAGS	+= $(debug-flags-y)
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciifdef CONFIG_DEBUG_INFO_REDUCED
2162306a36Sopenharmony_ciDEBUG_CFLAGS	+= -fno-var-tracking
2262306a36Sopenharmony_ciDEBUG_RUSTFLAGS	+= -Cdebuginfo=1
2362306a36Sopenharmony_ciifdef CONFIG_CC_IS_GCC
2462306a36Sopenharmony_ciDEBUG_CFLAGS	+= -femit-struct-debug-baseonly
2562306a36Sopenharmony_ciendif
2662306a36Sopenharmony_cielse
2762306a36Sopenharmony_ciDEBUG_RUSTFLAGS	+= -Cdebuginfo=2
2862306a36Sopenharmony_ciendif
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciifdef CONFIG_DEBUG_INFO_COMPRESSED_ZLIB
3162306a36Sopenharmony_ciDEBUG_CFLAGS	+= -gz=zlib
3262306a36Sopenharmony_ciKBUILD_AFLAGS	+= -gz=zlib
3362306a36Sopenharmony_ciKBUILD_LDFLAGS	+= --compress-debug-sections=zlib
3462306a36Sopenharmony_cielse ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZSTD
3562306a36Sopenharmony_ciDEBUG_CFLAGS	+= -gz=zstd
3662306a36Sopenharmony_ciKBUILD_AFLAGS	+= -gz=zstd
3762306a36Sopenharmony_ciKBUILD_LDFLAGS	+= --compress-debug-sections=zstd
3862306a36Sopenharmony_ciendif
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciKBUILD_CFLAGS	+= $(DEBUG_CFLAGS)
4162306a36Sopenharmony_ciexport DEBUG_CFLAGS
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciKBUILD_RUSTFLAGS += $(DEBUG_RUSTFLAGS)
4462306a36Sopenharmony_ciexport DEBUG_RUSTFLAGS
45