RSA
RSA copied to clipboard
no_std build with aarch64-unknown-uefi problem
When I build this lib with command cargo build -Zbuild-std=core,compiler_builtins,alloc -Zbuild-std-features=compiler-builtins-mem --target aarch64-unknown-uefi --no-default-features --features alloc
, I meet the problem below
cargo build -Zbuild-std=core,compiler_builtins,alloc -Zbuild-std-features=compiler-builtins-mem --target aarch64-unknown-uefi --no-default-features --features alloc Compiling compiler_builtins v0.1.49 Compiling typenum v1.15.0 Compiling generic-array v0.14.5 Compiling libm v0.2.1 Compiling num-traits v0.2.14 Compiling num-integer v0.1.44 Compiling num-iter v0.1.42 Compiling num-bigint-dig v0.7.0 error: failed to run custom build command for
num-bigint-dig v0.7.0`
Caused by:
process didn't exit successfully: /mnt/e/MyDocument/Git/bootloader/dependencies/RSA/target/debug/build/num-bigint-dig-e381e946b1699931/build-script-build
(exit status: 101)
--- stderr
error[E0463]: can't find crate for std
|
= note: the aarch64-unknown-uefi
target may not be installed
= help: consider downloading the target with rustup target add aarch64-unknown-uefi
= help: consider building the standard library from source with cargo build -Zbuild-std
error: aborting due to previous error
For more information about this error, try rustc --explain E0463
.
error[E0463]: can't find crate for core
|
= note: the aarch64-unknown-uefi
target may not be installed
= help: consider downloading the target with rustup target add aarch64-unknown-uefi
= help: consider building the standard library from source with cargo build -Zbuild-std
error: aborting due to previous error
For more information about this error, try rustc --explain E0463
.
warning: autocfg could not probe for std
error[E0463]: can't find crate for std
|
= note: the aarch64-unknown-uefi
target may not be installed
= help: consider downloading the target with rustup target add aarch64-unknown-uefi
= help: consider building the standard library from source with cargo build -Zbuild-std
error: aborting due to previous error
For more information about this error, try rustc --explain E0463
.
thread 'main' panicked at 'i128 support was not detected!', /home/become_light/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/num-bigint-dig-0.7.0/build.rs:10:9
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
`
How can I solve this problem? When I build with aarch64-unknown-none, it's the same problem as above.
aarch64-unknown-uefi target-special .json is below
{ "abi-return-struct-as-int": true, "allows-weak-linkage": false, "arch": "aarch64", "data-layout": "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128", "disable-redzone": true, "emit-debug-gdb-scripts": false, "exe-suffix": ".efi", "executables": true, "is-builtin": true, "is-like-msvc": true, "is-like-windows": true, "linker": "rust-lld", "linker-flavor": "lld-link", "linker-is-gnu": false, "lld-flavor": "link", "llvm-target": "aarch64-unknown-windows", "max-atomic-width": 64, "os": "uefi", "panic-strategy": "abort", "pre-link-args": { "lld-link": [ "/NOLOGO", "/entry:efi_main", "/subsystem:efi_application", "/machine:arm64" ], "msvc": [ "/NOLOGO", "/entry:efi_main", "/subsystem:efi_application", "/machine:arm64" ] }, "singlethread": true, "split-debuginfo": "packed", "stack-probes": { "kind": "call" }, "target-pointer-width": "64" }
This is odd:
Caused by: process didn't exit successfully: /mnt/e/MyDocument/Git/bootloader/dependencies/RSA/target/debug/build/num-bigint-dig-e381e946b1699931/build-script-build (exit status: 101) --- stderr error[E0463]: can't find crate for std
It looks like the build script is being cross-compiled to the target architecture?
num-bigint-dig
should otherwise have no_std
support.
This is odd:
Caused by: process didn't exit successfully: /mnt/e/MyDocument/Git/bootloader/dependencies/RSA/target/debug/build/num-bigint-dig-e381e946b1699931/build-script-build (exit status: 101) --- stderr error[E0463]: can't find crate for std
It looks like the build script is being cross-compiled to the target architecture?
num-bigint-dig
should otherwise haveno_std
support.
But I have built like a member who mentioned before, how should I avoid the problem? According to the description, It seems like no problem.
What a strange problem it is!
@Luchangcheng2333 It's still unclear what's happening.
Build scripts should be executed on the host, and therefore not impacted by the capabilities of the target. But for some reason something is going wrong and it seems the build script is trying to target the platform you're cross-compiling to, which obviously won't work because it needs to run on the host OS.
Having same problem here, building for x86_64-unknown-uefi
.
I tried building a version of RSA using the version 0.8.1 of num-bigint-dig
, instead of 0.7.0.
Not sure if it fix anything but i'm hitting another error, it tries to compile the crate getrandom
, but panic cause i'm in a no_std environment, I dont get why this crate is suddenly involved ?
It looks like getrandom
is getting pulled in here: https://github.com/RustCrypto/RSA/blob/master/Cargo.toml#L19
I'm unclear how CI is passing with this as a hard dependency. This target has no std
impl and should error if std
is linked:
https://github.com/RustCrypto/RSA/blob/master/.github/workflows/ci.yml#L32-L34
It'd probably be good to open a separate issue about this. Unless there are explicit rand
requirements that the rsa
crate is relying on it'd probably be better to use rand_core
and conditionally activate its getrandom
feature.
The problem is that getrandom
has no implentation for the *-unknown-uefi
target, so I guess it is trying a default one which depends on std
.
I'm currently working on the implementation of the EFI_RNG_PROTOCOL for the uefi-rs library (a wrapper for Rust around uefi protocols). So when I'm finished, I will submit an implementation for getrandom
.
We'll see then if it fix our problem.
getrandom
has a limited support for UEFI targets with enabled rdrand
feature.
getrandom
has a limited support for UEFI targets with enabledrdrand
feature.
That could work for me as I'm building for x86_64, not for the author sadly. Thanks for pointing this out, I'll try this first.
https://github.com/RustCrypto/utils/pull/821 is the relevant issue here