Makefile.debug 1.4 KB

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