Skip to content

Commit

Permalink
compile: add DEBUG_SYMBOLS_LEVEL allow custom the level
Browse files Browse the repository at this point in the history
Signed-off-by: ligd <[email protected]>
  • Loading branch information
GUIDINGLI authored and anjiahao1 committed Sep 26, 2024
1 parent d4f61ac commit 7a70747
Show file tree
Hide file tree
Showing 32 changed files with 44 additions and 30 deletions.
7 changes: 7 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,13 @@ config DEBUG_SYMBOLS
---help---
Build with debug symbols (needed for use with a debugger).

config DEBUG_SYMBOLS_LEVEL
string "Custom symbols level"
default "-g"
---help---
This string represents the custom symbol level that will be
used if DEBUG_SYMBOLS.

config FRAME_POINTER
bool "Compile the NuttX with frame pointers"
default n
Expand Down
5 changes: 4 additions & 1 deletion arch/arm/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ if(CONFIG_DEBUG_LINK_MAP)
endif()

if(CONFIG_DEBUG_SYMBOLS)
add_compile_options(-g3)
add_compile_options(${CONFIG_DEBUG_SYMBOLS_LEVEL})
if(CONFIG_ARM_TOOLCHAIN_ARMCLANG)
add_link_options(-Wl,--debug)
endif()
endif()

add_compile_options(-Wno-attributes -Wno-unknown-pragmas
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
ifeq ($(CONFIG_ARM_TOOLCHAIN_ARMCLANG),y)
LDFLAGS += --debug
endif
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

CROSSDEV ?= aarch64-none-elf-
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ if(CONFIG_DEBUG_LINK_MAP)
endif()

if(CONFIG_DEBUG_SYMBOLS)
add_compile_options(-g3)
add_compile_options(${CONFIG_DEBUG_SYMBOLS_LEVEL})
endif()

if(CONFIG_ARCH_TOOLCHAIN_GNU)
Expand Down
2 changes: 1 addition & 1 deletion arch/avr/src/avr32/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y)
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifeq ($(CONFIG_FRAME_POINTER),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/ceva/src/xc5/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ else
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ARCHCFLAGS += -fno-common
Expand Down
2 changes: 1 addition & 1 deletion arch/ceva/src/xm6/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ else
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ARCHCFLAGS += -fno-common
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/src/mips32/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ARCHCFLAGS += -fno-common
Expand Down
2 changes: 1 addition & 1 deletion arch/misoc/src/lm32/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ endif
LDFLAGS += -nostdlib

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ARCHCFLAGS += -fno-common
Expand Down
2 changes: 1 addition & 1 deletion arch/misoc/src/minerva/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ endif
LDFLAGS += -nostdlib

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ARCHCFLAGS += -fno-common
Expand Down
2 changes: 1 addition & 1 deletion arch/or1k/src/mor1kx/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ endif
LDFLAGS += -nostdlib

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ARCHCFLAGS += -fno-common
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ if(CONFIG_DEBUG_LINK_MAP)
endif()

if(CONFIG_DEBUG_SYMBOLS)
add_compile_options(-g3)
add_compile_options(${CONFIG_DEBUG_SYMBOLS_LEVEL})
endif()

# Generic GNU RVG toolchain
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

# Generic GNU RVG toolchain
Expand Down
2 changes: 1 addition & 1 deletion arch/sim/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()
add_compile_options(-fno-common)

if(CONFIG_DEBUG_SYMBOLS)
add_compile_options(-g3)
add_compile_options(${CONFIG_DEBUG_SYMBOLS_LEVEL})
endif()

if(CONFIG_SIM_M32)
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/src/sparc_v8/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ else
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ARCHCFLAGS += -fno-common
Expand Down
4 changes: 4 additions & 0 deletions arch/tricore/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ endif()
if(NOT CONFIG_CXX_RTTI)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
endif()

if(CONFIG_DEBUG_SYMBOLS)
add_compile_options(${CONFIG_DEBUG_SYMBOLS_LEVEL})
endif()
2 changes: 1 addition & 1 deletion arch/x86_64/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if(CONFIG_ARCH_COVERAGE)
endif()

if(CONFIG_DEBUG_SYMBOLS)
add_compile_options(-g3)
add_compile_options(${CONFIG_DEBUG_SYMBOLS_LEVEL})
endif()

# Architecture flags
Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
############################################################################

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/lx6/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ ifeq ($(CONFIG_DEBUG_LINK_WHOLE_ARCHIVE),y)
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

# Default toolchain
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/lx7/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ ifeq ($(CONFIG_DEBUG_LINK_MAP),y)
endif

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

# Default toolchain
Expand Down
2 changes: 1 addition & 1 deletion arch/z80/src/ez80/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ifeq ($(CONFIG_EZ80_TOOLCHAIN_CLANG),y)

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHASMOPTIMIZATION =
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
else
ARCHASMOPTIMIZATION =
ARCHOPTIMIZATION =
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/sama5/jupiter-nano/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
# LDFLAGS += --nostartfiles -nodefaultlibs
#endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g3
LDFLAGS += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif
2 changes: 1 addition & 1 deletion boards/hc/m9s12/demo9s12ne64/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ endif
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)ostest$(DELIM)$(LDSCRIPT)

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion boards/hc/m9s12/ne64badge/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ endif
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion boards/renesas/m16c/skp16c26/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion boards/renesas/rx65n/rx65n/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion boards/renesas/sh1/us7032evb1/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g3
ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
2 changes: 1 addition & 1 deletion boards/sim/sim/sim/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ARCHDEFINES += -U__NetBSD__ -U__linux__ -U__sun__ -U__unix__
ARCHDEFINES += -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__

ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION += -g3
ARCHOPTIMIZATION += $(CONFIG_DEBUG_SYMBOLS_LEVEL)
endif

ifeq ($(CONFIG_DEBUG_CUSTOMOPT),y)
Expand Down

0 comments on commit 7a70747

Please sign in to comment.