nixpkgs/pkgs/development/compilers/rust
Paul Lietar 8e1e16fdcb rustc: Fix building cross-compilers for no_std targets.
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'
2024-01-04 10:18:33 +00:00
..
1_74.nix rustc: use the wrapper for fastCross sysroot 2023-11-30 09:23:06 +00:00
binary.nix rustc: link to https homepage 2023-12-25 20:52:38 +01:00
bootstrap.nix lib.systems: elaborate Rust metadata 2023-11-09 10:02:24 +01:00
cargo_cross.nix rust: cargo: Use rustc and cargo built on Build 2023-09-10 14:48:39 +02:00
cargo-auditable-cargo-wrapper.nix cargo-auditable-cargo-wrapper: don't wrap if cargo-auditable is meta.broken (#250615) 2023-08-26 16:07:05 -05:00
cargo-auditable.nix cargo-auditable: fix cross compilation 2023-08-11 09:40:05 +01:00
cargo.nix cargo: fix tests eval 2023-12-29 10:20:59 +10:00
clippy.nix clippy: use unwrapped rustc when adding rpath for darwin 2023-12-15 17:46:56 +01:00
default.nix treewide: add __attrsFailEvaluation and __recurseIntoDerivationForReleaseJobs 2023-12-15 05:13:46 -08:00
make-rust-platform.nix rustPlatform.rust: deprecate 2023-05-12 15:31:21 +00:00
print-hashes.sh rustc: 1.72.1 -> 1.73.0 2023-10-10 14:42:30 +00:00
rust-lib-src.nix
rust-src.nix
rustc.nix rustc: Fix building cross-compilers for no_std targets. 2024-01-04 10:18:33 +00:00
rustfmt.nix rustfmt: use unwrapped rustc when adding rpath for darwin 2023-12-15 17:46:56 +01:00
setup-hook.sh