Skip to content

Allow hyperlight-host to build with x86_64-unknown-linux-musl target #601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ alias cg := build-and-move-c-guests

# build host library
build target=default-target:
cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
cargo build --profile={{ if target == "debug" { "dev" } else { target } }}

# build host library
build-with-musl-libc target=default-target:
cargo build --profile={{ if target == "debug" { "dev" } else { target } }} --target x86_64-unknown-linux-musl


# build testing guest binaries
guests: build-and-move-rust-guests build-and-move-c-guests
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
channel = "1.85"
# Target used for guest binaries. This is an additive list of targets in addition to host platform.
# Will install the target if not already installed when building guest binaries.
targets = ["x86_64-unknown-none"]
targets = ["x86_64-unknown-none", "x86_64-unknown-linux-musl"]
13 changes: 13 additions & 0 deletions src/hyperlight_host/src/hypervisor/hyperv_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,19 @@ impl HypervLinuxDriver {
interrupt_handle: Arc::new(LinuxInterruptHandle {
running: AtomicU64::new(0),
cancel_requested: AtomicBool::new(false),
#[cfg(all(
target_arch = "x86_64",
target_vendor = "unknown",
target_os = "linux",
target_env = "musl"
))]
tid: AtomicU64::new(unsafe { libc::pthread_self() as u64 }),
#[cfg(not(all(
target_arch = "x86_64",
target_vendor = "unknown",
target_os = "linux",
target_env = "musl"
)))]
tid: AtomicU64::new(unsafe { libc::pthread_self() }),
retry_delay: config.get_interrupt_retry_delay(),
sig_rt_min_offset: config.get_interrupt_vcpu_sigrtmin_offset(),
Expand Down
13 changes: 13 additions & 0 deletions src/hyperlight_host/src/hypervisor/kvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,19 @@ impl KVMDriver {
interrupt_handle: Arc::new(LinuxInterruptHandle {
running: AtomicU64::new(0),
cancel_requested: AtomicBool::new(false),
#[cfg(all(
target_arch = "x86_64",
target_vendor = "unknown",
target_os = "linux",
target_env = "musl"
))]
tid: AtomicU64::new(unsafe { libc::pthread_self() as u64 }),
#[cfg(not(all(
target_arch = "x86_64",
target_vendor = "unknown",
target_os = "linux",
target_env = "musl"
)))]
tid: AtomicU64::new(unsafe { libc::pthread_self() }),
retry_delay: config.get_interrupt_retry_delay(),
dropped: AtomicBool::new(false),
Expand Down
20 changes: 19 additions & 1 deletion src/hyperlight_host/src/seccomp/guest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,25 @@ fn syscalls_allowlist() -> Result<Vec<(i64, Vec<SeccompRule>)>> {
// because we don't currently support registering parameterized syscalls.
(
libc::SYS_ioctl,
or![and![Cond::new(1, ArgLen::Dword, Eq, libc::TCGETS)?]],
or![and![Cond::new(
1,
ArgLen::Dword,
Eq,
#[cfg(all(
target_arch = "x86_64",
target_vendor = "unknown",
target_os = "linux",
target_env = "musl"
))]
libc::TCGETS.try_into()?,
#[cfg(not(all(
target_arch = "x86_64",
target_vendor = "unknown",
target_os = "linux",
target_env = "musl"
)))]
libc::TCGETS,
)?]],
),
// `futex` is needed for some tests that run in parallel (`simple_test_parallel`,
// and `callback_test_parallel`).
Expand Down
Loading