From ffbfd9c828ec7a75fc506d952dbc6e38a9562466 Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Tue, 13 May 2025 13:49:39 +0200 Subject: [PATCH] rustc: ensure standard library docs are installed Fixes #405914 Upstream's installation script installs the `docs` component for every target that is built. Unfortunately, installing the docs for a target removes the previous target's docs, ultimately leaving only the docs of the last target in the list. In our case, that is a `no_std` target, for which no `alloc` or `std` docs are built, thus leaving `rustc.doc` without any standard library docs. Moving stdenv's `targetPlatform` to the end of the list ensures we get standard library docs. --- pkgs/development/compilers/rust/rustc.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 263feaa61704..0e69639b0514 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -153,11 +153,8 @@ stdenv.mkDerivation (finalAttrs: { # std is built for all platforms in --target. "--target=${ concatStringsSep "," ( - [ - stdenv.targetPlatform.rust.rustcTargetSpec - ] # Other targets that don't need any extra dependencies to build. - ++ optionals (!fastCross) [ + optionals (!fastCross) [ "wasm32-unknown-unknown" "wasm32v1-none" "bpfel-unknown-none" @@ -175,6 +172,13 @@ stdenv.mkDerivation (finalAttrs: { ++ optionals (stdenv.hostPlatform != stdenv.targetPlatform && !fastCross) [ stdenv.hostPlatform.rust.rustcTargetSpec ] + ++ [ + # `make install` only keeps the docs of the last target in the list. + # If the `targetPlatform` is not the last entry, we may end up without + # `alloc` or `std` docs (if the last target is `no_std`). + # More information: https://github.com/rust-lang/rust/issues/140922 + stdenv.targetPlatform.rust.rustcTargetSpec + ] ) }"