Skip to content

Commit c4da8c3

Browse files
authored
Merge pull request #675 from elbeno/death-to-sc
2 parents a0eb6cd + 45fa69f commit c4da8c3

18 files changed

+64
-851
lines changed

CMakeLists.txt

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,6 @@ set(GEN_STR_CATALOG
3232
${CMAKE_CURRENT_LIST_DIR}/tools/gen_str_catalog.py
3333
CACHE FILEPATH "Location of script to generate a string catalog")
3434

35-
add_library(cib_sc INTERFACE)
36-
target_compile_features(cib_sc INTERFACE cxx_std_20)
37-
target_link_libraries_system(cib_sc INTERFACE fmt::fmt-header-only stdx)
38-
39-
target_sources(
40-
cib_sc
41-
INTERFACE FILE_SET
42-
sc
43-
TYPE
44-
HEADERS
45-
BASE_DIRS
46-
include
47-
FILES
48-
include/sc/format.hpp
49-
include/sc/fwd.hpp
50-
include/sc/lazy_string_format.hpp
51-
include/sc/string_constant.hpp)
52-
5335
add_library(cib_match INTERFACE)
5436
target_compile_features(cib_match INTERFACE cxx_std_20)
5537
target_link_libraries_system(cib_match INTERFACE stdx)
@@ -241,7 +223,7 @@ target_sources(
241223

242224
add_library(cib_flow INTERFACE)
243225
target_compile_features(cib_flow INTERFACE cxx_std_20)
244-
target_link_libraries_system(cib_flow INTERFACE cib_log cib_nexus cib_sc stdx)
226+
target_link_libraries_system(cib_flow INTERFACE cib_log cib_nexus stdx)
245227

246228
target_sources(
247229
cib_flow
@@ -266,14 +248,7 @@ target_sources(
266248

267249
add_library(cib_seq INTERFACE)
268250
target_compile_features(cib_seq INTERFACE cxx_std_20)
269-
target_link_libraries_system(
270-
cib_seq
271-
INTERFACE
272-
cib_flow
273-
cib_log
274-
cib_nexus
275-
cib_sc
276-
stdx)
251+
target_link_libraries_system(cib_seq INTERFACE cib_flow cib_log cib_nexus stdx)
277252

278253
target_sources(
279254
cib_seq
@@ -303,7 +278,6 @@ target_link_libraries_system(
303278
cib_match
304279
cib_msg
305280
cib_nexus
306-
cib_sc
307281
cib_seq
308282
concurrency
309283
fmt::fmt-header-only
@@ -333,7 +307,6 @@ if(PROJECT_IS_TOP_LEVEL)
333307
clang_tidy_interface(cib_match)
334308
clang_tidy_interface(cib_msg)
335309
clang_tidy_interface(cib_nexus)
336-
clang_tidy_interface(cib_sc)
337310
clang_tidy_interface(cib_seq)
338311

339312
# Enable functional and performance test suites.

docs/index.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ include::logging.adoc[]
1313
include::interrupts.adoc[]
1414
include::match.adoc[]
1515
include::message.adoc[]
16-
include::sc.adoc[]
1716
include::implementation_details.adoc[]

docs/intro.adoc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ _cib_ contains several parts that work together:
4747
- xref:interrupt.adoc#_the_interrupt_library[`interrupt`]
4848
- xref:match.adoc#_the_match_library[`match`]
4949
- xref:message.adoc#_the_message_library[`message`]
50-
- xref:sc.adoc#_the_sc_string_constant_library[`sc` (string constant)]
5150

5251
=== Sub-library DAG
5352

@@ -58,13 +57,11 @@ library that contains all the functionality.
5857
----
5958
flowchart BT
6059
nexus(cib_nexus)
61-
sc(cib_sc)
6260
log(cib_log)
6361
match(cib_match)
6462
lookup(cib_lookup)
6563
6664
flow(cib_flow) --> nexus
67-
flow --> sc
6865
flow --> log
6966
7067
log_fmt(cib_log_fmt) --> log

docs/logging.adoc

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ xref:logging.adoc#_logging_environments[environment].
9999

100100
The first two runtime parameters receive preprocessor `\_​_FILE_​\_` and `__LINE_​_` values
101101
respectively. The `msg` argument is a structure containing a
102-
xref:sc.adoc#_formatting_strings[compile-time format string] and runtime
102+
compile-time format string and runtime
103103
arguments to be interpolated into it. It supports an `apply` function, so one
104104
way to implement `log` is:
105105

@@ -185,11 +185,52 @@ struct my_struct {
185185
}
186186
----
187187

188-
=== String data
189-
190-
On a constrained system, space for text can be at a premium. The `sc` library
191-
and the MIPI Sys-T logger combine to
192-
xref:sc.adoc#_efficient_logging_with_mipi_sys_t[solve this problem].
188+
=== Efficient logging with MIPI Sys-T
189+
190+
On a constrained system, space for text can be limited-to-nonexistent. `cib`
191+
uses `stdx::ct_format` and the
192+
https://github.com/intel/compile-time-init-build/tree/main/include/log/catalog/mipi_encoder.hpp[MIPI
193+
Sys-T logging config] to solve this problem.
194+
195+
- First, each string constant contains string character data in its type.
196+
- The MIPI logger calls the function template specialization
197+
https://github.com/intel/compile-time-init-build/blob/main/include/log/catalog/catalog.hpp[`catalog`]
198+
to get the catalog ID corresponding to each string constant.
199+
200+
But: the `catalog` function template is just that -- only a template -- to
201+
begin with. It is specialized as follows:
202+
203+
- The application is built as a library.
204+
- Running `nm` on that library reveals missing symbols: precisely the function
205+
specializations that are required for all the string constants.
206+
- Those symbols are used to generate the template specializations in another
207+
file, which itself is compiled into a library.
208+
- String data is recovered from the symbol types and used to generate the
209+
catalog collateral in XML and/or JSON format.
210+
- Link-time optimization inlines the `catalog` function template
211+
specializations, each of which is a one-line function that returns a
212+
catalog ID.
213+
214+
Thus no string data exists in the executable, but the correct catalog IDs are
215+
used in logging, and the remote log handler can reconstitute the actual strings.
216+
The XML and JSON collateral also contains information about any runtime
217+
arguments that need to be interpolated into the string and whose values are sent
218+
by the MIPI Sys-T logger after the catalog ID.
219+
220+
==== Tooling support
221+
222+
The process of generating log strings from the type information revealed by
223+
missing symbols is automated by a
224+
https://github.com/intel/compile-time-init-build/blob/main/tools/gen_str_catalog.py[python
225+
script] provided and by a
226+
https://github.com/intel/compile-time-init-build/blob/main/cmake/string_catalog.cmake[CMake
227+
wrapper function (`gen_str_catalog`)] that drives the process. See
228+
https://github.com/intel/compile-time-init-build/blob/main/test/CMakeLists.txt[the
229+
test] that exercises that functionality for an example.
230+
231+
NOTE: This process assigns IDs to both strings and
232+
xref:logging.adoc#_modules[log modules]. `catalog` is specialized for catalog
233+
IDs; `module` is specialized for module IDs.
193234

194235
=== Version logging
195236

docs/sc.adoc

Lines changed: 0 additions & 125 deletions
This file was deleted.

include/flow/graph_builder.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,10 @@ struct graph_builder {
169169

170170
template <typename T>
171171
constexpr static auto error_steps =
172-
stdx::transform([](auto N) { return stdx::ct_string_from_type(N); },
173-
T{})
174-
.join(stdx::ct_string{""}, [](auto x, auto y) {
175-
using namespace stdx::literals;
176-
return x + ", "_cts + y;
177-
});
172+
T{}.join(stdx::cts_t<"">{}, [](auto x, auto y) {
173+
using namespace stdx::literals;
174+
return x + ", "_ctst + y;
175+
});
178176

179177
constexpr static void check_for_missing_nodes(auto nodes,
180178
auto mentioned_nodes) {

include/flow/graphviz_builder.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ struct graphviz_builder {
2020
nodes_t sinks{};
2121
for_each(
2222
[&]<typename Node>(Node const &) {
23-
sources.insert(Node::name_t::value);
24-
sinks.insert(Node::name_t::value);
23+
sources.emplace(Node::name_t::value);
24+
sinks.emplace(Node::name_t::value);
2525
},
2626
nodes);
2727
for_each(
2828
[&]<typename Edge>(Edge const &) {
29-
sinks.erase(Edge::source_t::name_t::value);
30-
sources.erase(Edge::dest_t::name_t::value);
29+
sinks.erase(std::string_view{Edge::source_t::name_t::value});
30+
sources.erase(std::string_view{Edge::dest_t::name_t::value});
3131
},
3232
edges);
3333

@@ -39,9 +39,9 @@ struct graphviz_builder {
3939
}
4040
for_each(
4141
[&]<typename Edge>(Edge const &) {
42-
output += std::string{Edge::source_t::name_t::value};
42+
output += std::string_view{Edge::source_t::name_t::value};
4343
output += " -> ";
44-
output += std::string{Edge::dest_t::name_t::value};
44+
output += std::string_view{Edge::dest_t::name_t::value};
4545
output += '\n';
4646
},
4747
edges);

include/flow/step.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <flow/common.hpp>
66
#include <flow/log.hpp>
77
#include <flow/subgraph_identity.hpp>
8-
#include <sc/string_constant.hpp>
98

109
#include <stdx/compiler.hpp>
1110
#include <stdx/ct_string.hpp>
@@ -18,10 +17,7 @@ template <stdx::ct_string Type, stdx::ct_string Name,
1817
subgraph_identity Identity, typename Cond, typename F>
1918
struct ct_node {
2019
using is_subgraph = void;
21-
using type_t =
22-
decltype(stdx::ct_string_to_type<Type, sc::string_constant>());
23-
using name_t =
24-
decltype(stdx::ct_string_to_type<Name, sc::string_constant>());
20+
using name_t = stdx::cts_t<Name>;
2521
using func_t = F;
2622

2723
constexpr static auto ct_type = Type;

0 commit comments

Comments
 (0)