fortanix / rust-sgx

The Fortanix Rust Enclave Development Platform
https://edp.fortanix.com
Mozilla Public License 2.0
442 stars 98 forks source link

Could not compile `dcap-ql`: cargo install sgxs-tools failed #176

Open jithendaraa opened 5 years ago

jithendaraa commented 5 years ago

I was trying to setup fortanix SGX EDP and encountered the following after running cargo install sgxs-tools:

error[E0432]: unresolved import sgxs_loaders::sgx_enclave_common::dl::os::unix::Library --> C:\Users\jithe.cargo\registry\src\github.com-1ecc6299db9ec823\dcap-ql-0.2.0\src\lib.rs:31:5 use sgxs_loaders::sgx_enclave_common::dl::os::unix::Library as Dl; no Library in sgx_enclave_common::dl::os::unix error[E0432]: unresolved imports libc::RTLD_GLOBAL, libc::RTLD_NOW --> C:\Users\jithe.cargo\registry\src\github.com-1ecc6299db9ec823\dcap-ql-0.2.0\src\dl.rs:3:12 use libc::{RTLD_GLOBAL, RTLD_NOW}; no RTLD_GLOBAL in the root error[E0432]: unresolved import sgxs_loaders::sgx_enclave_common::dl::os::unix::Library --> C:\Users\jithe.cargo\registry\src\github.com-1ecc6299db9ec823\dcap-ql-0.2.0\src\dl.rs:8:5 use sgxs_loaders::sgx_enclave_common::dl::os::unix::Library as Dl; no Library in sgx_enclave_common::dl::os::unix error: aborting due to 3 previous errors

For more information about this error, try rustc --explain E0432. error: Could not compile dcap-ql. warning: build failed, waiting for other jobs to finish... error: failed to compile sgxs-tools v0.7.0, intermediate artifacts can be found at C:\Users\jithe\AppData\Local\Temp\cargo-installO8Gt63

Caused by: build failed

jethrogb commented 5 years ago

Looks like we're trying to build some stuff that can only be built on Linux.

@parthsane can you look into what it would take to make this crate work on Windows?

@jithendaraa Can you try the following:

  1. clone this git repository
  2. apply this patch

    diff --git a/sgxs-tools/Cargo.toml b/sgxs-tools/Cargo.toml
    index fe25101..d1407c5 100644
    --- a/sgxs-tools/Cargo.toml
    +++ b/sgxs-tools/Cargo.toml
    @@ -26,6 +26,7 @@ required-features = ["pe2sgxs"]
    [[bin]]
    name = "sgx-detect"
    path = "src/sgx_detect/main.rs"
    +required-features = ["nope"]
    
    [dependencies]
    # Project dependencies
    @@ -33,7 +34,6 @@ path = "src/sgx_detect/main.rs"
    "sgxs-loaders" = { version = "0.2.0", path = "../sgxs-loaders" }
    "aesm-client" = { version = "0.2.0", path = "../aesm-client", features = ["sgxs"] }
    "sgx-isa" = { version = "0.3.0", path = "../sgx-isa" }
    -"dcap-ql" = { version = "0.2.0", path = "../dcap-ql" }
    "report-test" = { version = "0.2.0", path = "../report-test" }
    "enclave-runner" = { version = "0.2.0", path = "../enclave-runner" }
  3. Run these commands:
    cd sgxs-tools
    cargo install .
jithendaraa commented 5 years ago

@jethrogb I tried applying the above patch to rust-sgx/sgxs-tools/cargo.toml

After I cd into sgxs-tools and run cargo install ., I get the following error:

Updating crates.io index error: could not find . in registry https://github.com/rust-lang/crates.io-index Is there somewhere I'm going wrong and is this something that can't build on Windows 10?

jethrogb commented 5 years ago

Maybe it's just cargo install

jithendaraa commented 5 years ago

When I ran cargo install, it suggested me to run cargo install --path . or cargo buildinstead.

On running cargo install --path ., I got a bunch of warnings and this error: error[E0432]: unresolved import sgxs_loaders::sgx_enclave_common::dl::os::unix::Library --> C:\Users\jithe.cargo\registry\src\github.com-1ecc6299db9ec823\dcap-ql-0.2.0\src\lib.rs:31:5 | 31 | use sgxs_loaders::sgx_enclave_common::dl::os::unix::Library as Dl; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no Library in sgx_enclave_common::dl::os::unix

error[E0432]: unresolved imports libc::RTLD_GLOBAL, libc::RTLD_NOW --> C:\Users\jithe.cargo\registry\src\github.com-1ecc6299db9ec823\dcap-ql-0.2.0\src\dl.rs:3:12 3 use libc::{RTLD_GLOBAL, RTLD_NOW}; ^^^^^^^^^^^ ^^^^^^^^ no RTLD_NOW in the root
no RTLD_GLOBAL in the root

error[E0432]: unresolved import sgxs_loaders::sgx_enclave_common::dl::os::unix::Library --> C:\Users\jithe.cargo\registry\src\github.com-1ecc6299db9ec823\dcap-ql-0.2.0\src\dl.rs:8:5 | 8 | use sgxs_loaders::sgx_enclave_common::dl::os::unix::Library as Dl; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no Library in sgx_enclave_common::dl::os::unix

error: aborting due to 3 previous errors

For more information about this error, try rustc --explain E0432. error: Could not compile dcap-ql. warning: build failed, waiting for other jobs to finish... error: failed to compile sgxs-tools v0.7.0, intermediate artifacts can be found at C:\Users\jithe\AppData\Local\Temp\cargo-installPLGZLg

On running cargo build, I got a bunch of warnings and this error:

error[E0432]: unresolved import sgxs_loaders::isgx --> sgxs-tools\src\bin\sgxs-load.rs:22:5 | 22 | use sgxs_loaders::isgx; | ^^^^^^^^^^^^^^^^^^ no isgx in the root

warning: unused import: Load --> sgxs-tools\src\bin\sgxs-load.rs:20:20 20 use sgxs::loader::{Load, Tcs}; ^^^^

= note: #[warn(unused_imports)] on by default

error: aborting due to previous error

For more information about this error, try rustc --explain E0432. error: Could not compile sgxs-tools. warning: build failed, waiting for other jobs to finish... error: failed to compile sgxs-tools v0.7.0 (C:\Users\jithe\rust-sgx\sgxs-tools), intermediate artifacts can be found at C:\Users\jithe\rust-sgx\target

Caused by: build failed

Is there something I can do about this?