diff --git a/CHANGELOG.md b/CHANGELOG.md index b2cbb54ef5..af762a1f96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). * **Breaking:** Generated libc bindings use `usize` for `size_t` arguments and return values, including `strlen` and `memcpy`. Rust callers that use `u64` or `c_ulong` need explicit conversions. The C ABI is unchanged. ### Removed +* **Breaking:** The `print_debug` cargo feature and the exported `hyperlight_host::debug!` macro. Use `tracing::debug!` with a subscriber. +* **Breaking:** The `build-metadata` cargo feature. A library should not log build details, and for crates.io users its git fields were always empty. Applications can log build details with their own tooling. ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 5292f14c87..79d96a9170 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -295,16 +295,6 @@ dependencies = [ "spin 0.10.1", ] -[[package]] -name = "built" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9" -dependencies = [ - "chrono", - "git2", -] - [[package]] name = "bumpalo" version = "3.20.3" @@ -1382,18 +1372,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "git2" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddddbf932745a6be37109b6112d3ee09696106f848449069d3a57bba937ab82e" -dependencies = [ - "bitflags 2.13.2", - "libc", - "libgit2-sys", - "log", -] - [[package]] name = "glib" version = "0.22.9" @@ -1786,7 +1764,6 @@ dependencies = [ "bindgen", "bitflags 2.13.2", "blake3", - "built", "bytemuck", "cc", "cfg-if", @@ -2254,18 +2231,6 @@ dependencies = [ "cc", ] -[[package]] -name = "libgit2-sys" -version = "0.18.8+1.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7c568b25d7489bc3fb2988ed69ab111d2944d2f5fec3d5c987fe545ea97b50" -dependencies = [ - "cc", - "libc", - "libz-sys", - "pkg-config", -] - [[package]] name = "libloading" version = "0.8.9" @@ -2308,18 +2273,6 @@ dependencies = [ "escape8259", ] -[[package]] -name = "libz-sys" -version = "1.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bc9657773828b90eeb625adff10eeac83cc21bbfd8e23a03eaa8a33c9e28d9" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linkme" version = "0.3.37" @@ -4383,12 +4336,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version-compare" version = "0.2.1" diff --git a/Justfile b/Justfile index fbb2b83ce5..72e7917ff4 100644 --- a/Justfile +++ b/Justfile @@ -112,8 +112,8 @@ test-like-ci config=default-target hypervisor="kvm": @# with default features just test {{config}} - @# with only one driver enabled + build-metadata - just test {{config}} build-metadata,{{ if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }} + @# with only one driver enabled + just test {{config}} {{ if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }} @# with hw-interrupts enabled (+ explicit driver on Linux) {{ if os() == "linux" { if hypervisor == "mshv3" { "just test " + config + " mshv3,hw-interrupts" } else { "just test " + config + " kvm,hw-interrupts" } } else { "just test " + config + " hw-interrupts" } }} @@ -375,7 +375,6 @@ miri-tests: (ensure-cargo-nextest) (ensure-nightly-miri) check: {{ cargo-cmd }} check {{ target-triple-flag }} {{ cargo-cmd }} check -p hyperlight-host --features crashdump {{ target-triple-flag }} - {{ cargo-cmd }} check -p hyperlight-host --features print_debug {{ target-triple-flag }} {{ cargo-cmd }} check -p hyperlight-host --features gdb {{ target-triple-flag }} {{ cargo-cmd }} check -p hyperlight-host --features trace_guest,mem_profile {{ target-triple-flag }} {{ cargo-cmd }} check -p hyperlight-host --features hw-interrupts {{ target-triple-flag }} @@ -587,8 +586,8 @@ coverage-run hypervisor="kvm": ensure-cargo-llvm-cov # tests with default features (all drivers; skip stress tests — too slow under instrumentation) cargo +{{nightly-toolchain}} test {{ coverage-packages }} --tests -- --skip stress_test - # tests with single driver + build-metadata - cargo +{{nightly-toolchain}} test {{ coverage-packages }} --no-default-features --features build-metadata,{{ if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }} --tests -- --skip stress_test + # tests with single driver + cargo +{{nightly-toolchain}} test {{ coverage-packages }} --no-default-features --features {{ if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }} --tests -- --skip stress_test # isolated tests (require running separately due to global state) cargo +{{nightly-toolchain}} test -p hyperlight-host --lib -- sandbox::uninitialized::tests::test_log_trace --exact --ignored diff --git a/docs/how-to-run-coverage.md b/docs/how-to-run-coverage.md index 7d2b410384..31b3072f45 100644 --- a/docs/how-to-run-coverage.md +++ b/docs/how-to-run-coverage.md @@ -98,8 +98,8 @@ We use [cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) over alternat The `coverage-run` recipe mirrors the `test-like-ci` + `run-examples-like-ci` workflows by running all test phases and examples with different feature combinations: -1. **Default features** — all drivers enabled (kvm + mshv3 + build-metadata) -2. **Single driver** — only one hypervisor driver + build-metadata +1. **Default features** — all drivers enabled (kvm + mshv3) +2. **Single driver** — only one hypervisor driver 3. **Isolated tests** — tests that require running separately due to global state 4. **Integration tests** — including `executable_heap` feature 5. **Crashdump** — tests + example with the `crashdump` feature enabled diff --git a/hack/clippy-package-features.sh b/hack/clippy-package-features.sh index 49b6716b81..fc0b1b0143 100755 --- a/hack/clippy-package-features.sh +++ b/hack/clippy-package-features.sh @@ -37,7 +37,7 @@ fi EXCLUDED_FEATURES=("${REQUIRED_FEATURES[@]}") if [[ -n "${TARGET_TRIPLE}" && "$TARGET_TRIPLE" =~ aarch64 ]] || [[ -z "${TARGET_TRIPLE}" && "$(uname -m)" = "aarch64" ]]; then - EXCLUDED_FEATURES+=("crashdump" "trace_guest" "mem_profile" "hw-interrupts" "gdb" "i686-guest" "nanvix-unstable") + EXCLUDED_FEATURES+=("crashdump" "trace_guest" "mem_profile" "hw-interrupts" "gdb") fi # Get all features for the package (excluding default and required features) diff --git a/src/hyperlight_common/Cargo.toml b/src/hyperlight_common/Cargo.toml index 3ea678ecf5..975b102069 100644 --- a/src/hyperlight_common/Cargo.toml +++ b/src/hyperlight_common/Cargo.toml @@ -35,7 +35,7 @@ tracing = ["dep:tracing"] fuzzing = ["dep:arbitrary"] trace_guest = [] mem_profile = [] -std = ["thiserror/std", "log/std", "tracing/std"] +std = ["thiserror/std", "log/std", "tracing?/std"] [dev-dependencies] criterion = "0.8.1" diff --git a/src/hyperlight_guest_bin/Cargo.toml b/src/hyperlight_guest_bin/Cargo.toml index 6c6f86efe1..f1af7f3e65 100644 --- a/src/hyperlight_guest_bin/Cargo.toml +++ b/src/hyperlight_guest_bin/Cargo.toml @@ -15,7 +15,7 @@ and third-party code used by our C-API needed to build a native hyperlight-guest [features] default = ["libc", "macros"] libc = ["dep:hyperlight-libc"] # compile libc from picolibc -trace_guest = ["hyperlight-common/trace_guest", "hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"] +trace_guest = ["hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"] mem_profile = ["hyperlight-common/mem_profile"] macros = ["dep:hyperlight-guest-macro", "dep:linkme"] diff --git a/src/hyperlight_host/Cargo.toml b/src/hyperlight_host/Cargo.toml index bbaa1663f5..db6a806558 100644 --- a/src/hyperlight_host/Cargo.toml +++ b/src/hyperlight_host/Cargo.toml @@ -122,16 +122,13 @@ proc-maps = "0.5.0" [build-dependencies] anyhow = { version = "1.0.102" } cfg_aliases = "0.2.1" -built = { version = "0.8.1", optional = true, features = ["chrono", "git2"] } bindgen = { version = "0.72", features = ["prettyplease"] } cc = "1.2" [features] -default = ["kvm", "mshv3", "hvf", "build-metadata"] +default = ["kvm", "mshv3", "hvf"] function_call_metrics = [] executable_heap = [] -# This feature enables printing of debug information to stdout in debug builds -print_debug = [] # Dumps the VM state to a file on unexpected errors or crashes. The path of the file will be printed on stdout and logged. crashdump = ["dep:chrono", "dep:elfcore"] trace_guest = ["dep:opentelemetry", "dep:tracing-opentelemetry", "dep:hyperlight-guest-tracing", "hyperlight-common/trace_guest"] @@ -143,7 +140,6 @@ hw-interrupts = [] # This enables easy debug in the guest gdb = ["dep:gdbstub", "dep:gdbstub_arch"] fuzzing = ["hyperlight-common/fuzzing"] -build-metadata = ["dep:built"] [[bench]] name = "benchmarks" diff --git a/src/hyperlight_host/build.rs b/src/hyperlight_host/build.rs index 6326b429d2..41c9b1908f 100644 --- a/src/hyperlight_host/build.rs +++ b/src/hyperlight_host/build.rs @@ -2,8 +2,6 @@ // Copyright 2025 The Hyperlight Authors. use anyhow::{Context, Result}; -#[cfg(feature = "build-metadata")] -use built::write_built_file; fn main() -> Result<()> { // re-run the build if this script is changed (or deleted!), @@ -155,8 +153,6 @@ fn main() -> Result<()> { mshv3: { all(feature = "mshv3", target_os = "linux") }, hvf: { all(feature = "hvf", target_os = "macos") }, crashdump: { all(feature = "crashdump", target_arch = "x86_64") }, - // print_debug feature is aliased with debug_assertions to make it only available in debug-builds. - print_debug: { all(feature = "print_debug", debug_assertions) }, // the gdb feature (only temporarily!) needs to use // writable/un-shared snapshot memories. unshared_snapshot_mem: { gdb }, @@ -176,8 +172,5 @@ fn main() -> Result<()> { readable_shared_mem: { any(gdb, all(feature = "mem_profile", not(unshared_snapshot_mem))) }, } - #[cfg(feature = "build-metadata")] - write_built_file()?; - Ok(()) } diff --git a/src/hyperlight_host/src/lib.rs b/src/hyperlight_host/src/lib.rs index afd9ade1f9..1bbe61ed85 100644 --- a/src/hyperlight_host/src/lib.rs +++ b/src/hyperlight_host/src/lib.rs @@ -26,16 +26,6 @@ #![cfg_attr(not(any(test, debug_assertions)), warn(clippy::expect_used))] #![cfg_attr(not(any(test, debug_assertions)), warn(clippy::unwrap_used))] -#[cfg(feature = "build-metadata")] -use std::sync::Once; - -#[cfg(feature = "build-metadata")] -/// The `built` crate is used to generate a `built.rs` file that contains -/// information about the build environment. This information is used to -/// populate the `built_info` module, which is re-exported here. -pub(crate) mod built_info { - include!(concat!(env!("OUT_DIR"), "/built.rs")); -} /// Dealing with errors, including errors across VM boundaries pub mod error; /// Wrappers for host and guest functions. @@ -135,67 +125,3 @@ macro_rules! log_then_return { return Err(__err); }; } - -/// Same as tracing::debug!, but will additionally print to stdout if the print_debug feature is enabled -#[macro_export] -macro_rules! debug { - ($($arg:tt)+) => - { - #[cfg(print_debug)] - println!($($arg)+); - tracing::debug!($($arg)+); - } -} - -// LOG_ONCE is used to log information about the crate version once -#[cfg(feature = "build-metadata")] -static LOG_ONCE: Once = Once::new(); - -#[cfg(feature = "build-metadata")] -pub(crate) fn log_build_details() { - use tracing::info; - LOG_ONCE.call_once(|| { - info!("Package name: {}", built_info::PKG_NAME); - info!("Package version: {}", built_info::PKG_VERSION); - info!("Package features: {:?}", built_info::FEATURES); - info!("Target triple: {}", built_info::TARGET); - info!("Optimization level: {}", built_info::OPT_LEVEL); - info!("Profile: {}", built_info::PROFILE); - info!("Debug: {}", built_info::DEBUG); - info!("Rustc: {}", built_info::RUSTC); - info!("Built at: {}", built_info::BUILT_TIME_UTC); - match built_info::CI_PLATFORM.unwrap_or("") { - "" => info!("Not built on a CI platform"), - other => info!("Built on : {}", other), - } - match built_info::GIT_COMMIT_HASH.unwrap_or("") { - "" => info!("No git commit hash found"), - other => info!("Git commit hash: {}", other), - } - - let git = match built_info::GIT_HEAD_REF.unwrap_or("") { - "" => { - info!("No git head ref found"); - false - } - other => { - info!("Git head ref: {}", other); - true - } - }; - match built_info::GIT_VERSION.unwrap_or("") { - "" => info!("No git version found"), - other => info!("Git version: {}", other), - } - match built_info::GIT_DIRTY.unwrap_or(false) { - true => info!("Repo had uncommitted changes"), - false => { - if git { - info!("Repo had no uncommitted changes") - } else { - info!("No git repo found") - } - } - } - }); -} diff --git a/src/hyperlight_host/src/sandbox/trace/context.rs b/src/hyperlight_host/src/sandbox/trace/context.rs index e6eb677c63..bbd164a36c 100644 --- a/src/hyperlight_host/src/sandbox/trace/context.rs +++ b/src/hyperlight_host/src/sandbox/trace/context.rs @@ -347,7 +347,7 @@ impl TraceContext { pub(crate) fn setup_guest_trace(&mut self, ctx: Context) { if self.start_instant.is_none() { - crate::debug!("Guest Start Epoch set"); + tracing::debug!("Guest Start Epoch set"); self.start_wall = Some(SystemTime::now()); self.start_tsc = Some(hyperlight_guest_tracing::invariant_tsc::read_tsc()); self.start_instant = Some(std::time::Instant::now()); diff --git a/src/hyperlight_host/src/sandbox/uninitialized.rs b/src/hyperlight_host/src/sandbox/uninitialized.rs index bf6e3198be..07051e0835 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized.rs @@ -14,8 +14,6 @@ use super::snapshot::Snapshot; use super::uninitialized_evolve::initialize_sandbox; use crate::func::host_functions::{HostFunction, register_host_function}; use crate::func::{ParameterTuple, SupportedReturnType}; -#[cfg(feature = "build-metadata")] -use crate::log_build_details; use crate::mem::memory_region::{DEFAULT_GUEST_BLOB_MEM_FLAGS, MemoryRegionFlags}; use crate::mem::mgr::SandboxMemoryManager; use crate::mem::shared_mem::{ExclusiveSharedMemory, SharedMemory}; @@ -142,9 +140,6 @@ impl UninitializedSandbox { // // This is ok for now as this is not a public function fn from_snapshot(snapshot: Arc, cfg: Option) -> Result { - #[cfg(feature = "build-metadata")] - log_build_details(); - // hyperlight is only supported on Windows 11 and Windows Server 2022 and later #[cfg(target_os = "windows")] check_windows_version()?; @@ -165,7 +160,7 @@ impl UninitializedSandbox { pending_file_mappings: Vec::new(), }; - crate::debug!("Sandbox created: {:#?}", sandbox); + tracing::debug!("Sandbox created: {:#?}", sandbox); Ok(sandbox) } @@ -794,7 +789,6 @@ mod tests { /// our subscriber's `Interest::sometimes()` /// 3. Clear recorded state and run the real test #[test] - #[cfg(feature = "build-metadata")] fn test_trace_trace() { use hyperlight_testing::tracing_subscriber::TracingSubscriber; use tracing::Level; @@ -905,7 +899,6 @@ mod tests { #[ignore] // Tests that traces are emitted as log records when there is no trace // subscriber configured. - #[cfg(feature = "build-metadata")] fn test_log_trace() { use std::path::PathBuf; diff --git a/src/hyperlight_libc/Cargo.toml b/src/hyperlight_libc/Cargo.toml index 4050820080..a28784f64a 100644 --- a/src/hyperlight_libc/Cargo.toml +++ b/src/hyperlight_libc/Cargo.toml @@ -13,9 +13,6 @@ This crate provides picolibc for Hyperlight guests. It builds the picolibc library and generates bindings to the libc types and functions. """ -[features] -default = [] - [dependencies] [lints] diff --git a/src/tests/rust_guests/dummyguest/Cargo.toml b/src/tests/rust_guests/dummyguest/Cargo.toml index 6ef29a7417..fca18bf8a6 100644 --- a/src/tests/rust_guests/dummyguest/Cargo.toml +++ b/src/tests/rust_guests/dummyguest/Cargo.toml @@ -11,4 +11,4 @@ hyperlight-common = { path = "../../../hyperlight_common", default-features = fa [features] default = [] trace_guest = ["hyperlight-guest-bin/trace_guest"] -mem_profile = ["hyperlight-common/mem_profile", "hyperlight-guest-bin/mem_profile"] +mem_profile = ["hyperlight-guest-bin/mem_profile"] diff --git a/src/tests/rust_guests/simpleguest/Cargo.toml b/src/tests/rust_guests/simpleguest/Cargo.toml index 456d312194..d683801116 100644 --- a/src/tests/rust_guests/simpleguest/Cargo.toml +++ b/src/tests/rust_guests/simpleguest/Cargo.toml @@ -13,6 +13,6 @@ tracing = { version = "0.1.41", default-features = false, features = ["log", "at [features] default = [] -trace_guest = ["hyperlight-guest-bin/trace_guest", "hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"] -mem_profile = ["hyperlight-common/mem_profile", "hyperlight-guest-bin/mem_profile"] +trace_guest = ["hyperlight-guest-bin/trace_guest"] +mem_profile = ["hyperlight-guest-bin/mem_profile"] diff --git a/src/tests/rust_guests/witguest/Cargo.toml b/src/tests/rust_guests/witguest/Cargo.toml index d1fe284643..51b75f0f4b 100644 --- a/src/tests/rust_guests/witguest/Cargo.toml +++ b/src/tests/rust_guests/witguest/Cargo.toml @@ -12,5 +12,5 @@ spin = "0.12.0" [features] default = [] -trace_guest = ["hyperlight-guest-bin/trace_guest", "hyperlight-guest/trace_guest"] -mem_profile = ["hyperlight-common/mem_profile", "hyperlight-guest-bin/mem_profile"] +trace_guest = ["hyperlight-guest-bin/trace_guest"] +mem_profile = ["hyperlight-guest-bin/mem_profile"]