diff --git a/support/bsp_sources/installer.py b/support/bsp_sources/installer.py index 82a5e3dc..10cc492d 100644 --- a/support/bsp_sources/installer.py +++ b/support/bsp_sources/installer.py @@ -267,11 +267,11 @@ def install(self, destination, rts_descriptor=None): # And generate the project files used to build the rts - build_flags = {} - for f in ['common_flags', 'common_gnarl_flags', - 'asm_flags', 'c_flags']: - build_flags[f] = '",\n "'.join(rts_obj.build_flags[f]) - cnt = readfile(getdatafilepath('target_options.gpr')) + build_flags = { + f: '",\n "'.join(rts_obj.build_flags[f]) + for f in rts_obj.build_flags if f.endswith('_flags') + } + cnt = readfile(getdatafilepath('target_options.gpr.in')) build_flags["gnat_version"] = runtime_sources.version # Format cnt = cnt.format(**build_flags) diff --git a/support/bsp_sources/target.py b/support/bsp_sources/target.py index b79423be..97bdf43e 100644 --- a/support/bsp_sources/target.py +++ b/support/bsp_sources/target.py @@ -162,10 +162,13 @@ def __init__(self): self.rts_options = RTSProfiles(self) + # Flags for keys in target_options.gpr.in must end in _flags. This is + # to avoid duplicating the list of flags in support/bsp_sources/installer.py. self.build_flags = {'source_dirs': None, 'common_flags': ['-ffunction-sections', '-fdata-sections'], 'common_gnarl_flags': [], + 'common_debug_flags': ['-g'], 'asm_flags': [], 'c_flags': ['-DIN_RTS', '-Dinhibit_libc', '-DLIGHT_RUNTIME']} # GNAT-LLVM doesn't support -fcallgraph-info diff --git a/support/data/target_options.gpr b/support/data/target_options.gpr.in similarity index 89% rename from support/data/target_options.gpr rename to support/data/target_options.gpr.in index e99d4d0b..a83c6405 100644 --- a/support/data/target_options.gpr +++ b/support/data/target_options.gpr.in @@ -16,6 +16,7 @@ abstract project Target_Options is -- COMFLAGS here is common flags (used for C and Ada). COMFLAGS := ("{common_flags}"); COMGNARLFLAGS := ("{common_gnarl_flags}"); + COMDEBUGFLAGS := ("{common_debug_flags}"); -- Per language flags (COMFLAGS will be added later) ADAFLAGS := ("-gnatg", "-nostdinc", "-fno-delete-null-pointer-checks"); @@ -28,8 +29,8 @@ abstract project Target_Options is ADAFLAGS := ADAFLAGS & ("-gnatp", "-gnatn2"); when "Debug" => -- Disable optimization and add debug symbols - COMFLAGS := COMFLAGS & ("-O0", "-g"); - ASMFLAGS := ASMFLAGS & ("-g"); + COMFLAGS := COMFLAGS & COMDEBUGFLAGS & ("-O0"); + ASMFLAGS := ASMFLAGS & COMDEBUGFLAGS; when "Assert" => -- Possibly enable assertions. This might use too much memory on -- some systems or could be too slow. @@ -37,8 +38,8 @@ abstract project Target_Options is ADAFLAGS := ADAFLAGS & ("-gnata"); when "Gnatcov" => -- For coverage - COMFLAGS := COMFLAGS & ("-O0", "-g", "-fdump-scos", - "-fpreserve-control-flow"); + COMFLAGS := COMFLAGS & COMDEBUGFLAGS & + ("-O0", "-fdump-scos", "-fpreserve-control-flow"); end case; -- Linker flags, used for building shared libraries LOPTIONS := ();