-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8e7965
commit b77af14
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Building and testing the Rust bindings | ||
|
||
These instructions require cargo and rustc. | ||
To get these follow the instructions at [https://rustup.rs](https://rustup.rs) | ||
The instructions compile the onnxruntime along with the bindings, | ||
so require `cmake`, a python 3 interpreter and gcc c++ compiler. | ||
|
||
## Local setup of onnxruntime repo | ||
|
||
```sh | ||
git clone https://github.com/microsoft/onnxruntime | ||
cd onnxruntime | ||
git submodule update --init --recursive | ||
``` | ||
|
||
## cargo build both crates | ||
|
||
from the root of onnxruntime repo | ||
|
||
```sh | ||
CARGO_TARGET_DIR=build/rust cargo build --manifest-dir rust/Cargo.toml | ||
``` | ||
|
||
The CARGO_TARGET_DIR environment variable puts the build artifacts in `onnxruntime/build/rust` | ||
instead of `onnxruntime/rust/target`. | ||
|
||
## cargo test both crates | ||
|
||
```sh | ||
CARGO_TARGET_DIR=build/rust cargo test --manifest-dir rust/Cargo.toml --features model-fetching | ||
``` | ||
|
||
## cargo test with sanitizer support | ||
|
||
**If you are using a nightly Rust compiler and are on one the platforms listed in [Rust sanitizer support](https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html).** | ||
|
||
where `$SAN` is one of `address`, `thread`, `memory` or `leak` | ||
|
||
```sh | ||
RUSTFLAGS="-Zsanitizer=$SAN" CARGO_TARGET_DIR=build/rust cargo test --manifest-dir rust/Cargo.toml --features model-fetching --target <your target for example x86_64-unknown-linux-gnu> -Z build-std -- --test-threads=1 | ||
``` |