Nick Desaulniers | 32ef9e5 | 2022-09-19 10:45:47 -0700 | [diff] [blame] | 1 | DEBUG_CFLAGS := |
Miguel Ojeda | 2f7ab12 | 2021-07-03 16:42:57 +0200 | [diff] [blame] | 2 | DEBUG_RUSTFLAGS := |
| 3 | |
Nick Desaulniers | 32ef9e5 | 2022-09-19 10:45:47 -0700 | [diff] [blame] | 4 | debug-flags-y := -g |
Masahiro Yamada | 6947fd9 | 2021-10-12 12:25:03 +0900 | [diff] [blame] | 5 | |
| 6 | ifdef CONFIG_DEBUG_INFO_SPLIT |
| 7 | DEBUG_CFLAGS += -gsplit-dwarf |
Masahiro Yamada | 6947fd9 | 2021-10-12 12:25:03 +0900 | [diff] [blame] | 8 | endif |
| 9 | |
Nick Desaulniers | 32ef9e5 | 2022-09-19 10:45:47 -0700 | [diff] [blame] | 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)) |
Masahiro Yamada | 6947fd9 | 2021-10-12 12:25:03 +0900 | [diff] [blame] | 16 | endif |
Nick Desaulniers | 32ef9e5 | 2022-09-19 10:45:47 -0700 | [diff] [blame] | 17 | DEBUG_CFLAGS += $(debug-flags-y) |
| 18 | KBUILD_AFLAGS += $(debug-flags-y) |
Masahiro Yamada | 6947fd9 | 2021-10-12 12:25:03 +0900 | [diff] [blame] | 19 | |
| 20 | ifdef CONFIG_DEBUG_INFO_REDUCED |
| 21 | DEBUG_CFLAGS += -fno-var-tracking |
Miguel Ojeda | 2f7ab12 | 2021-07-03 16:42:57 +0200 | [diff] [blame] | 22 | DEBUG_RUSTFLAGS += -Cdebuginfo=1 |
Masahiro Yamada | 6947fd9 | 2021-10-12 12:25:03 +0900 | [diff] [blame] | 23 | ifdef CONFIG_CC_IS_GCC |
| 24 | DEBUG_CFLAGS += -femit-struct-debug-baseonly |
| 25 | endif |
Miguel Ojeda | 2f7ab12 | 2021-07-03 16:42:57 +0200 | [diff] [blame] | 26 | else |
| 27 | DEBUG_RUSTFLAGS += -Cdebuginfo=2 |
Masahiro Yamada | 6947fd9 | 2021-10-12 12:25:03 +0900 | [diff] [blame] | 28 | endif |
| 29 | |
| 30 | ifdef CONFIG_DEBUG_INFO_COMPRESSED |
| 31 | DEBUG_CFLAGS += -gz=zlib |
| 32 | KBUILD_AFLAGS += -gz=zlib |
| 33 | KBUILD_LDFLAGS += --compress-debug-sections=zlib |
| 34 | endif |
| 35 | |
Nick Desaulniers | 32ef9e5 | 2022-09-19 10:45:47 -0700 | [diff] [blame] | 36 | KBUILD_CFLAGS += $(DEBUG_CFLAGS) |
Masahiro Yamada | 6947fd9 | 2021-10-12 12:25:03 +0900 | [diff] [blame] | 37 | export DEBUG_CFLAGS |
Miguel Ojeda | 2f7ab12 | 2021-07-03 16:42:57 +0200 | [diff] [blame] | 38 | |
| 39 | KBUILD_RUSTFLAGS += $(DEBUG_RUSTFLAGS) |
| 40 | export DEBUG_RUSTFLAGS |