apache / incubator-teaclave-sgx-sdk

Apache Teaclave (incubating) SGX SDK helps developers to write Intel SGX applications in the Rust programming language, and also known as Rust SGX SDK.
https://teaclave.apache.org
Apache License 2.0
1.17k stars 259 forks source link

support recent nightly to get better debug info on no_std issues #161

Open brenzi opened 4 years ago

brenzi commented 4 years ago

The following rust-lang PR should give us better debug info for duplicate lang itemissues:

Issue: https://github.com/rust-lang/rust/issues/60561

PR: https://github.com/rust-lang/rust/pull/64883

Can we get support for recent nightly including this PR?

dingelish commented 4 years ago

Hey @brenzi , I figured out a way to use the latest compiler. Please see the branch "test-2019-10". To use that in your enclave, you can add a patch section with fixed path:

[patch.'https://github.com/baidu/rust-sgx-sdk.git']
sgx_alloc = { path = "../../../ding/rust-sgx-sdk/sgx_alloc" }
sgx_build_helper = { path = "../../../ding/rust-sgx-sdk/sgx_build_helper" }
sgx_cov = { path = "../../../ding/rust-sgx-sdk/sgx_cov" }
sgx_crypto_helper = { path = "../../../ding/rust-sgx-sdk/sgx_crypto_helper" }
sgx_libc = { path = "../../../ding/rust-sgx-sdk/sgx_libc" }
sgx_rand = { path = "../../../ding/rust-sgx-sdk/sgx_rand" }
sgx_rand_derive = { path = "../../../ding/rust-sgx-sdk/sgx_rand_derive" }
sgx_serialize = { path = "../../../ding/rust-sgx-sdk/sgx_serialize" }
sgx_serialize_derive = { path = "../../../ding/rust-sgx-sdk/sgx_serialize_derive" }
sgx_serialize_derive_internals = { path = "../../../ding/rust-sgx-sdk/sgx_serialize_derive_internals" }
sgx_tcrypto = { path = "../../../ding/rust-sgx-sdk/sgx_tcrypto" }
sgx_tcrypto_helper = { path = "../../../ding/rust-sgx-sdk/sgx_tcrypto_helper" }
sgx_tdh = { path = "../../../ding/rust-sgx-sdk/sgx_tdh" }
sgx_tkey_exchange = { path = "../../../ding/rust-sgx-sdk/sgx_tkey_exchange" }
sgx_tprotected_fs = { path = "../../../ding/rust-sgx-sdk/sgx_tprotected_fs" }
sgx_trts = { path = "../../../ding/rust-sgx-sdk/sgx_trts" }
sgx_tse = { path = "../../../ding/rust-sgx-sdk/sgx_tse" }
sgx_tseal = { path = "../../../ding/rust-sgx-sdk/sgx_tseal" }
sgx_tservice = { path = "../../../ding/rust-sgx-sdk/sgx_tservice" }
sgx_tstd = { path = "../../../ding/rust-sgx-sdk/sgx_tstd" }
sgx_tunittest = { path = "../../../ding/rust-sgx-sdk/sgx_tunittest" }
sgx_types = { path = "../../../ding/rust-sgx-sdk/sgx_types" }
sgx_ucrypto = { path = "../../../ding/rust-sgx-sdk/sgx_ucrypto" }
sgx_unwind = { path = "../../../ding/rust-sgx-sdk/sgx_unwind" }
sgx_urts = { path = "../../../ding/rust-sgx-sdk/sgx_urts" }
brenzi commented 4 years ago

cheers, I'll have a look - but it will take time. Will this enter the next release?

dingelish commented 4 years ago

of course! but I'm not sure if I can do this earlier. it seems that all the forked crates can build well using nightly-2019-10-04.

and I think there's probably another release around Nov. 12th.

brenzi commented 4 years ago

This doesn't seem to work for me. If I build https://github.com/scs/test-no-std/tree/substrate-primitives with

cargo +nightly-2019-08-01 build

this goes through building sgx_tstd successfully

But with

cargo +nightly-2019-10-04 build

I get errors:

error[E0432]: unresolved import `core::prelude::v1::__rust_unstable_column`
  --> /home/abrenzikofer/.cargo/git/checkouts/rust-sgx-sdk-fc8771c5c45bde9a/166d481/sgx_tstd/src/prelude/v1.rs:52:5
   |
52 |     __rust_unstable_column,
   |     ^^^^^^^^^^^^^^^^^^^^^^ no `__rust_unstable_column` in `prelude::v1`

error[E0432]: unresolved imports `core::prelude::v1::Decodable`, `core::prelude::v1::Encodable`
  --> /home/abrenzikofer/.cargo/git/checkouts/rust-sgx-sdk-fc8771c5c45bde9a/166d481/sgx_tstd/src/prelude/v1.rs:84:5
   |
84 |     Decodable,
   |     ^^^^^^^^^ no `Decodable` in `prelude::v1`
85 |     Default,
86 |     Encodable,
   |     ^^^^^^^^^ no `Encodable` in `prelude::v1`

error[E0432]: unresolved import `alloc_crate::collections::CollectionAllocErr`
  --> /home/abrenzikofer/.cargo/git/checkouts/rust-sgx-sdk-fc8771c5c45bde9a/166d481/sgx_tstd/src/collections/mod.rs:46:9
   |
46 | pub use alloc_crate::collections::CollectionAllocErr;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `CollectionAllocErr` in `collections`

error: internal compiler error: src/librustc/session/mod.rs:379: can't buffer lints after HIR lowering

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:915:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0-nightly (032a53a06 2019-10-03) running on x86_64-unknown-linux-gnu

note: compiler flags: -C panic=abort -C debuginfo=2 --crate-type rlib

note: some of the compiler flags provided by cargo are hidden

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0432`.
error: could not compile `sgx_tstd`.