fortanix / rust-sgx

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

`cargo install sgxs-tools` fails to compile `enclave-runner` on Windows 10 #438

Open ColinGreybosh opened 1 year ago

ColinGreybosh commented 1 year ago

Running cargo install sgxs-tools --git https://github.com/fortanix/rust-sgx on Windows 10 results in a compilation failure due to dead code.

Inspecting mod.rs:789 reveals that the usercall variable is only used on Linux compilation targets, and the tcs_address method is left unused as usercall.tcs_address() a few lines down is only compiled on Linux targets too. The produced errors are the following:

error: unused variable: `usercall`
   --> intel-sgx\enclave-runner\src\usercalls\mod.rs:789:46
    |
789 |                     UsercallHandleData::Sync(usercall, _, debug_buf) => {
    |                                              ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_usercall`
    |
note: the lint level is defined here
   --> intel-sgx\enclave-runner\src\lib.rs:7:9
    |
7   | #![deny(warnings)]
    |         ^^^^^^^^
    = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]`

error: method `tcs_address` is never used
  --> intel-sgx\enclave-runner\src\tcs.rs:47:12
   |
34 | impl<T: Tcs> Usercall<T> {
   | ------------------------ method in this implementation
...
47 |     pub fn tcs_address(&self) -> *mut c_void {
   |            ^^^^^^^^^^^
   |
   = note: `#[deny(dead_code)]` implied by `#[deny(warnings)]`

error: could not compile `enclave-runner` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `sgxs-tools v0.8.6 (https://github.com/fortanix/rust-sgx#04037689)`, intermediate artifacts can be found at `$HOME$\AppData\Local\Temp\cargo-installg4xmFG`

EDIT: After some testing, it looks like installing sgxs-tools is broken further down as well.

This following assembly is not valid when using the nightly-x86_64-pc-windows-msvc toolchain and targeting x86_64-pc-windows-msvc:

error: expected absolute expression
   --> intel-sgx\enclave-runner\src\tcs.rs:145:1
    |
145 | .type __vdso_sgx_enter_enclave, function
    | ^
    |
note: instantiated into assembly here
   --> <inline asm>:5:7
    |
5   | .type __vdso_sgx_enter_enclave, function
    |       ^

error: could not compile `enclave-runner` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `sgxs-tools v0.8.6 (https://github.com/colingreybosh/rust-sgx#dabe58cb)`, intermediate artifacts can be found at `$HOME$\AppData\Local\Temp\cargo-installUqbnjW`

Assuming these previous errors are fixed, cargo install sgxs-tools once again fails when compiling proc-mounts as (I assume) it expects a unix target:

error[E0433]: failed to resolve: could not find `unix` in `os`
 --> C:\Users\Colin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-mounts-0.2.4\src\mounts\info.rs:7:9
  |
7 |     os::unix::ffi::OsStringExt,
  |         ^^^^ could not find `unix` in `os`

error[E0433]: failed to resolve: could not find `unix` in `os`
 --> C:\Users\Colin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-mounts-0.2.4\src\mounts\list.rs:4:9
  |
4 |     os::unix::ffi::OsStrExt,
  |         ^^^^ could not find `unix` in `os`

error[E0433]: failed to resolve: could not find `unix` in `os`
 --> C:\Users\Colin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-mounts-0.2.4\src\swaps.rs:7:9
  |
7 |     os::unix::ffi::OsStringExt,
  |         ^^^^ could not find `unix` in `os`

error[E0599]: no function or associated item named `from_vec` found for struct `OsString` in the current scope
   --> C:\Users\Colin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-mounts-0.2.4\src\mounts\info.rs:130:22
    |
130 |         Ok(OsString::from_vec(ret))
    |                      ^^^^^^^^ function or associated item not found in `OsString`

error[E0599]: no method named `as_bytes` found for reference `&OsStr` in the current scope
  --> C:\Users\Colin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-mounts-0.2.4\src\mounts\list.rs:55:43
   |
55 |         self.starts_with(path.as_os_str().as_bytes(), |m| &m.source)
   |                                           ^^^^^^^^ method not found in `&OsStr`

error[E0599]: no method named `as_bytes` found for reference `&OsStr` in the current scope
  --> C:\Users\Colin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-mounts-0.2.4\src\mounts\list.rs:63:43
   |
63 |         self.starts_with(path.as_os_str().as_bytes(), |m| &m.dest)
   |                                           ^^^^^^^^ method not found in `&OsStr`

error[E0599]: no method named `as_bytes` found for reference `&OsStr` in the current scope
  --> C:\Users\Colin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-mounts-0.2.4\src\mounts\list.rs:72:49
   |
72 |             let input = func(mount).as_os_str().as_bytes();
   |                                                 ^^^^^^^^ method not found in `&OsStr`

error[E0599]: no function or associated item named `from_vec` found for struct `OsString` in the current scope
   --> C:\Users\Colin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\proc-mounts-0.2.4\src\swaps.rs:106:22
    |
106 |         Ok(OsString::from_vec(ret))
    |                      ^^^^^^^^ function or associated item not found in `OsString`

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `proc-mounts` (lib) due to 8 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `sgxs-tools v0.8.6 (https://github.com/colingreybosh/rust-sgx#83476c09)`, intermediate artifacts can be found at `$HOME$\AppData\Local\Temp\cargo-installXQMddk`
jethrogb commented 1 year ago

Oops, the __vdso_sgx_enter_enclave stuff is definitely supposed to be conditionally compilation for Linux only.