Skip to content

Commit dfe87a7

Browse files
Copilotjsturtevant
andcommitted
Fix README.md examples based on feedback - remove hardcoded paths, unused imports, type errors, and add cargo config info
Co-authored-by: jsturtevant <[email protected]>
1 parent cdc70b0 commit dfe87a7

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use hyperlight_host::{MultiUseSandbox, UninitializedSandbox};
4242
fn main() -> hyperlight_host::Result<()> {
4343
// Create an uninitialized sandbox with a guest binary
4444
let mut uninitialized_sandbox = UninitializedSandbox::new(
45-
hyperlight_host::GuestBinary::FilePath(hyperlight_testing::simple_guest_as_string().unwrap()),
45+
hyperlight_host::GuestBinary::FilePath("path/to/your/guest/binary".to_string()),
4646
None // default configuration
4747
)?;
4848

@@ -88,7 +88,7 @@ use hyperlight_common::flatbuffer_wrappers::util::get_flatbuffer_result;
8888
use hyperlight_guest::error::{HyperlightGuestError, Result};
8989
use hyperlight_guest_bin::guest_function::definition::GuestFunctionDefinition;
9090
use hyperlight_guest_bin::guest_function::register::register_function;
91-
use hyperlight_guest_bin::host_comm::{call_host_function, call_host_function_without_returning_result};
91+
use hyperlight_guest_bin::host_comm::call_host_function;
9292

9393
fn print_output(function_call: &FunctionCall) -> Result<Vec<u8>> {
9494
if let ParameterValue::String(message) = function_call.parameters.clone().unwrap()[0].clone() {
@@ -112,7 +112,7 @@ pub extern "C" fn hyperlight_main() {
112112
"PrintOutput".to_string(),
113113
Vec::from(&[ParameterType::String]),
114114
ReturnType::Int,
115-
print_output as i64,
115+
print_output as usize,
116116
);
117117
register_function(print_output_def);
118118
}
@@ -127,6 +127,28 @@ pub fn guest_dispatch_function(function_call: FunctionCall) -> Result<Vec<u8>> {
127127
}
128128
```
129129

130+
**Note**: Guest applications require a specific build configuration. Create a `.cargo/config.toml` file in your guest project with the following content:
131+
132+
```toml
133+
[build]
134+
target = "x86_64-unknown-none"
135+
136+
[target.x86_64-unknown-none]
137+
rustflags = [
138+
"-C",
139+
"code-model=small",
140+
"-C",
141+
"link-args=-e entrypoint",
142+
]
143+
linker = "rust-lld"
144+
145+
[profile.release]
146+
panic = "abort"
147+
148+
[profile.dev]
149+
panic = "abort"
150+
```
151+
130152
For additional examples of using the Hyperlight host Rust library, see
131153
the [./src/hyperlight_host/examples](./src/hyperlight_host/examples) directory.
132154

0 commit comments

Comments
 (0)