Skip to content

Commit 104f62a

Browse files
authored
Update hyperlight-guest-tracing crate to conditionally enable traces at compile time (#752)
* [trace] Add check for empty message to trace macro Signed-off-by: Doru Blânzeanu <[email protected]> * [trace] move tracing logic inside tracing module - this helps with later conditionally compiling only the tracing code depending on a feature Signed-off-by: Doru Blânzeanu <[email protected]> * [trace] add 'trace' feature to guest tracing crates - This allows the use of the 'hyperlight-guest-tracing' without having the tracing enabled - Now the user can select at compile time whether the macros enable tracing or not - Before this change, the crate using the macros from hyperlight-guest-tracing-macro needed to define a features called 'trace_guest' because the generated code would gate everything with that feature - The change makes the generation of code dependent on the 'trace' feature - Some of the variables used in the macros were prefixed with an '_' to avoid warnings when the 'trace' feature is not set Signed-off-by: Doru Blânzeanu <[email protected]> * [trace] move macros tests to the tracing crate - This is needed for the tests to pass because the macros use 'hyperlight_guest_tracing::' which cannot be imported by 'hyperlight_guest_tracing_macro' bacause it would create a circular dependency. - The caveat is that when using 'hyperlight_guest_tracing_macro' one needs to have as a dependency 'hyperlight_guest_tracing' also Signed-off-by: Doru Blânzeanu <[email protected]> * update guests to use the tracing crate to intrument functions Signed-off-by: Doru Blânzeanu <[email protected]> --------- Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 0e5d419 commit 104f62a

File tree

14 files changed

+422
-298
lines changed

14 files changed

+422
-298
lines changed

src/hyperlight_guest/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Provides only the essential building blocks for interacting with the host enviro
1515
anyhow = { version = "1.0.98", default-features = false }
1616
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
1717
hyperlight-common = { workspace = true }
18-
hyperlight-guest-tracing = { workspace = true }
18+
hyperlight-guest-tracing = { workspace = true, default-features = false }
1919

2020
[features]
2121
default = []
22-
trace_guest = []
22+
trace_guest = ["hyperlight-guest-tracing/trace"]

src/hyperlight_guest_bin/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ and third-party code used by our C-API needed to build a native hyperlight-guest
1717
default = ["libc", "printf"]
1818
libc = [] # compile musl libc
1919
printf = [ "libc" ] # compile printf
20-
trace_guest = ["hyperlight-common/trace_guest", "hyperlight-guest/trace_guest"]
20+
trace_guest = ["hyperlight-common/trace_guest", "hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"]
2121
mem_profile = ["hyperlight-common/unwind_guest","hyperlight-common/mem_profile"]
2222

2323
[dependencies]
2424
hyperlight-guest = { workspace = true, default-features = false }
2525
hyperlight-common = { workspace = true, default-features = false }
26-
hyperlight-guest-tracing = { workspace = true }
26+
hyperlight-guest-tracing = { workspace = true, default-features = false }
2727
buddy_system_allocator = "0.11.0"
2828
log = { version = "0.4", default-features = false }
2929
spin = "0.10.0"

src/hyperlight_guest_tracing/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ readme.workspace = true
1010
description = """Provides the tracing functionality for the hyperlight guest."""
1111

1212
[dependencies]
13-
hyperlight-common = { workspace = true, default-features = false, features = ["trace_guest"] }
13+
hyperlight-common = { workspace = true, default-features = false }
1414
hyperlight-guest-tracing-macro = { workspace = true }
1515
spin = "0.10.0"
1616

1717
[lints]
1818
workspace = true
19+
20+
[features]
21+
default = []
22+
trace = [ "hyperlight-guest-tracing-macro/trace", "hyperlight-common/trace_guest" ]

0 commit comments

Comments
 (0)