Skip to content

Commit 245fd9f

Browse files
committed
Changes to allow hyperlight-host to build with x86_64-unknown-linux-musl target
Signed-off-by: Simon Davies <[email protected]>
1 parent bdf5800 commit 245fd9f

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

Justfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ alias cg := build-and-move-c-guests
2424

2525
# build host library
2626
build target=default-target:
27-
cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
27+
cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
28+
29+
# build host library
30+
build-with-musl-libc target=default-target:
31+
rustup target add x86_64-unknown-linux-musl
32+
cargo build --profile={{ if target == "debug" { "dev" } else { target } }} --target x86_64-unknown-linux-musl
33+
2834

2935
# build testing guest binaries
3036
guests: build-and-move-rust-guests build-and-move-c-guests

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,19 @@ impl HypervLinuxDriver {
405405
interrupt_handle: Arc::new(LinuxInterruptHandle {
406406
running: AtomicU64::new(0),
407407
cancel_requested: AtomicBool::new(false),
408+
#[cfg(all(
409+
target_arch = "x86_64",
410+
target_vendor = "unknown",
411+
target_os = "linux",
412+
target_env = "musl"
413+
))]
414+
tid: AtomicU64::new(unsafe { libc::pthread_self() as u64 }),
415+
#[cfg(not(all(
416+
target_arch = "x86_64",
417+
target_vendor = "unknown",
418+
target_os = "linux",
419+
target_env = "musl"
420+
)))]
408421
tid: AtomicU64::new(unsafe { libc::pthread_self() }),
409422
retry_delay: config.get_interrupt_retry_delay(),
410423
sig_rt_min_offset: config.get_interrupt_vcpu_sigrtmin_offset(),

src/hyperlight_host/src/hypervisor/kvm.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,19 @@ impl KVMDriver {
360360
interrupt_handle: Arc::new(LinuxInterruptHandle {
361361
running: AtomicU64::new(0),
362362
cancel_requested: AtomicBool::new(false),
363+
#[cfg(all(
364+
target_arch = "x86_64",
365+
target_vendor = "unknown",
366+
target_os = "linux",
367+
target_env = "musl"
368+
))]
369+
tid: AtomicU64::new(unsafe { libc::pthread_self() as u64 }),
370+
#[cfg(not(all(
371+
target_arch = "x86_64",
372+
target_vendor = "unknown",
373+
target_os = "linux",
374+
target_env = "musl"
375+
)))]
363376
tid: AtomicU64::new(unsafe { libc::pthread_self() }),
364377
retry_delay: config.get_interrupt_retry_delay(),
365378
dropped: AtomicBool::new(false),

src/hyperlight_host/src/seccomp/guest.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ fn syscalls_allowlist() -> Result<Vec<(i64, Vec<SeccompRule>)>> {
4949
// because we don't currently support registering parameterized syscalls.
5050
(
5151
libc::SYS_ioctl,
52-
or![and![Cond::new(1, ArgLen::Dword, Eq, libc::TCGETS)?]],
52+
or![and![Cond::new(
53+
1,
54+
ArgLen::Dword,
55+
Eq,
56+
libc::TCGETS.try_into()?
57+
)?]],
5358
),
5459
// `futex` is needed for some tests that run in parallel (`simple_test_parallel`,
5560
// and `callback_test_parallel`).

0 commit comments

Comments
 (0)