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.
This commit is contained in:
Niklas Korz
2025-05-13 17:54:17 +02:00
committed by Alyssa Ross
parent a765eb64a5
commit ffbfd9c828
+8 -4
View File
@@ -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
]
)
}"