Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use (Linux) #49

Closed
jethrogb opened this issue Dec 28, 2018 · 5 comments
Closed

How to use (Linux) #49

jethrogb opened this issue Dec 28, 2018 · 5 comments

Comments

@jethrogb
Copy link
Member

jethrogb commented Dec 28, 2018

This issue documents the current best way to build for x86_64-fortanix-unknown-sgx and run the enclaves on Linux. Subscribe to this issue to be notified of changes.

Installing build dependencies

Install Rust nightly

You will need Rust nightly installed, the easiest way is with rustup:

rustup default nightly

Building

Run Cargo

Build your crate for the x86_64-fortanix-unknown-sgx target, for example:

cargo build --target x86_64-fortanix-unknown-sgx

or

cargo test --target x86_64-fortanix-unknown-sgx --no-run

Installing runtime dependencies

Install SGX driver & software

Install SGX pre-requisites. In order to test execution, you'll need to have a CPU with Intel SGX support. SGX support needs to be enabled in the BIOS. You'll also need to install the SGX driver and Platform Software (PSW) from Intel.

Install enclave conversion utilities & runtime

cargo install sgxs-tools --version 0.6.0-rc1
cargo install fortanix-sgx-tools --git https://github.com/fortanix/rust-sgx

Running

To run any binary $BINARY (you can find these in target/x86_64-fortanix-unknown-sgx/debug after building), do:

ftxsgx-elf2sgxs $BINARY --debug --threads 1 --heap-size 0x20000 --ssaframesize 1 --stack-size 0x20000
sgxs-append -i $BINARY.sgxs
ftxsgx-runner $BINARY.sgxs

Depending on your application, you might want to increase the stack or heap size or the number of threads.

@jethrogb
Copy link
Member Author

jethrogb commented Jan 8, 2019

With nightly-2019-01-08 or newer, you no longer need a patched compiler-builtins or xargo. Updated instructions above.

@jethrogb
Copy link
Member Author

Use nightly-2019-01-08 (not newer) for now

bors bot added a commit that referenced this issue Jan 14, 2019
53: runner script r=jethrogb a=akash-fortanix

This script encapsulates the three steps listed [here](#49) under `Running`.

To trigger this script on `cargo run`, add .cargo/config file within crate with content:

> [target.x86_64-fortanix-unknown-sgx]
> runner = "ftxsgx-runner-cargo"

And to set custom values for arguments to `ftxsgx-elf2sgxs` script, add `package.metadata` section in Cargo.toml

> [package.metadata]
> threads=15

Co-authored-by: akashfortanix <akash.anand@fortanix.com>
@jethrogb
Copy link
Member Author

jethrogb commented Jan 21, 2019

Xargo is no longer needed. To stop using it:

  • Update to the latest nightly: rustup update nightly
  • Add pre-compiled Fortanix target: rustup target add x86_64-fortanix-unknown-sgx --toolchain nightly
  • Use cargo instead of xargo (e.g. cargo build --target x86_64-fortanix-unknown-sgx)
  • Delete your Xargo.toml file
  • (optional) Uninstall Xargo: cargo uninstall xargo

The instructions above have been updated as well.

@jethrogb
Copy link
Member Author

Also, you no longer need to manually build libuwind so you can remove libunwind.a and the source tree as well.

@jethrogb
Copy link
Member Author

jethrogb commented Feb 4, 2019

Closing this in favor of the installation guide.

@jethrogb jethrogb closed this as completed Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant