Skip to content

Commit

Permalink
Only support sim in test_enclave
Browse files Browse the repository at this point in the history
Previously the `test_enclave` had a `sim` feature.  The `sim` feature
was used to build the `test_enclave` in a sim environment.  Cargo
currently doesn't support feature propagation to _only_ dev
dependencies. Always propagating `sim` to the `test_enclave` resulted in
failures to package `mc-sgx-urts` as `mc-sgx-urts` was now looking for a
published version of `test_enclave`.  Now `test_enclave` will only build
for the simulation SGX SDK, there is no feature flag to add or remove
this.
  • Loading branch information
nick-mobilecoin committed Oct 10, 2022
1 parent a5578ab commit 9dafcbe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 0 additions & 1 deletion test_enclave/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ mc-sgx-urts-sys-types = { path = "../urts/sys/types" }

[features]
default = []
sim = []

[build-dependencies]
bindgen = "0.60.1"
Expand Down
4 changes: 2 additions & 2 deletions test_enclave/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Provides a simple enclave that can be used to exercise the SGX SDK for creating
an enclave and for calling into functions in the enclave.

This crate supports testing with the hardware as well as the simulation SGX
SDKs. To test with the simulation SDKs use the `sim` feature.
At this time, this crate only supports testing with the simulation SGX
SDKs.

This crate can be added to the development dependency of the crate to test the
creation of enclaves with.
Expand Down
18 changes: 10 additions & 8 deletions test_enclave/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,15 @@ fn build_dynamic_enclave_binary<P: AsRef<Path>>(
) -> PathBuf {
let mut dynamic_enclave = PathBuf::from(static_enclave.as_ref());
dynamic_enclave.set_extension("so");
let sgx_suffix = mc_sgx_core_build::sgx_library_suffix();
let trts = format!("-lsgx_trts{}", sgx_suffix);
let tservice = format!("-lsgx_tservice{}", sgx_suffix);

// TODO: IFF the test enclave persists this will need to be updated to
// handle hw builds. Currently only doing sim builds as there were issues
// propagating the `sim` feature to this package, `test_enclave`,
// conditionally
let sgx_suffix = "sim";
let trts = format!("-lsgx_trts_{}", sgx_suffix);
let tservice = format!("-lsgx_tservice_{}", sgx_suffix);
let pcl = format!("-lsgx_pcl{}", sgx_suffix);

let link_string = mc_sgx_core_build::sgx_library_string();
let cve_link_string = mc_sgx_core_build::sgx_library_dir()
Expand All @@ -212,11 +218,7 @@ fn build_dynamic_enclave_binary<P: AsRef<Path>>(
.arg("--whole-archive")
.arg(&trts);
if let Some(_) = keyfile {
if cfg!(feature = "sim") {
command.arg("-lsgx_pclsim");
} else {
command.arg("-lsgx_pcl");
}
command.arg(pcl);
}
command
.arg("--no-whole-archive")
Expand Down
2 changes: 1 addition & 1 deletion urts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mc-sgx-urts-sys-types = { path = "sys/types", version = "=0.2.1-pre" }
mc-sgx-util = { path = "../util", version = "=0.2.1-pre" }

[features]
sim = ["mc-sgx-urts-sys/sim", "test_enclave/sim"]
sim = ["mc-sgx-urts-sys/sim"]
default = []

[dev-dependencies]
Expand Down

0 comments on commit 9dafcbe

Please sign in to comment.