Skip to content

Commit 6058dd7

Browse files
committed
enable optimization
Signed-off-by: Jo5ta <[email protected]>
1 parent a173a9c commit 6058dd7

File tree

9 files changed

+33
-39
lines changed

9 files changed

+33
-39
lines changed

CMakePresets.json

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"cacheVariables": {
1414
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
1515
"CMAKE_BUILD_TYPE": "Debug",
16+
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON",
17+
"CMAKE_CXX_FLAGS_DEBUG": "-Og",
18+
"CMAKE_C_FLAGS_DEBUG": "-Og",
1619
"STANDALONE_PROJECT": "ON"
1720
}
1821
},
@@ -23,19 +26,6 @@
2326
"CLLTK_EXAMPLES": "ON"
2427
}
2528
},
26-
{
27-
"name": "release",
28-
"inherits": "default",
29-
"displayName": "Release",
30-
"description": "Optimized release build with LTO.",
31-
"cacheVariables": {
32-
"CMAKE_BUILD_TYPE": "Release",
33-
"CMAKE_CXX_FLAGS_RELEASE": "-O3 -flto -DNDEBUG",
34-
"CMAKE_C_FLAGS_RELEASE": "-O3 -flto -DNDEBUG",
35-
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "TRUE",
36-
"CLLTK_TESTS": "OFF"
37-
}
38-
},
3929
{
4030
"name": "rpm",
4131
"inherits": "default",
@@ -71,13 +61,6 @@
7161
"targets": [
7262
"all"
7363
]
74-
},
75-
{
76-
"name": "release",
77-
"configurePreset": "release",
78-
"targets": [
79-
"all"
80-
]
8164
}
8265
],
8366
"testPresets": [

VERSION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ refactor: reorganize include structure and improve project layout
1010
- Restructured decoder_tool and snapshot_library to use consistent directory layout and public headers.
1111
- Fixed include paths in all examples, tests, and kernel module code to reflect new structure.
1212
- Removed redundant CMake logic and improved target properties.
13+
- Enable optimization
1314
## 1.2.47
1415
- fix macros
1516
- add more cmake options

command_line_tool/commands/decode/decoder.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,9 @@ static void add_decode_command(CLI::App &app)
128128
});
129129
}
130130

131-
static int init_function() noexcept
131+
static void init_function() noexcept
132132
{
133133
auto [app, lock] = CommonLowLevelTracingKit::cmd::interface::acquireMainApp();
134134
add_decode_command(app);
135-
return 0;
136135
}
137-
138-
static const int dummy = init_function();
136+
COMMAND_INIT(init_function);

command_line_tool/commands/snapshot/snapshot.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ static void add_snapshot_command(CLI::App &app)
6565
[&]() { take_snapshot(output_file_name, tracepoints, compress, bucket_size, verbose); });
6666
}
6767

68-
static int init_function() noexcept
68+
69+
static void init_function() noexcept
6970
{
7071
auto [app, lock] = CommonLowLevelTracingKit::cmd::interface::acquireMainApp();
7172
add_snapshot_command(app);
72-
return 0;
7373
}
74-
75-
static const int dummy = init_function();
74+
COMMAND_INIT(init_function);

command_line_tool/commands/trace/tracebuffer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ static void add_create_tracebuffer_command(CLI::App &app)
4141
command->callback([]() { clltk_dynamic_tracebuffer_creation(tracebuffer.c_str(), size); });
4242
}
4343

44-
static int init_function() noexcept
44+
static void init_function() noexcept
4545
{
4646
auto [app, lock] = CommonLowLevelTracingKit::cmd::interface::acquireMainApp();
4747
add_create_tracebuffer_command(app);
48-
return 0;
4948
}
49+
COMMAND_INIT(init_function);
5050

51-
static const int dummy = init_function();

command_line_tool/commands/trace/tracepipe.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,9 @@ class Command
122122
}
123123
};
124124

125-
static int init_function() noexcept
125+
static void init_function() noexcept
126126
{
127127
auto [app, lock] = CommonLowLevelTracingKit::cmd::interface::acquireMainApp();
128128
Command::AddCommand(app);
129-
return 0;
130129
}
131-
132-
static const int dummy = init_function();
130+
COMMAND_INIT(init_function);

command_line_tool/commands/trace/tracepoint.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ static void add_create_tracepoint_command(CLI::App &app)
6969
});
7070
}
7171

72-
static int init_function() noexcept
72+
static void init_function() noexcept
7373
{
7474
auto [app, lock] = CommonLowLevelTracingKit::cmd::interface::acquireMainApp();
7575
add_create_tracepoint_command(app);
76-
return 0;
7776
}
78-
79-
static const int dummy = init_function();
77+
COMMAND_INIT(init_function);

command_line_tool/interface/commands/interface.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@
88
#include "CLI/Config.hpp" // IWYU pragma: export
99
#include "CLI/Formatter.hpp" // IWYU pragma: export
1010
#include "CLI/Validators.hpp" // IWYU pragma: export
11+
#if __has_include("CLI/ExtraValidators.hpp")
12+
#include "CLI/ExtraValidators.hpp" // IWYU pragma: export
13+
#endif
1114
#include <CLI/Error.hpp> // IWYU pragma: export
1215
#include <CLI/Option.hpp> // IWYU pragma: export
1316

1417
#include <mutex>
1518

19+
typedef void (*init_fn)(void);
20+
#define COMMAND_INIT(func) \
21+
__attribute__((retain, used, section("clltk_cmdinit"))) \
22+
static init_fn _init_##func##_ptr = func
23+
24+
1625
namespace CommonLowLevelTracingKit::cmd::interface
1726
{
1827
using MainAppHandle = std::pair<CLI::App &, std::unique_lock<std::mutex>>;

command_line_tool/main/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,17 @@ CommonLowLevelTracingKit::cmd::interface::acquireMainApp(void)
6161
return {*mainApp, std::unique_lock{mainAppLock}};
6262
}
6363

64+
void call_all_init_functions(void) {
65+
extern init_fn __start_clltk_cmdinit;
66+
extern init_fn __stop_clltk_cmdinit;
67+
for (init_fn *p = &__start_clltk_cmdinit; p < &__stop_clltk_cmdinit; p++) {
68+
(*p)();
69+
}
70+
}
71+
6472
int main(int argc, const char **argv)
6573
{
74+
call_all_init_functions();
6675
auto [app, lock] = CommonLowLevelTracingKit::cmd::interface::acquireMainApp();
6776
if (argc == 1) {
6877
std::cout << app.help() << std::endl;

0 commit comments

Comments
 (0)