mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-03 18:54:42 +00:00
8e1e16fdcb
When building a cross-compiler, the rustc derivation does some tricks to only build the standard library and reuse the host's compiler, leading to much faster build time. Unfortunately, the way the build system was invoked, it would always build the `std` crate, whether or not the target supports it. Some bare-metal targets only support building the `core` and `alloc` crates. By being more vague about the build command, using `library` instead of `library/std`, Rust's build system is able to figure out exactly which crates to build: https://github.com/rust-lang/rust/blob/1.74.1/src/bootstrap/compile.rs#L370-L412 Oddly enough, the install command still needs to use `library/std`, even if building just a subset: https://github.com/rust-lang/rust/blob/1.74.1/src/bootstrap/install.rs#L207 The following command was used to reproduce the original issue. Without this patch, it leads to a build failure when trying to compile one of std's dependencies. With the patch it completes succesfully and produces a working cross-compiler. nix build --impure --expr '(import ./. { crossSystem = { config = "riscv32-none-elf"; rustc.config = "riscv32imc-unknown-none-elf"; }; }).buildPackages.rustc' |
||
---|---|---|
.. | ||
1_74.nix | ||
binary.nix | ||
bootstrap.nix | ||
cargo_cross.nix | ||
cargo-auditable-cargo-wrapper.nix | ||
cargo-auditable.nix | ||
cargo.nix | ||
clippy.nix | ||
default.nix | ||
make-rust-platform.nix | ||
print-hashes.sh | ||
rust-lib-src.nix | ||
rust-src.nix | ||
rustc.nix | ||
rustfmt.nix | ||
setup-hook.sh |