Skip to content

Commit 39ac164

Browse files
authored
Build rust guests without hyperlight-libc (#1505)
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent bd08e23 commit 39ac164

5 files changed

Lines changed: 12 additions & 146 deletions

File tree

src/hyperlight_guest_bin/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ fn _panic_handler(info: &core::panic::PanicInfo) -> ! {
203203

204204
unsafe extern "C" {
205205
fn hyperlight_main();
206+
207+
#[cfg(feature = "libc")]
206208
fn srand(seed: u32);
207209
}
208210

@@ -222,7 +224,7 @@ core::arch::global_asm!(
222224
/// user initialisation
223225
pub(crate) extern "C" fn generic_init(
224226
peb_address: u64,
225-
seed: u64,
227+
_seed: u64,
226228
ops: u64,
227229
max_log_level: u64,
228230
) -> u64 {
@@ -248,11 +250,13 @@ pub(crate) extern "C" fn generic_init(
248250
#[cfg(feature = "trace_guest")]
249251
let guest_start_tsc = hyperlight_guest_tracing::invariant_tsc::read_tsc();
250252

253+
#[cfg(feature = "libc")]
251254
unsafe {
252-
let srand_seed = (((peb_address << 8) ^ (seed >> 4)) >> 32) as u32;
253-
// Set the seed for the random number generator for C code using rand;
255+
let srand_seed = (((peb_address << 8) ^ (_seed >> 4)) >> 32) as u32;
254256
srand(srand_seed);
257+
}
255258

259+
unsafe {
256260
OS_PAGE_SIZE = ops as u32;
257261
}
258262

src/tests/rust_guests/Cargo.lock

Lines changed: 2 additions & 140 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tests/rust_guests/dummyguest/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66

77
[dependencies]
8-
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
8+
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin", default-features = false }
99
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
1010

1111
[features]

src/tests/rust_guests/simpleguest/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
hyperlight-guest = { path = "../../../hyperlight_guest" }
8-
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
8+
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin", default-features = false, features = ["macros"] }
99
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
1010
hyperlight-guest-tracing = { path = "../../../hyperlight_guest_tracing" }
1111
log = {version = "0.4", default-features = false }

src/tests/rust_guests/witguest/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
hyperlight-guest = { path = "../../../hyperlight_guest" }
8-
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
8+
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin", default-features = false }
99
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
1010
hyperlight-component-macro = { path = "../../../hyperlight_component_macro" }
1111
spin = "0.10.0"

0 commit comments

Comments
 (0)