Build failed without standard library
Closed this issue · 1 comments
gaojiaqi7 commented
Hi,
I am trying to use mbedtls in no_std
environment with x86_64-unknown-none
target without standard library built-in, but I met the following errors when compiling mbedtls:
error[E0277]: the trait bound `rust_alloc::boxed::Box<SavedRawCipher>: Deserialize<'_>` is not satisfied
--> mbedtls/src/cipher/raw/serde.rs:52:9
|
52 | inner_cipher_ctx: Box<SavedRawCipher>
| ^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `rust_alloc::boxed::Box<SavedRawCipher>`
|
= help: the following other types implement trait `Deserialize<'de>`:
&'a [u8]
&'a str
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
and 102 others
note: required by a bound in `next_value`
--> /home/tdvf/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.101/src/de/mod.rs:1845:12
|
1845 | V: Deserialize<'de>,
| ^^^^^^^^^^^^^^^^ required by this bound in `next_value`
Some errors have detailed explanations: E0277, E0407.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `mbedtls` due to 4 previous errors
error[E0405]: cannot find trait `Default` in this scope
--> /home/tdvf/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-1.3.2/src/lib.rs:1831:6
|
1831 | impl Default for LittleEndian {
| ^^^^^^^ not found in this scope
|
help: consider importing this trait
|
83 | use core::default::Default;
|
Some errors have detailed explanations: E0405, E0425, E0463.
For more information about an error, try `rustc --explain E0405`.
error: could not compile `byteorder` due to 173 previous errors
The error message is too long, so I only pasted part of it here.
The build command I'm using is:
cargo build -p mbedtls -Zbuild-std=core,alloc,compiler_builtins --target=x86_64-unknown-none --no-default-features --features="no_std_deps,rdrand"
The same result applies to:
cargo build -p mbedtls -Zbuild-std=core,alloc,compiler_builtins --target=x86_64-unknown-linux-gnu--no-default-features --features="no_std_deps,rdrand"
gaojiaqi7 commented
From the compiler output, it seems the default features of byteorder
should not be enabled and the alloc
feature of serde
should be enabled under no_std
.
https://github.com/BurntSushi/byteorder/blob/master/Cargo.toml#L25
I submitted a pull request #209 trying to fix this error. Please take a review, thanks🙂