diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-04-03 12:05:06 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2025-04-23 15:20:08 +0200 |
commit | e5201ee251d11675c8fcbd686056ff08bea118b5 (patch) | |
tree | 0819414de83e3bea653970e3e6546bc8502ce3d5 | |
parent | 3e0d1255cdf428fb4b7d2381fb82f8db0a0e8bf3 (diff) | |
download | rules-cc-e5201ee251d11675c8fcbd686056ff08bea118b5.tar.gz |
rules CC: Make DEBUG variable a map
It expects now the key 'USE_DEBUG_FISSION', which enables debug
fission, but does not add any flags on its own. For this, the
'FISSION_CONFIG' key is expected with certain entries that provide
the compile and/or link flags that configure debug fission.
The flags are added only where needed, i.e., before running or
storing the respective compile or link actions.
-rw-r--r-- | CC/EXPRESSIONS | 161 | ||||
-rw-r--r-- | CC/RULES | 52 |
2 files changed, 205 insertions, 8 deletions
diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 2911c34..572ba04 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -682,6 +682,141 @@ } } } +, "add-fission-compile-flags": + { "doc": ["Add debug fission flags, if enabled, to existing compile flags."] + , "vars": ["COMPILE_FLAGS", "DEBUG"] + , "expression": + { "type": "let*" + , "bindings": + [ [ "fission-config" + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + , "then": + { "type": "assert_non_empty" + , "msg": + [ "Debug fission requires non-empty debug map FISSION_CONFIG field" + ] + , "$1": + { "type": "lookup" + , "key": "FISSION_CONFIG" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + } + , "else": {"type": "empty_map"} + } + ] + , [ "flags" + , { "type": "++" + , "$1": + [ {"type": "var", "name": "COMPILE_FLAGS"} + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_SPLIT_DWARF" + , "map": {"type": "var", "name": "fission-config"} + } + , "then": ["-gsplit-dwarf"] + } + , { "type": "let*" + , "bindings": + [ [ "version" + , { "type": "lookup" + , "key": "DWARF_VERSION" + , "map": {"type": "var", "name": "fission-config"} + } + ] + ] + , "body": + { "type": "if" + , "cond": {"type": "var", "name": "version"} + , "then": + [ { "type": "join" + , "$1": ["-gdwarf-", {"type": "var", "name": "version"}] + } + ] + } + } + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_DEBUG_TYPES_SECTION" + , "map": {"type": "var", "name": "fission-config"} + } + , "then": ["-fdebug-types-section"] + } + ] + } + ] + ] + , "body": {"type": "var", "name": "flags"} + } + } +, "add-fission-link-flags": + { "doc": ["Add debug fission flags, if enabled, to existing link flags."] + , "vars": ["LDFLAGS", "DEBUG"] + , "expression": + { "type": "let*" + , "bindings": + [ [ "fission-config" + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + , "then": + { "type": "assert_non_empty" + , "msg": + [ "Debug fission requires non-empty debug map FISSION_CONFIG field" + ] + , "$1": + { "type": "lookup" + , "key": "FISSION_CONFIG" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + } + , "else": {"type": "empty_map"} + } + ] + , [ "flags" + , { "type": "++" + , "$1": + [ {"type": "var", "name": "LDFLAGS"} + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_GDB_INDEX" + , "map": {"type": "var", "name": "fission-config"} + } + , "then": ["-Wl,--gdb-index"] + } + ] + } + ] + ] + , "body": {"type": "var", "name": "flags"} + } + } , "objects": { "vars": [ "COMPILER" @@ -694,6 +829,7 @@ , "compile-deps" , "cflags-files" ] + , "imports": {"add-fission-compile-flags": "add-fission-compile-flags"} , "expression": { "type": "let*" , "bindings": @@ -721,6 +857,9 @@ ] } ] + , [ "compile flags" + , {"type": "CALL_EXPRESSION", "name": "add-fission-compile-flags"} + ] ] , "body": { "type": "map_union" @@ -782,7 +921,7 @@ { "type": "++" , "$1": [ [{"type": "var", "name": "COMPILER"}] - , {"type": "var", "name": "COMPILE_FLAGS"} + , {"type": "var", "name": "compile flags"} , ["-I", "work", "-isystem", "include"] , ["-c", {"type": "var", "name": "work src_name"}] , ["-o", {"type": "var", "name": "work out"}] @@ -839,6 +978,7 @@ , "default-NON_SYSTEM_TOOLS": "default-NON_SYSTEM_TOOLS" , "compiler": "compiler" , "flags": "flags" + , "add-fission-compile-flags": "add-fission-compile-flags" } , "expression": { "type": "let*" @@ -863,6 +1003,9 @@ ] } ] + , [ "compile flags" + , {"type": "CALL_EXPRESSION", "name": "add-fission-compile-flags"} + ] , [ "include tree" , { "type": "singleton_map" , "key": "include" @@ -959,7 +1102,7 @@ , { "type": "++" , "$1": [ [{"type": "var", "name": "COMPILER"}] - , {"type": "var", "name": "COMPILE_FLAGS"} + , {"type": "var", "name": "compile flags"} , [ "-I" , "work" , "-isystem" @@ -1029,7 +1172,7 @@ , { "type": "++" , "$1": [ [{"type": "var", "name": "COMPILER"}] - , {"type": "var", "name": "COMPILE_FLAGS"} + , {"type": "var", "name": "compile flags"} , ["-I", "work", "-isystem", "include"] , ["-c", {"type": "var", "name": "work src_name"}] , ["-o", {"type": "var", "name": "work out"}] @@ -1632,6 +1775,8 @@ , "default-LDFLAGS": "default-LDFLAGS" , "default-TOOLCHAIN": "default-TOOLCHAIN" , "default-NON_SYSTEM_TOOLS": "default-NON_SYSTEM_TOOLS" + , "add-fission-compile-flags": "add-fission-compile-flags" + , "add-fission-link-flags": "add-fission-link-flags" } , "expression": { "type": "let*" @@ -1697,6 +1842,12 @@ ] , ["hdrs", {"type": "empty_map"}] , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}] + , [ "compile flags" + , {"type": "CALL_EXPRESSION", "name": "add-fission-compile-flags"} + ] + , [ "ld flags" + , {"type": "CALL_EXPRESSION", "name": "add-fission-link-flags"} + ] , [ "link-args" , { "type": "nub_right" , "$1": @@ -1758,9 +1909,9 @@ , "-o" , {"type": "var", "name": "binpath"} ] - , {"type": "var", "name": "COMPILE_FLAGS"} + , {"type": "var", "name": "compile flags"} , {"type": "var", "name": "link-args"} - , {"type": "var", "name": "LDFLAGS"} + , {"type": "var", "name": "ld flags"} ] } ] @@ -104,7 +104,23 @@ , "HOST_ARCH": ["The architecture on which the build actions are carried out."] , "TARGET_ARCH": ["The architecture for which to build."] - , "DEBUG": ["Compute the debug-stage, needed for local debugging."] + , "DEBUG": + [ "Map configuring the debug-stage, needed for local debugging." + , "If non-empty, debug mode is enabled." + , "" + , "The key \"USE_DEBUG_FISSION\" expects a flag which enables the debug" + , "fission mode, but does not add any flags. Explicitly setting it to a" + , "false value is needed to enable regular debug mode." + , "The key \"FISSION_CONFIG\" expects a map configuring debug fission." + , " - subkey \"USE_SPLIT_DWARF\" expects a flag that, if true, adds the" + , "-gsplit-dwarf compile flag." + , " - subkey \"DWARF_VERSION\" expects a string that adds the" + , "-gdwarf-<value> compile flag." + , " - subkey \"USE_GDB_INDEX\" expects a flag that, if true, adds the" + , "-Wl,--gdb-index linker flag." + , " - subkey \"USE_DEBUG_TYPES_SECTION\" expects a flag that, if true," + , "adds the -fdebug-types-section compile flag." + ] } , "imports": { "base-provides": "defaults-base-provides" @@ -553,7 +569,22 @@ ] , "ENV": ["The environment for any action generated."] , "DEBUG": - [ "Compute the debug-stage, needed for local debugging." + [ "Map configuring the debug-stage, needed for local debugging." + , "If non-empty, debug mode is enabled." + , "" + , "The key \"USE_DEBUG_FISSION\" expects a flag which enables the debug" + , "fission mode, but does not add any flags. Explicitly setting it to a" + , "false value is needed to enable regular debug mode." + , "The key \"FISSION_CONFIG\" expects a map configuring debug fission." + , " - subkey \"USE_SPLIT_DWARF\" expects a flag that, if true, adds the" + , "-gsplit-dwarf compile flag." + , " - subkey \"DWARF_VERSION\" expects a string that adds the" + , "-gdwarf-<value> compile flag." + , " - subkey \"USE_GDB_INDEX\" expects a flag that, if true, adds the" + , "-Wl,--gdb-index linker flag." + , " - subkey \"USE_DEBUG_TYPES_SECTION\" expects a flag that, if true," + , "adds the -fdebug-types-section compile flag." + , "" , "If no compile flags are otherwise configured, [\"-g\"] will be taken." ] , "LINT": @@ -756,7 +787,22 @@ ] , "ENV": ["The environment for any action generated."] , "DEBUG": - [ "Compute the debug-stage, needed for local debugging." + [ "Map configuring the debug-stage, needed for local debugging." + , "If non-empty, debug mode is enabled." + , "" + , "The key \"USE_DEBUG_FISSION\" expects a flag which enables the debug" + , "fission mode, but does not add any flags. Explicitly setting it to a" + , "false value is needed to enable regular debug mode." + , "The key \"FISSION_CONFIG\" expects a map configuring debug fission." + , " - subkey \"USE_SPLIT_DWARF\" expects a flag that, if true, adds the" + , "-gsplit-dwarf compile flag." + , " - subkey \"DWARF_VERSION\" expects a string that adds the" + , "-gdwarf-<value> compile flag." + , " - subkey \"USE_GDB_INDEX\" expects a flag that, if true, adds the" + , "-Wl,--gdb-index linker flag." + , " - subkey \"USE_DEBUG_TYPES_SECTION\" expects a flag that, if true," + , "adds the -fdebug-types-section compile flag." + , "" , "If no compile flags are otherwise configured, [\"-g\"] will be taken." ] , "LINT": |