AP_HAL_ChibiOS: do not build ChibiOS with debug symbols unless debug build

debug symbols subtly change the compiler output which can lead to problems with repeatable builds
This commit is contained in:
Peter Barker 2023-05-10 16:07:13 +10:00 committed by Andrew Tridgell
parent b19035b9a7
commit 537fc19bb5
4 changed files with 11 additions and 3 deletions

View File

@ -275,7 +275,7 @@ class Board:
env.DEFINES.update( env.DEFINES.update(
HAL_DEBUG_BUILD = 1, HAL_DEBUG_BUILD = 1,
) )
elif cfg.options.g: elif cfg.options.debug_symbols:
env.CFLAGS += [ env.CFLAGS += [
'-g', '-g',
] ]

View File

@ -494,6 +494,8 @@ def load_env_vars(env):
else: else:
env[k] = v env[k] = v
print("env set %s=%s" % (k, v)) print("env set %s=%s" % (k, v))
if env.DEBUG or env.DEBUG_SYMBOLS:
env.CHIBIOS_BUILD_FLAGS += ' ENABLE_DEBUG_SYMBOLS=yes'
if env.ENABLE_ASSERTS: if env.ENABLE_ASSERTS:
env.CHIBIOS_BUILD_FLAGS += ' ENABLE_ASSERTS=yes' env.CHIBIOS_BUILD_FLAGS += ' ENABLE_ASSERTS=yes'
if env.ENABLE_MALLOC_GUARD: if env.ENABLE_MALLOC_GUARD:

View File

@ -5,7 +5,11 @@
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
USE_OPT = -g -fomit-frame-pointer -falign-functions=16 USE_OPT = -fomit-frame-pointer -falign-functions=16
endif
ifeq ($(ENABLE_DEBUG_SYMBOLS), yes)
USE_OPT += -g
endif endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).

View File

@ -126,7 +126,7 @@ def options(opt):
default=False, default=False,
help='Configure as debug variant.') help='Configure as debug variant.')
g.add_option('-g', g.add_option('--debug-symbols', '-g',
action='store_true', action='store_true',
default=False, default=False,
help='Add debug symbolds to build.') help='Add debug symbolds to build.')
@ -432,6 +432,7 @@ def configure(cfg):
cfg.env.BOARD = cfg.options.board cfg.env.BOARD = cfg.options.board
cfg.env.DEBUG = cfg.options.debug cfg.env.DEBUG = cfg.options.debug
cfg.env.DEBUG_SYMBOLS = cfg.options.debug_symbols
cfg.env.COVERAGE = cfg.options.coverage cfg.env.COVERAGE = cfg.options.coverage
cfg.env.AUTOCONFIG = cfg.options.autoconfig cfg.env.AUTOCONFIG = cfg.options.autoconfig
@ -444,6 +445,7 @@ def configure(cfg):
cfg.env.BOARD = cfg.options.board cfg.env.BOARD = cfg.options.board
cfg.env.DEBUG = cfg.options.debug cfg.env.DEBUG = cfg.options.debug
cfg.env.DEBUG_SYMBOLS = cfg.options.debug_symbols
cfg.env.COVERAGE = cfg.options.coverage cfg.env.COVERAGE = cfg.options.coverage
cfg.env.FORCE32BIT = cfg.options.force_32bit cfg.env.FORCE32BIT = cfg.options.force_32bit
cfg.env.ENABLE_ASSERTS = cfg.options.enable_asserts cfg.env.ENABLE_ASSERTS = cfg.options.enable_asserts