From a0cb31ec1315b63f6143915ad0fcee797fa2aeca Mon Sep 17 00:00:00 2001 From: Johannes Kliemann Date: Tue, 5 Dec 2023 14:03:00 +0000 Subject: [PATCH 1/3] Rename target_options.gpr to target_options.gpr.in The template files for runtime_build.gpr and ravenscar_build.gpr have a .in suffix. The template file for target_options.gpr did not have this suffix allowing someone to be mislead into assuming it is not a template file. ref eng/cert/certified-rts#18 --- support/bsp_sources/installer.py | 2 +- support/data/{target_options.gpr => target_options.gpr.in} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename support/data/{target_options.gpr => target_options.gpr.in} (100%) diff --git a/support/bsp_sources/installer.py b/support/bsp_sources/installer.py index 82a5e3dc..616b3c7e 100644 --- a/support/bsp_sources/installer.py +++ b/support/bsp_sources/installer.py @@ -271,7 +271,7 @@ def install(self, destination, rts_descriptor=None): 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')) + cnt = readfile(getdatafilepath('target_options.gpr.in')) build_flags["gnat_version"] = runtime_sources.version # Format cnt = cnt.format(**build_flags) diff --git a/support/data/target_options.gpr b/support/data/target_options.gpr.in similarity index 100% rename from support/data/target_options.gpr rename to support/data/target_options.gpr.in From 8bde8d9453ab52ec505fd67e2cbb3b5854b9404c Mon Sep 17 00:00:00 2001 From: Johannes Kliemann Date: Tue, 5 Dec 2023 16:24:59 +0000 Subject: [PATCH 2/3] Remove redundancy in setting the build flags for target_options.gpr The procedure to set build options in target_options required the build flag keys to be present in two different places yet they needed to be synchronised. To fix that a policy for build flag names is added and the second set of keys is generated from that policy. ref eng/cert/certified-rts#18 --- support/bsp_sources/installer.py | 8 ++++---- support/bsp_sources/target.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/support/bsp_sources/installer.py b/support/bsp_sources/installer.py index 616b3c7e..10cc492d 100644 --- a/support/bsp_sources/installer.py +++ b/support/bsp_sources/installer.py @@ -267,10 +267,10 @@ 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]) + 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 diff --git a/support/bsp_sources/target.py b/support/bsp_sources/target.py index b79423be..8dc3ba19 100644 --- a/support/bsp_sources/target.py +++ b/support/bsp_sources/target.py @@ -162,6 +162,8 @@ 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'], From d7ddcc0f264445e0b4fab7d522af21a543c28671 Mon Sep 17 00:00:00 2001 From: Johannes Kliemann Date: Tue, 5 Dec 2023 16:34:10 +0000 Subject: [PATCH 3/3] Add option to modify debug flags Some bare metal runtimes require custom debug flags. To fulfil that requirement the debug flags are now configurable via common_debug_flags analogous to common_flags. ref eng/cert/certified-rts#18 --- support/bsp_sources/target.py | 1 + support/data/target_options.gpr.in | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/support/bsp_sources/target.py b/support/bsp_sources/target.py index 8dc3ba19..97bdf43e 100644 --- a/support/bsp_sources/target.py +++ b/support/bsp_sources/target.py @@ -168,6 +168,7 @@ def __init__(self): '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.in b/support/data/target_options.gpr.in index e99d4d0b..a83c6405 100644 --- a/support/data/target_options.gpr.in +++ 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 := ();