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 + ] ) }"