Build rust guests without hyperlight-libc#1505
Open
ludfjig wants to merge 1 commit into
Open
Conversation
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces Rust guest dependencies by allowing hyperlight-guest-bin to be used without its default libc feature (and therefore without pulling in hyperlight-libc/picolibc) when the guest doesn’t need C/POSIX support.
Changes:
- Gate the
srandextern declaration and call ingeneric_initbehind#[cfg(feature = "libc")]. - Update Rust test guests (
simpleguest,dummyguest,witguest) to depend onhyperlight-guest-binwithdefault-features = false(re-enabling onlymacroswhere needed). - Refresh the nested
src/tests/rust_guests/Cargo.lockto reflect the reduced dependency graph (droppinghyperlight-libcand its transitive build deps).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/hyperlight_guest_bin/src/lib.rs | Makes srand usage conditional on the libc feature to avoid requiring picolibc when not needed. |
| src/tests/rust_guests/simpleguest/Cargo.toml | Disables default features for hyperlight-guest-bin and explicitly enables macros for macro usage. |
| src/tests/rust_guests/dummyguest/Cargo.toml | Disables default features for hyperlight-guest-bin to avoid transitive hyperlight-libc. |
| src/tests/rust_guests/witguest/Cargo.toml | Disables default features for hyperlight-guest-bin to avoid transitive hyperlight-libc. |
| src/tests/rust_guests/Cargo.lock | Updates lockfile to remove hyperlight-libc and related build dependencies from the guest workspace graph. |
Comments suppressed due to low confidence (1)
src/hyperlight_guest_bin/src/lib.rs:232
generic_initrenamesseedto_seed, but the value is still used whenfeature = "libc"is enabled. This can trigger theused_underscore_bindingwarning (and CI runs clippy with-D warningsforhyperlight-guest-binwith--features libc). Prefer keeping the parameter namedseedand explicitly marking it as used only in the non-libc configuration.
pub(crate) extern "C" fn generic_init(
peb_address: u64,
_seed: u64,
ops: u64,
max_log_level: u64,
) -> u64 {
unsafe {
GUEST_HANDLE = GuestHandle::init(peb_address as *mut HyperlightPEB);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rust guests transitively depend on hyperlight-libc (picolibc) through hyperlight-guest-bin's default libc feature. The only reason the dependency was needed was an unconditional call to picolibc's srand in generic_init. The Rust guests themselves never use it.
This PR:
I am also strongly considering making cargo feature libc a non-default cargo feature of hyperlight-guest-bin, since I am guessing most people who write rust guests do not need hyperlight-libc, but would appreciate more thoughts/feedback on that.
Closes #1483