From a761fdbbc19a52d552fca8bd9a6db73295aec8b8 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 25 Mar 2025 10:34:59 +0100 Subject: expressions CC: Remove unused import --- CC/EXPRESSIONS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'CC') diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 26a61ee..c52b209 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -832,8 +832,7 @@ , "defaults-transition" ] , "imports": - { "objects": "objects" - , "list_provider": ["./", "..", "field_list_provider"] + { "list_provider": ["./", "..", "field_list_provider"] , "runfiles_list": ["./", "..", "field_runfiles_list"] , "default-TOOLCHAIN": "default-TOOLCHAIN" , "default-NON_SYSTEM_TOOLS": "default-NON_SYSTEM_TOOLS" -- cgit v1.2.3 From 5b7031c42ad40d462f1652e4565efcca434a5f61 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 20 Mar 2025 13:05:28 +0100 Subject: rules CC defaults: Add DEBUGFLAGS and ADD_DEBUGFLAGS config vars If in debug mode - DEBUGFLAGS replaces any resulting CFLAGS and CXXFLAGS, and - ADD_DEBUGFLAGS is appended to the resulting debug compile flags. --- CC/RULES | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'CC') diff --git a/CC/RULES b/CC/RULES index 0f1b0ff..eddf0b7 100644 --- a/CC/RULES +++ b/CC/RULES @@ -14,10 +14,12 @@ , "CXXFLAGS" , "LDFLAGS" , "ARFLAGS" + , "DEBUGFLAGS" , "ADD_COMPILE_FLAGS" , "ADD_CFLAGS" , "ADD_CXXFLAGS" , "ADD_LDFLAGS" + , "ADD_DEBUGFLAGS" , "AR" , "PATH" , "SYSTEM_TOOLS" @@ -63,6 +65,11 @@ , "object files. If the \"ARFLAGS\" specified in the defaults target are" , "empty, the rules will use [\"cqs\"]." ] + , "DEBUGFLAGS": + [ "Flags to be used for the debug-stage for both C and C++, instead of" + , "the resulting CFLAGS and CXXFLAGS, respectively." + , "Specifying this field overwrites values from \"base\"." + ] , "ADD_COMPILE_FLAGS": [ "Additional compilation flags for C and C++. Specifying this field" , "extends values from \"base\" for both, \"CFLAGS\" and \"CXXFLAGS\"." @@ -79,6 +86,11 @@ [ "Additional linker flags for linking the final CC library. Specifying" , "this field extends values from \"base\"." ] + , "ADD_DEBUGFLAGS": + [ "Additional compilation flags for the debug-stage. Specifying this" + , "field extends values from \"base\" for both, \"CFLAGS\" and" + , "\"CXXFLAGS\"." + ] , "PATH": [ "Path for looking up the compilers. Individual paths are joined" , "with \":\". Specifying this field extends values from \"base\"." @@ -119,6 +131,7 @@ , ["CXXFLAGS", {"type": "FIELD", "name": "CXXFLAGS"}] , ["LDFLAGS", {"type": "FIELD", "name": "LDFLAGS"}] , ["ARFLAGS", {"type": "FIELD", "name": "ARFLAGS"}] + , ["DEBUGFLAGS", {"type": "FIELD", "name": "DEBUGFLAGS"}] , ["AR", {"type": "FIELD", "name": "AR"}] , ["PATH", {"type": "FIELD", "name": "PATH"}] , ["provider", "CC"] @@ -169,6 +182,14 @@ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} } ] + , ["provider", "DEBUGFLAGS"] + , [ "DEBUGFLAGS" + , { "type": "if" + , "cond": {"type": "var", "name": "DEBUGFLAGS"} + , "then": {"type": "var", "name": "DEBUGFLAGS"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"} + } + ] , ["provider", "AR"] , [ "AR" , { "type": "if" @@ -308,6 +329,40 @@ ] } ] + , [ "CFLAGS" + , { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": + { "type": "++" + , "$1": + [ { "type": "if" + , "cond": {"type": "var", "name": "DEBUGFLAGS"} + , "then": {"type": "var", "name": "DEBUGFLAGS"} + , "else": {"type": "var", "name": "CFLAGS"} + } + , {"type": "FIELD", "name": "ADD_DEBUGFLAGS"} + ] + } + , "else": {"type": "var", "name": "CFLAGS"} + } + ] + , [ "CXXFLAGS" + , { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": + { "type": "++" + , "$1": + [ { "type": "if" + , "cond": {"type": "var", "name": "DEBUGFLAGS"} + , "then": {"type": "var", "name": "DEBUGFLAGS"} + , "else": {"type": "var", "name": "CXXFLAGS"} + } + , {"type": "FIELD", "name": "ADD_DEBUGFLAGS"} + ] + } + , "else": {"type": "var", "name": "CXXFLAGS"} + } + ] , ["deps-fieldnames", ["base", "deps"]] , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}] , [ "compile-args" -- cgit v1.2.3 From 3e0d1255cdf428fb4b7d2381fb82f8db0a0e8bf3 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 20 Mar 2025 14:58:17 +0100 Subject: rules CC: Use the -g flag as fallback in debug mode... ...if no flags are otherwise configured (by toolchain or rule-specific configuration variables). --- CC/EXPRESSIONS | 28 ++++++++++++++++++++++++---- CC/RULES | 10 ++++++++-- 2 files changed, 32 insertions(+), 6 deletions(-) (limited to 'CC') diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index c52b209..2911c34 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -819,6 +819,7 @@ , "CXXFLAGS" , "ADD_CFLAGS" , "ADD_CXXFLAGS" + , "DEBUG" , "pure C" , "srcs" , "hdrs" @@ -1189,15 +1190,32 @@ , "CXXFLAGS" , "ADD_CFLAGS" , "ADD_CXXFLAGS" + , "DEBUG" , "pure C" , "defaults-transition" ] , "imports": {"flags-cc": "flags-cc", "flags-cxx": "flags-cxx"} , "expression": - { "type": "if" - , "cond": {"type": "var", "name": "pure C"} - , "then": {"type": "CALL_EXPRESSION", "name": "flags-cc"} - , "else": {"type": "CALL_EXPRESSION", "name": "flags-cxx"} + { "type": "let*" + , "bindings": + [ [ "flags" + , { "type": "if" + , "cond": {"type": "var", "name": "pure C"} + , "then": {"type": "CALL_EXPRESSION", "name": "flags-cc"} + , "else": {"type": "CALL_EXPRESSION", "name": "flags-cxx"} + } + ] + ] + , "body": + { "type": "if" + , "cond": {"type": "var", "name": "flags"} + , "then": {"type": "var", "name": "flags"} + , "else": + { "type": "if" + , "cond": {"type": "var", "name": "DEBUG"} + , "then": ["-g"] + } + } } } , "lib artifact": @@ -1210,6 +1228,7 @@ , "ADD_CXXFLAGS" , "AR" , "ENV" + , "DEBUG" , "name" , "pure C" , "srcs" @@ -1590,6 +1609,7 @@ , "ADD_CFLAGS" , "ADD_CXXFLAGS" , "ENV" + , "DEBUG" , "name" , "pure C" , "srcs" diff --git a/CC/RULES b/CC/RULES index eddf0b7..c618467 100644 --- a/CC/RULES +++ b/CC/RULES @@ -552,7 +552,10 @@ , "If None, the respective value from [\"CC\", \"defaults\"] will be taken." ] , "ENV": ["The environment for any action generated."] - , "DEBUG": ["Compute the debug-stage, needed for local debugging."] + , "DEBUG": + [ "Compute the debug-stage, needed for local debugging." + , "If no compile flags are otherwise configured, [\"-g\"] will be taken." + ] , "LINT": [ "Also provide nodes describing compile actions and header files;" , "those can be used by lint rules (doing also the config transition)" @@ -752,7 +755,10 @@ , "taken from the [\"CC\", \"defaults\"] target" ] , "ENV": ["The environment for any action generated."] - , "DEBUG": ["Compute the debug-stage, needed for local debugging."] + , "DEBUG": + [ "Compute the debug-stage, needed for local debugging." + , "If no compile flags are otherwise configured, [\"-g\"] will be taken." + ] , "LINT": [ "Also provide nodes describing compile actions and header files;" , "those can be used by lint rules (doing also the config transition)" -- cgit v1.2.3 From e5201ee251d11675c8fcbd686056ff08bea118b5 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 3 Apr 2025 12:05:06 +0200 Subject: 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. --- CC/EXPRESSIONS | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- CC/RULES | 52 +++++++++++++++++-- 2 files changed, 205 insertions(+), 8 deletions(-) (limited to 'CC') 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"} ] } ] diff --git a/CC/RULES b/CC/RULES index c618467..61834f9 100644 --- a/CC/RULES +++ b/CC/RULES @@ -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- 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- 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- 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": -- cgit v1.2.3 From 305c7e95a1d3f06a5387b176a8c83e6df0566530 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 25 Mar 2025 13:51:31 +0100 Subject: rules CC proto: Update docstring for DEBUG variable ...to reflect the value change from boolean to map. Behavior of the proto rules remains the same, as only the truth value of the variable is currently being taken into account. --- CC/proto/RULES | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'CC') diff --git a/CC/proto/RULES b/CC/proto/RULES index 07b2dad..dc9d66c 100644 --- a/CC/proto/RULES +++ b/CC/proto/RULES @@ -76,7 +76,23 @@ ] , "HOST_ARCH": ["The architecture on which the build actions are carried out."] - , "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 debug" + , "fission, 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- 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"] -- cgit v1.2.3 From 3af43b1bbeaa83f946621ee075a060033b0880ad Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 25 Mar 2025 12:44:35 +0100 Subject: rules CC: Support debug fission in objects For this purpose, the DEBUG configuration variable is updated to expect a map with at least the USE_DEBUG_FISSION flag field. If set, compilation of source files is expected to produce besides the regular object file also a DWARF file. --- CC/EXPRESSIONS | 270 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 192 insertions(+), 78 deletions(-) (limited to 'CC') diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 572ba04..202496e 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -822,6 +822,7 @@ [ "COMPILER" , "COMPILE_FLAGS" , "ENV" + , "DEBUG" , "TOOLCHAIN" , "srcs" , "hdrs" @@ -860,93 +861,196 @@ , [ "compile flags" , {"type": "CALL_EXPRESSION", "name": "add-fission-compile-flags"} ] - ] - , "body": - { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "var_key": "src_name" - , "var_val": "src_val" - , "range": {"type": "var", "name": "srcs"} - , "body": - { "type": "let*" - , "bindings": - [ [ "work src_name" - , { "type": "join" - , "separator": "/" - , "$1": ["work", {"type": "var", "name": "src_name"}] - } - ] - , [ "inputs" - , { "type": "map_union" - , "$1": - [ {"type": "var", "name": "all hdrs"} - , { "type": "singleton_map" - , "key": {"type": "var", "name": "work src_name"} - , "value": {"type": "var", "name": "src_val"} + , [ "all staged output artifacts" + , { "type": "foreach_map" + , "var_key": "src_name" + , "var_val": "src_val" + , "range": {"type": "var", "name": "srcs"} + , "body": + { "type": "let*" + , "bindings": + [ [ "work src_name" + , { "type": "join" + , "separator": "/" + , "$1": ["work", {"type": "var", "name": "src_name"}] + } + ] + , [ "inputs" + , { "type": "map_union" + , "$1": + [ {"type": "var", "name": "all hdrs"} + , { "type": "singleton_map" + , "key": {"type": "var", "name": "work src_name"} + , "value": {"type": "var", "name": "src_val"} + } + , { "type": "var" + , "name": "cflags-files" + , "default": {"type": "empty_map"} + } + , { "type": "var" + , "name": "TOOLCHAIN" + , "default": {"type": "empty_map"} + } + ] + } + ] + , [ "out" + , { "type": "change_ending" + , "$1": {"type": "var", "name": "src_name"} + , "ending": ".o" + } + ] + , [ "work out" + , { "type": "join" + , "separator": "/" + , "$1": ["work", {"type": "var", "name": "out"}] + } + ] + , [ "dwarf out" + , { "type": "change_ending" + , "$1": {"type": "var", "name": "src_name"} + , "ending": ".dwo" + } + ] + , [ "work dwarf out" + , { "type": "join" + , "separator": "/" + , "$1": ["work", {"type": "var", "name": "dwarf out"}] + } + ] + , [ "action output" + , { "type": "ACTION" + , "outs": + { "type": "++" + , "$1": + [ { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + , "then": [{"type": "var", "name": "work dwarf out"}] + , "else": [] + } + , [{"type": "var", "name": "work out"}] + ] } - , { "type": "var" - , "name": "cflags-files" + , "inputs": {"type": "var", "name": "inputs"} + , "env": + { "type": "var" + , "name": "ENV" , "default": {"type": "empty_map"} } - , { "type": "var" - , "name": "TOOLCHAIN" - , "default": {"type": "empty_map"} + , "cmd": + { "type": "++" + , "$1": + [ [{"type": "var", "name": "COMPILER"}] + , {"type": "var", "name": "compile flags"} + , ["-I", "work", "-isystem", "include"] + , ["-c", {"type": "var", "name": "work src_name"}] + , ["-o", {"type": "var", "name": "work out"}] + ] } - ] - } - ] - , [ "out" - , { "type": "change_ending" - , "$1": {"type": "var", "name": "src_name"} - , "ending": ".o" - } - ] - , [ "work out" - , { "type": "join" - , "separator": "/" - , "$1": ["work", {"type": "var", "name": "out"}] - } - ] - , [ "action output" - , { "type": "ACTION" - , "outs": [{"type": "var", "name": "work out"}] - , "inputs": {"type": "var", "name": "inputs"} - , "env": - { "type": "var" - , "name": "ENV" - , "default": {"type": "empty_map"} } - , "cmd": - { "type": "++" + ] + , [ "staged output artifacts" + , { "type": "++" , "$1": - [ [{"type": "var", "name": "COMPILER"}] - , {"type": "var", "name": "compile flags"} - , ["-I", "work", "-isystem", "include"] - , ["-c", {"type": "var", "name": "work src_name"}] - , ["-o", {"type": "var", "name": "work out"}] + [ [ { "type": "singleton_map" + , "key": {"type": "var", "name": "out"} + , "value": + { "type": "lookup" + , "key": {"type": "var", "name": "work out"} + , "map": {"type": "var", "name": "action output"} + } + } + ] + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + , "else": [] + , "then": + [ { "type": "singleton_map" + , "key": {"type": "var", "name": "dwarf out"} + , "value": + { "type": "lookup" + , "key": {"type": "var", "name": "work dwarf out"} + , "map": {"type": "var", "name": "action output"} + } + } + ] + } ] } - } + ] ] - , [ "staged output artifact" - , { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "range": {"type": "var", "name": "action output"} - , "var_val": "object" - , "body": - { "type": "singleton_map" - , "key": {"type": "var", "name": "out"} - , "value": {"type": "var", "name": "object"} - } - } + , "body": {"type": "var", "name": "staged output artifacts"} + } + } + ] + , [ "staged objects" + , { "type": "map_union" + , "$1": + { "type": "foreach" + , "range": {"type": "var", "name": "all staged output artifacts"} + , "body": + { "type": "[]" + , "index": "0" + , "list": {"type": "var", "name": "_"} + } + } + } + ] + , [ "staged dwarf objects" + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + , "else": {"type": "empty_map"} + , "then": + { "type": "map_union" + , "$1": + { "type": "foreach" + , "range": {"type": "var", "name": "all staged output artifacts"} + , "body": + { "type": "[]" + , "index": "1" + , "list": {"type": "var", "name": "_"} } - ] - ] - , "body": {"type": "var", "name": "staged output artifact"} + } + } } - } + ] + ] + , "body": + { "type": "map_union" + , "$1": + [ { "type": "singleton_map" + , "key": "objects" + , "value": {"type": "var", "name": "staged objects"} + } + , { "type": "singleton_map" + , "key": "dwarf objects" + , "value": {"type": "var", "name": "staged dwarf objects"} + } + ] } } } @@ -1479,7 +1583,12 @@ ] } ] - , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}] + , [ "objects" + , { "type": "lookup" + , "key": "objects" + , "map": {"type": "CALL_EXPRESSION", "name": "objects"} + } + ] , [ "base name" , { "type": "if" , "cond": {"type": "var", "name": "objects"} @@ -1841,7 +1950,12 @@ } ] , ["hdrs", {"type": "empty_map"}] - , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}] + , [ "objects" + , { "type": "lookup" + , "key": "objects" + , "map": {"type": "CALL_EXPRESSION", "name": "objects"} + } + ] , [ "compile flags" , {"type": "CALL_EXPRESSION", "name": "add-fission-compile-flags"} ] -- cgit v1.2.3 From 293488e5c0fb4416e7ac0f60e3bf6348334dda82 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 7 Apr 2025 12:24:57 +0200 Subject: rules CC: Support debug fission in linting As the command passed to the linter can produce additional outputs if debug fission is enabled, pass those artifact paths in a new variable "extra outs", which the ["lint", "targets"] rule can then make it available in the meta.json file expected by the linter. --- CC/EXPRESSIONS | 38 ++++++++++++++++++++++++++++++++++++-- lint/RULES | 14 ++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) (limited to 'CC') diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 202496e..03c9c07 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -1217,10 +1217,12 @@ ] } ] + , ["extra outs", []] ] , "body": { "type": "env" - , "vars": ["cmd", "src", "direct deps artifact names"] + , "vars": + ["cmd", "src", "direct deps artifact names", "extra outs"] } } } @@ -1272,6 +1274,33 @@ , "$1": ["work", {"type": "var", "name": "out"}] } ] + , [ "dwarf out" + , { "type": "change_ending" + , "$1": {"type": "var", "name": "src_name"} + , "ending": ".dwo" + } + ] + , [ "work dwarf out" + , { "type": "join" + , "separator": "/" + , "$1": ["work", {"type": "var", "name": "dwarf out"}] + } + ] + , [ "extra outs" + , { "type": "if" + , "cond": + { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + , "then": [{"type": "var", "name": "work dwarf out"}] + , "else": [] + } + ] , [ "cmd" , { "type": "++" , "$1": @@ -1295,7 +1324,12 @@ [["src", {"type": "var", "name": "work src_name"}]] , "body": { "type": "env" - , "vars": ["cmd", "src", "direct deps artifact names"] + , "vars": + [ "cmd" + , "src" + , "direct deps artifact names" + , "extra outs" + ] } } } diff --git a/lint/RULES b/lint/RULES index 6bdfba7..684ec2f 100644 --- a/lint/RULES +++ b/lint/RULES @@ -58,10 +58,13 @@ , " by the field \"config\", and" , "- OUT pointing to a directory to which files with the lint result" , " can be written." - , "- META pointing to a json file contaning" + , "- META pointing to a json file containing" , " - at key \"direct deps artifact names\" a list of all input" , " artifacts that come from the target itself or are runfiles of a" , " direct dependency." + , " - at key \"extra outs\" a list of extra output artifacts that the" + , " command might produce, such as DWARF objects if debug fission is" + , " enabled." , "- TMPDIR pointing to a directory location that can be used to" , " create additional temporary files." , "It is supposed to indicate by the exit code whether the file to lint" @@ -163,6 +166,12 @@ , "provider": "direct deps artifact names" } ] + , [ "extra outs" + , { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "_"} + , "provider": "extra outs" + } + ] ] , "body": { "type": "TREE" @@ -189,7 +198,8 @@ { "type": "json_encode" , "$1": { "type": "env" - , "vars": ["direct deps artifact names"] + , "vars": + ["direct deps artifact names", "extra outs"] } } } -- cgit v1.2.3 From 95905ca12f6433916ba3c326685f3cdfd92ce89f Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 21 Mar 2025 13:44:59 +0100 Subject: rules CC: Add DWP configuration variable ...defining the DWARF format packaging tool to use once debug fission is supported. --- CC/RULES | 45 +++++++++++++++++++++++++++++++++++++++++++-- CC/TARGETS | 1 + 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'CC') diff --git a/CC/RULES b/CC/RULES index 61834f9..a6c775c 100644 --- a/CC/RULES +++ b/CC/RULES @@ -21,6 +21,7 @@ , "ADD_LDFLAGS" , "ADD_DEBUGFLAGS" , "AR" + , "DWP" , "PATH" , "SYSTEM_TOOLS" ] @@ -44,9 +45,13 @@ , "CC": ["The C compiler to use"] , "CXX": ["The C++ compiler to use"] , "AR": ["The archiver tool to use"] + , "DWP": + [ "The DWARF format packaging tool to use. Required by debug builds that" + , "enable debug fission." + ] , "SYSTEM_TOOLS": - [ "List of tools (\"CC\", \"CXX\", or \"AR\") that should be taken from" - , "the system instead of from \"toolchain\" (if specified)." + [ "List of tools (\"CC\", \"CXX\", \"AR\", or \"DWP\") that should be" + , "taken from the system instead of from \"toolchain\" (if specified)." ] , "CFLAGS": [ "Flags for C compilation. Specifying this field overwrites" @@ -149,6 +154,7 @@ , ["ARFLAGS", {"type": "FIELD", "name": "ARFLAGS"}] , ["DEBUGFLAGS", {"type": "FIELD", "name": "DEBUGFLAGS"}] , ["AR", {"type": "FIELD", "name": "AR"}] + , ["DWP", {"type": "FIELD", "name": "DWP"}] , ["PATH", {"type": "FIELD", "name": "PATH"}] , ["provider", "CC"] , [ "CC" @@ -214,6 +220,14 @@ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} } ] + , ["provider", "DWP"] + , [ "DWP" + , { "type": "if" + , "cond": {"type": "var", "name": "DWP"} + , "then": {"type": "var", "name": "DWP"} + , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"} + } + ] , ["provider", "PATH"] , [ "PATH" , { "type": "nub_left" @@ -279,6 +293,20 @@ } ] } + , { "type": "if" + , "cond": {"type": "FIELD", "name": "DWP"} + , "then": + [ { "type": "singleton_map" + , "key": "DWP" + , "value": + { "type": "if" + , "cond": {"type": "FIELD", "name": "toolchain"} + , "then": true + , "else": false + } + } + ] + } , { "type": "foreach" , "range": {"type": "FIELD", "name": "SYSTEM_TOOLS"} , "var": "tool" @@ -432,6 +460,7 @@ , "CXXFLAGS" , "LDFLAGS" , "AR" + , "DWP" , "ARFLAGS" , "PATH" , "ENV" @@ -472,6 +501,7 @@ , "ADD_CFLAGS" , "ADD_CXXFLAGS" , "AR" + , "DWP" , "ENV" , "DEBUG" , "LINT" @@ -567,6 +597,11 @@ [ "The archive tool to used for creating the library" , "If None, the respective value from [\"CC\", \"defaults\"] will be taken." ] + , "DWP": + [ "The DWARF format packaging tool to use in debug builds that enable" + , "debug fission." + , "If None, the respective value from [\"CC\", \"defaults\"] will be taken." + ] , "ENV": ["The environment for any action generated."] , "DEBUG": [ "Map configuring the debug-stage, needed for local debugging." @@ -726,6 +761,7 @@ , "CXXFLAGS" , "ADD_CFLAGS" , "ADD_CXXFLAGS" + , "DWP" , "ENV" , "DEBUG" , "LINT" @@ -785,6 +821,11 @@ [ "The flags to add to the default ones for CXX" , "taken from the [\"CC\", \"defaults\"] target" ] + , "DWP": + [ "The DWARF format packaging tool to use in debug builds that enable" + , "debug fission." + , "If None, the respective value from [\"CC\", \"defaults\"] will be taken." + ] , "ENV": ["The environment for any action generated."] , "DEBUG": [ "Map configuring the debug-stage, needed for local debugging." diff --git a/CC/TARGETS b/CC/TARGETS index 2da456b..f629f7e 100644 --- a/CC/TARGETS +++ b/CC/TARGETS @@ -5,6 +5,7 @@ , "CFLAGS": [] , "CXXFLAGS": [] , "AR": ["ar"] + , "DWP": ["dwp"] , "PATH": ["/bin", "/usr/bin"] } } -- cgit v1.2.3 From 6634c6cc70f74696761c2306f2ce353359359b2e Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 1 Apr 2025 11:06:29 +0200 Subject: expressions CC: Small refactoring Allow the expressions running the actions producing the library and binary artifacts to pass along more information to consumers if needed by extending their return values to maps. Ensure the changes do not affect other consumers of the current expressions, such as the test rules, which do not expect extra information besides the single action artifact. --- CC/EXPRESSIONS | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 4 deletions(-) (limited to 'CC') diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 03c9c07..476bc11 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -1500,7 +1500,42 @@ } } , "lib artifact": - { "vars": + { "doc": ["Provides the library artifact."] + , "vars": + [ "CC" + , "CXX" + , "CFLAGS" + , "CXXFLAGS" + , "ADD_CFLAGS" + , "ADD_CXXFLAGS" + , "AR" + , "ENV" + , "DEBUG" + , "name" + , "pure C" + , "srcs" + , "hdrs" + , "private-hdrs" + , "stage" + , "compile-deps" + , "compile-args" + , "cflags-files" + , "defaults-transition" + ] + , "imports": {"lib action": "lib action"} + , "expression": + { "type": "lookup" + , "key": "library" + , "map": {"type": "CALL_EXPRESSION", "name": "lib action"} + , "default": {"type": "empty_map"} + } + } +, "lib action": + { "doc": + [ "Run the action producing the library artifact and pass it together with" + , "related information to consumers." + ] + , "vars": [ "CC" , "CXX" , "CFLAGS" @@ -1715,7 +1750,11 @@ } ] ] - , "body": {"type": "var", "name": "lib"} + , "body": + { "type": "singleton_map" + , "key": "library" + , "value": {"type": "var", "name": "lib"} + } } } , "lib result": @@ -1886,7 +1925,42 @@ } } , "bin artifact": - { "doc": ["Produces the binary artifact."] + { "doc": ["Provides the linked binary."] + , "vars": + [ "CC" + , "CXX" + , "CFLAGS" + , "CXXFLAGS" + , "ADD_CFLAGS" + , "ADD_CXXFLAGS" + , "ENV" + , "DEBUG" + , "name" + , "pure C" + , "srcs" + , "private-hdrs" + , "stage" + , "compile-deps" + , "compile-args" + , "link-deps" + , "link-args" + , "cflags-files" + , "ldflags-files" + , "defaults-transition" + ] + , "imports": {"bin action": "bin action"} + , "expression": + { "type": "lookup" + , "key": "binary" + , "map": {"type": "CALL_EXPRESSION", "name": "bin action"} + , "default": {"type": "empty_map"} + } + } +, "bin action": + { "doc": + [ "Run the action producing the binary artifact and pass it together with" + , "related information to consumers." + ] , "vars": [ "CC" , "CXX" @@ -2106,7 +2180,11 @@ } ] ] - , "body": {"type": "var", "name": "binary"} + , "body": + { "type": "singleton_map" + , "key": "binary" + , "value": {"type": "var", "name": "binary"} + } } } , "bin result": -- cgit v1.2.3 From 8859f56f490d4a21a3ac7000e913ed5a730b2327 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 1 Apr 2025 11:39:23 +0200 Subject: expressions CC: Add expression generating DWARF packages --- CC/EXPRESSIONS | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) (limited to 'CC') diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 476bc11..a085f6e 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -61,6 +61,27 @@ , "body": {"type": "var", "name": "AR"} } } +, "default-DWP": + { "vars": ["defaults-transition"] + , "imports": {"list_provider": ["./", "..", "field_list_provider"]} + , "expression": + { "type": "let*" + , "bindings": + [ ["fieldname", "defaults"] + , ["provider", "DWP"] + , ["transition", {"type": "var", "name": "defaults-transition"}] + , ["DWP", {"type": "CALL_EXPRESSION", "name": "list_provider"}] + , [ "DWP" + , { "type": "if" + , "cond": {"type": "var", "name": "DWP"} + , "then": {"type": "var", "name": "DWP"} + , "else": ["dwp"] + } + ] + ] + , "body": {"type": "var", "name": "DWP"} + } + } , "default-ARFLAGS": { "vars": ["defaults-transition"] , "imports": {"list_provider": ["./", "..", "field_list_provider"]} @@ -817,6 +838,142 @@ , "body": {"type": "var", "name": "flags"} } } +, "dwarf package": + { "vars": + [ "DWP" + , "TOOLCHAIN" + , "TOOLCHAIN_DIR" + , "NON_SYSTEM_TOOLS" + , "ENV" + , "name" + , "dwarf objects" + , "dwarf deps" + , "stage" + ] + , "imports": {"default-DWP": "default-DWP"} + , "expression": + { "type": "let*" + , "bindings": + [ [ "DWP" + , { "type": "var" + , "name": "DWP" + , "default": + { "type": "join" + , "$1": + { "type": "++" + , "$1": + [ { "type": "if" + , "cond": + { "type": "lookup" + , "key": "DWP" + , "map": {"type": "var", "name": "NON_SYSTEM_TOOLS"} + } + , "then": + ["./", {"type": "var", "name": "TOOLCHAIN_DIR"}, "/"] + } + , {"type": "CALL_EXPRESSION", "name": "default-DWP"} + ] + } + } + } + ] + , [ "pkgname" + , {"type": "join", "$1": [{"type": "var", "name": "name"}, ".dwp"]} + ] + , [ "pkgpath" + , { "type": "if" + , "cond": {"type": "var", "name": "stage"} + , "then": + { "type": "join" + , "separator": "/" + , "$1": + [ {"type": "var", "name": "stage"} + , {"type": "var", "name": "pkgname"} + ] + } + , "else": {"type": "var", "name": "pkgname"} + } + ] + , [ "objects" + , { "type": "var" + , "name": "dwarf objects" + , "default": {"type": "empty_map"} + } + ] + , [ "objects" + , { "type": "disjoint_map_union" + , "$1": + [ {"type": "var", "name": "objects"} + , {"type": "var", "name": "dwarf deps"} + ] + } + ] + , [ "dwarf pkg" + , { "type": "if" + , "cond": {"type": "var", "name": "objects"} + , "else": {"type": "empty_map"} + , "then": + { "type": "let*" + , "bindings": + [ [ "staged objects" + , { "type": "to_subdir" + , "subdir": "work" + , "$1": {"type": "var", "name": "objects"} + } + ] + , [ "staged pkgpath" + , { "type": "join" + , "$1": ["work/", {"type": "var", "name": "pkgpath"}] + } + ] + , [ "staged pkg" + , { "type": "ACTION" + , "outs": [{"type": "var", "name": "staged pkgpath"}] + , "inputs": + { "type": "map_union" + , "$1": + [ {"type": "var", "name": "TOOLCHAIN"} + , {"type": "var", "name": "staged objects"} + ] + } + , "env": + { "type": "var" + , "name": "ENV" + , "default": {"type": "empty_map"} + } + , "cmd": + { "type": "++" + , "$1": + [ [ {"type": "var", "name": "DWP", "default": "dwp"} + , "-o" + , {"type": "var", "name": "staged pkgpath"} + ] + , { "type": "keys" + , "$1": {"type": "var", "name": "staged objects"} + } + ] + } + } + ] + , [ "pkg artifact" + , { "type": "lookup" + , "map": {"type": "var", "name": "staged pkg"} + , "key": {"type": "var", "name": "staged pkgpath"} + } + ] + ] + , "body": + { "type": "singleton_map" + , "key": {"type": "var", "name": "pkgpath"} + , "value": {"type": "var", "name": "pkg artifact"} + } + } + } + ] + ] + , "body": {"type": "var", "name": "dwarf pkg"} + } + } , "objects": { "vars": [ "COMPILER" -- cgit v1.2.3 From a1069b261c9f266d2c1955170304202befb4f3fe Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 1 Apr 2025 11:50:26 +0200 Subject: rules CC: Libraries and binaries provide DWARF package files The "library" and "binary" rules are modified to generate, if needed, the appropriate DWARF package from the DWARF objects of their compilation units and the DWARF package files of their link dependencies, if any. The resulting artifact is made available to consumers in the provides map. --- CC/EXPRESSIONS | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 217 insertions(+), 13 deletions(-) (limited to 'CC') diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index a085f6e..5904281 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -1809,10 +1809,15 @@ ] } ] + , ["objects result", {"type": "CALL_EXPRESSION", "name": "objects"}] , [ "objects" , { "type": "lookup" , "key": "objects" - , "map": {"type": "CALL_EXPRESSION", "name": "objects"} + , "map": + { "type": "var" + , "name": "objects result" + , "default": {"type": "empty_map"} + } } ] , [ "base name" @@ -1908,9 +1913,28 @@ ] ] , "body": - { "type": "singleton_map" - , "key": "library" - , "value": {"type": "var", "name": "lib"} + { "type": "map_union" + , "$1": + [ { "type": "singleton_map" + , "key": "library" + , "value": {"type": "var", "name": "lib"} + } + , { "type": "singleton_map" + , "key": "dwarf objects" + , "value": + { "type": "lookup" + , "key": "dwarf objects" + , "map": + { "type": "var" + , "name": "objects result" + , "default": {"type": "empty_map"} + } + } + } + , { "type": "env" + , "vars": ["TOOLCHAIN", "TOOLCHAIN_DIR", "NON_SYSTEM_TOOLS", "ENV"] + } + ] } } } @@ -1923,6 +1947,7 @@ , "ADD_CFLAGS" , "ADD_CXXFLAGS" , "AR" + , "DWP" , "ENV" , "DEBUG" , "LINT" @@ -1947,9 +1972,10 @@ , "link-args-deps": "link-args-deps" , "cflags-files-deps": "cflags-files-deps" , "ldflags-files-deps": "ldflags-files-deps" - , "lib artifact": "lib artifact" + , "lib action": "lib action" , "debug-deps": "debug-deps" , "lint": "lint information" + , "dwarf package": "dwarf package" } , "expression": { "type": "let*" @@ -1972,7 +1998,71 @@ , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"} ] , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}] - , ["lib", {"type": "CALL_EXPRESSION", "name": "lib artifact"}] + , [ "lib action result" + , {"type": "CALL_EXPRESSION", "name": "lib action"} + ] + , [ "lib" + , { "type": "lookup" + , "key": "library" + , "map": {"type": "var", "name": "lib action result"} + } + ] + , [ "dwarf objects" + , { "type": "lookup" + , "key": "dwarf objects" + , "map": {"type": "var", "name": "lib action result"} + } + ] + , ["dwarf deps", {"type": "empty_map"}] + , [ "dwarf-pkg" + , { "type": "if" + , "cond": + { "type": "and" + , "$1": + [ {"type": "var", "name": "dwarf objects"} + , { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + ] + } + , "then": + { "type": "let*" + , "bindings": + [ [ "TOOLCHAIN" + , { "type": "lookup" + , "key": "TOOLCHAIN" + , "map": {"type": "var", "name": "lib action result"} + } + ] + , [ "TOOLCHAIN_DIR" + , { "type": "lookup" + , "key": "TOOLCHAIN_DIR" + , "map": {"type": "var", "name": "lib action result"} + } + ] + , [ "NON_SYSTEM_TOOLS" + , { "type": "lookup" + , "key": "NON_SYSTEM_TOOLS" + , "map": {"type": "var", "name": "lib action result"} + } + ] + , [ "ENV" + , { "type": "lookup" + , "key": "ENV" + , "map": {"type": "var", "name": "lib action result"} + } + ] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "dwarf package"} + } + , "else": {"type": "empty_map"} + } + ] , ["lint-deps fieldnames", ["deps", "private-deps"]] , [ "lint" , { "type": "if" @@ -2070,6 +2160,7 @@ , "debug-srcs" , "debug-hdrs" , "lint" + , "dwarf-pkg" ] } , { "type": "var" @@ -2215,10 +2306,15 @@ } ] , ["hdrs", {"type": "empty_map"}] + , ["objects result", {"type": "CALL_EXPRESSION", "name": "objects"}] , [ "objects" , { "type": "lookup" , "key": "objects" - , "map": {"type": "CALL_EXPRESSION", "name": "objects"} + , "map": + { "type": "var" + , "name": "objects result" + , "default": {"type": "empty_map"} + } } ] , [ "compile flags" @@ -2338,9 +2434,28 @@ ] ] , "body": - { "type": "singleton_map" - , "key": "binary" - , "value": {"type": "var", "name": "binary"} + { "type": "map_union" + , "$1": + [ { "type": "singleton_map" + , "key": "binary" + , "value": {"type": "var", "name": "binary"} + } + , { "type": "singleton_map" + , "key": "dwarf objects" + , "value": + { "type": "lookup" + , "key": "dwarf objects" + , "map": + { "type": "var" + , "name": "objects result" + , "default": {"type": "empty_map"} + } + } + } + , { "type": "env" + , "vars": ["TOOLCHAIN", "TOOLCHAIN_DIR", "NON_SYSTEM_TOOLS", "ENV"] + } + ] } } } @@ -2372,9 +2487,10 @@ , "link-args-deps": "link-args-deps" , "cflags-files-deps": "cflags-files-deps" , "ldflags-files-deps": "ldflags-files-deps" - , "binary": "bin artifact" + , "bin action": "bin action" , "debug-deps": "debug-deps" , "lint": "lint information" + , "dwarf package": "dwarf package" } , "expression": { "type": "let*" @@ -2454,13 +2570,101 @@ } } ] + , [ "bin action result" + , {"type": "CALL_EXPRESSION", "name": "bin action"} + ] + , [ "binary" + , { "type": "lookup" + , "key": "binary" + , "map": {"type": "var", "name": "bin action result"} + } + ] + , [ "dwarf objects" + , { "type": "lookup" + , "key": "dwarf objects" + , "map": {"type": "var", "name": "bin action result"} + } + ] + , [ "dwarf deps" + , { "type": "if" + , "cond": + { "type": "and" + , "$1": + [ {"type": "var", "name": "dwarf objects"} + , { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + ] + } + , "else": {"type": "empty_map"} + , "then": + { "type": "let*" + , "bindings": [["deps-provider", "dwarf-pkg"]] + , "body": {"type": "CALL_EXPRESSION", "name": "debug-deps"} + } + } + ] + , [ "dwarf-pkg" + , { "type": "if" + , "cond": + { "type": "and" + , "$1": + [ {"type": "var", "name": "dwarf objects"} + , { "type": "lookup" + , "key": "USE_DEBUG_FISSION" + , "map": + { "type": "var" + , "name": "DEBUG" + , "default": {"type": "empty_map"} + } + } + ] + } + , "then": + { "type": "let*" + , "bindings": + [ [ "TOOLCHAIN" + , { "type": "lookup" + , "key": "TOOLCHAIN" + , "map": {"type": "var", "name": "bin action result"} + } + ] + , [ "TOOLCHAIN_DIR" + , { "type": "lookup" + , "key": "TOOLCHAIN_DIR" + , "map": {"type": "var", "name": "bin action result"} + } + ] + , [ "NON_SYSTEM_TOOLS" + , { "type": "lookup" + , "key": "NON_SYSTEM_TOOLS" + , "map": {"type": "var", "name": "bin action result"} + } + ] + , [ "ENV" + , { "type": "lookup" + , "key": "ENV" + , "map": {"type": "var", "name": "bin action result"} + } + ] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "dwarf package"} + } + , "else": {"type": "empty_map"} + } + ] ] , "body": { "type": "RESULT" - , "artifacts": {"type": "CALL_EXPRESSION", "name": "binary"} + , "artifacts": {"type": "var", "name": "binary"} , "provides": { "type": "env" - , "vars": ["package", "debug-srcs", "debug-hdrs", "lint"] + , "vars": ["package", "debug-srcs", "debug-hdrs", "lint", "dwarf-pkg"] } } } -- cgit v1.2.3 From 20b7c7fa1b10a90e0e3aad46579ebe450d6720b9 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 4 Apr 2025 15:14:02 +0200 Subject: rules CC: Extend install-wih-deps to stage DWARF package files --- CC/EXPRESSIONS | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'CC') diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 5904281..cb114aa 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -2738,6 +2738,18 @@ } } ] + , [ "dwarf-pkg" + , { "type": "if" + , "cond": {"type": "var", "name": "skip-debug-stage"} + , "then": {"type": "empty_map"} + , "else": + { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "target"} + , "provider": "dwarf-pkg" + , "default": {"type": "empty_map"} + } + } + ] ] , "body": { "type": "if" @@ -2747,9 +2759,14 @@ { "type": "let*" , "bindings": [ [ "artifacts" - , { "type": "DEP_ARTIFACTS" - , "dep": {"type": "var", "name": "target"} - , "default": {"type": "empty_map"} + , { "type": "map_union" + , "$1": + [ { "type": "DEP_ARTIFACTS" + , "dep": {"type": "var", "name": "target"} + , "default": {"type": "empty_map"} + } + , {"type": "var", "name": "dwarf-pkg"} + ] } ] , [ "link-deps" -- cgit v1.2.3