Skip to content

Commit 6947fd9

Browse files
committed
kbuild: split DEBUG_CFLAGS out to scripts/Makefile.debug
To slim down the top Makefile, split out the code block surrounded by ifdef CONFIG_DEBUG_INFO ... endif. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Reviewed-by: Sedat Dilek <[email protected]>
1 parent 3510c5c commit 6947fd9

File tree

2 files changed

+34
-38
lines changed

2 files changed

+34
-38
lines changed

Makefile

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -847,44 +847,6 @@ ifdef CONFIG_ZERO_CALL_USED_REGS
847847
KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
848848
endif
849849

850-
DEBUG_CFLAGS :=
851-
852-
ifdef CONFIG_DEBUG_INFO
853-
854-
ifdef CONFIG_DEBUG_INFO_SPLIT
855-
DEBUG_CFLAGS += -gsplit-dwarf
856-
else
857-
DEBUG_CFLAGS += -g
858-
endif
859-
860-
ifndef CONFIG_AS_IS_LLVM
861-
KBUILD_AFLAGS += -Wa,-gdwarf-2
862-
endif
863-
864-
ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
865-
dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
866-
dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5
867-
DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y)
868-
endif
869-
870-
ifdef CONFIG_DEBUG_INFO_REDUCED
871-
DEBUG_CFLAGS += -fno-var-tracking
872-
ifdef CONFIG_CC_IS_GCC
873-
DEBUG_CFLAGS += -femit-struct-debug-baseonly
874-
endif
875-
endif
876-
877-
ifdef CONFIG_DEBUG_INFO_COMPRESSED
878-
DEBUG_CFLAGS += -gz=zlib
879-
KBUILD_AFLAGS += -gz=zlib
880-
KBUILD_LDFLAGS += --compress-debug-sections=zlib
881-
endif
882-
883-
endif # CONFIG_DEBUG_INFO
884-
885-
KBUILD_CFLAGS += $(DEBUG_CFLAGS)
886-
export DEBUG_CFLAGS
887-
888850
ifdef CONFIG_FUNCTION_TRACER
889851
ifdef CONFIG_FTRACE_MCOUNT_USE_CC
890852
CC_FLAGS_FTRACE += -mrecord-mcount
@@ -1033,6 +995,7 @@ KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
1033995

1034996
# include additional Makefiles when needed
1035997
include-y := scripts/Makefile.extrawarn
998+
include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
1036999
include-$(CONFIG_KASAN) += scripts/Makefile.kasan
10371000
include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
10381001
include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan

scripts/Makefile.debug

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
DEBUG_CFLAGS :=
2+
3+
ifdef CONFIG_DEBUG_INFO_SPLIT
4+
DEBUG_CFLAGS += -gsplit-dwarf
5+
else
6+
DEBUG_CFLAGS += -g
7+
endif
8+
9+
ifndef CONFIG_AS_IS_LLVM
10+
KBUILD_AFLAGS += -Wa,-gdwarf-2
11+
endif
12+
13+
ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
14+
dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
15+
dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5
16+
DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y)
17+
endif
18+
19+
ifdef CONFIG_DEBUG_INFO_REDUCED
20+
DEBUG_CFLAGS += -fno-var-tracking
21+
ifdef CONFIG_CC_IS_GCC
22+
DEBUG_CFLAGS += -femit-struct-debug-baseonly
23+
endif
24+
endif
25+
26+
ifdef CONFIG_DEBUG_INFO_COMPRESSED
27+
DEBUG_CFLAGS += -gz=zlib
28+
KBUILD_AFLAGS += -gz=zlib
29+
KBUILD_LDFLAGS += --compress-debug-sections=zlib
30+
endif
31+
32+
KBUILD_CFLAGS += $(DEBUG_CFLAGS)
33+
export DEBUG_CFLAGS

0 commit comments

Comments
 (0)