Skip to content

Commit d185df2

Browse files
simongdaviesludfjig
authored andcommitted
Changes to allow hyperlight-host to build with x86_64-unknown-linux-musl target (#601)
Signed-off-by: Simon Davies <[email protected]>
1 parent 18cae10 commit d185df2

File tree

5 files changed

+52
-3
lines changed

5 files changed

+52
-3
lines changed

Justfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ 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+
cargo build --profile={{ if target == "debug" { "dev" } else { target } }} --target x86_64-unknown-linux-musl
32+
2833

2934
# build testing guest binaries
3035
guests: build-and-move-rust-guests build-and-move-c-guests

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
channel = "1.85"
33
# Target used for guest binaries. This is an additive list of targets in addition to host platform.
44
# Will install the target if not already installed when building guest binaries.
5-
targets = ["x86_64-unknown-none"]
5+
targets = ["x86_64-unknown-none", "x86_64-unknown-linux-musl"]

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,19 @@ impl HypervLinuxDriver {
398398
interrupt_handle: Arc::new(LinuxInterruptHandle {
399399
running: AtomicU64::new(0),
400400
cancel_requested: AtomicBool::new(false),
401+
#[cfg(all(
402+
target_arch = "x86_64",
403+
target_vendor = "unknown",
404+
target_os = "linux",
405+
target_env = "musl"
406+
))]
407+
tid: AtomicU64::new(unsafe { libc::pthread_self() as u64 }),
408+
#[cfg(not(all(
409+
target_arch = "x86_64",
410+
target_vendor = "unknown",
411+
target_os = "linux",
412+
target_env = "musl"
413+
)))]
401414
tid: AtomicU64::new(unsafe { libc::pthread_self() }),
402415
retry_delay: config.get_interrupt_retry_delay(),
403416
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
@@ -353,6 +353,19 @@ impl KVMDriver {
353353
interrupt_handle: Arc::new(LinuxInterruptHandle {
354354
running: AtomicU64::new(0),
355355
cancel_requested: AtomicBool::new(false),
356+
#[cfg(all(
357+
target_arch = "x86_64",
358+
target_vendor = "unknown",
359+
target_os = "linux",
360+
target_env = "musl"
361+
))]
362+
tid: AtomicU64::new(unsafe { libc::pthread_self() as u64 }),
363+
#[cfg(not(all(
364+
target_arch = "x86_64",
365+
target_vendor = "unknown",
366+
target_os = "linux",
367+
target_env = "musl"
368+
)))]
356369
tid: AtomicU64::new(unsafe { libc::pthread_self() }),
357370
retry_delay: config.get_interrupt_retry_delay(),
358371
dropped: AtomicBool::new(false),

src/hyperlight_host/src/seccomp/guest.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,25 @@ 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+
#[cfg(all(
57+
target_arch = "x86_64",
58+
target_vendor = "unknown",
59+
target_os = "linux",
60+
target_env = "musl"
61+
))]
62+
libc::TCGETS.try_into()?,
63+
#[cfg(not(all(
64+
target_arch = "x86_64",
65+
target_vendor = "unknown",
66+
target_os = "linux",
67+
target_env = "musl"
68+
)))]
69+
libc::TCGETS,
70+
)?]],
5371
),
5472
// `futex` is needed for some tests that run in parallel (`simple_test_parallel`,
5573
// and `callback_test_parallel`).

0 commit comments

Comments
 (0)