29 lines
1.0 KiB
Markdown
29 lines
1.0 KiB
Markdown
# Use Rust with Occlum
|
|
|
|
This directory contains scripts and source code to demonstrate how to
|
|
compile and run Rust programs on Occlum.
|
|
|
|
## occlum-cargo and occlum-rustc
|
|
|
|
We introduce cargo and rustc wrappers called occlum-cargo and occlum-rustc
|
|
respectively. They wrap the original commands with options specific to occlum.
|
|
Refer to tools/toolchains/rust/build.sh for more information.
|
|
|
|
## rust\_app
|
|
|
|
This directory contains source code of a Rust program with two test cases. One is a cpp FFI test,
|
|
where the cpp interface increments the input by one. The other is a multithreading file backed mmap test.
|
|
Rust code calls the function and displays the result on the terminal.
|
|
|
|
One can use occlum-cargo in the way cargo is used. In the rust\_app directory,
|
|
calling ```occlum-cargo build``` will build the demo and ```occlum-cargo run```
|
|
will run the demo on host. To run the demo in occlum, run:
|
|
```
|
|
run_rust_demo_on_occlum.sh
|
|
```
|
|
The output will be displayed on the terminal:
|
|
```
|
|
Cpp FFI test passed!
|
|
Multithreading mmap test passed!
|
|
```
|