nixpkgs/pkgs/development/compilers/rust
Adam Joseph 53b6e1a3c5 rustc: fix >=1.68 host!=build
Our `rustc.nix` adds a `--target` flag for the host when doing a
host!=target build, but neglects to add a `--target` flag for the
buildPlatform when doing a build!=(host==target) build.  This commit
corrects that.

Before rustc 1.68 omitting the --target flag for the buildPlatform
did not cause any problems.  As of rustc 1.68, build!=host without a
--target for the build will fail like below (with hundreds more
"cannot find std::" errors.

```
$ nix build -f . -L pkgsCross.aarch64-multiplatform.rustc
...
Copying stage1 library from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / aarch64-unknown-linux-gnu)
Uplifting stage1 library (x86_64-unknown-linux-gnu -> aarch64-unknown-linux-gnu)
Copying stage2 library from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / aarch64-unknown-linux-gnu)
Building stage2 tool rust-analyzer-proc-macro-srv (aarch64-unknown-linux-gnu)
   Compiling autocfg v1.1.0
   Compiling libc v0.2.135
   Compiling cfg-if v1.0.0
   Compiling proc-macro2 v1.0.47
   Compiling quote v1.0.21
   Compiling unicode-ident v1.0.5
   Compiling syn v1.0.102
   Compiling once_cell v1.15.0
   Compiling parking_lot_core v0.9.4
   Compiling serde_derive v1.0.145
   Compiling hashbrown v0.12.3
   Compiling scopeguard v1.1.0
   Compiling smallvec v1.10.0
   Compiling log v0.4.17
   Compiling serde v1.0.145
   Compiling rustc-hash v1.1.0
error[E0463]: can't find crate for `std`
error: cannot find macro `println` in this scope
 --> /nix/tmp/nix-build-rustc-aarch64-unknown-linux-gnu-1.68.2.drv-0/rustc-1.68.2-src/vendor/libc-0.2.135/build.rs:7:5
  |
7 |     println!("cargo:rerun-if-changed=build.rs");
  |     ^^^^^^^
error: cannot find macro `println` in this scope
  --> /nix/tmp/nix-build-rustc-aarch64-unknown-linux-gnu-1.68.2.drv-0/rustc-1.68.2-src/vendor/libc-0.2.135/build.rs:16:9
   |
16 |         println!(
   |         ^^^^^^^
error: cannot find macro `println` in this scope
  --> /nix/tmp/nix-build-rustc-aarch64-unknown-linux-gnu-1.68.2.drv-0/rustc-1.68.2-src/vendor/libc-0.2.135/build.rs:29:13
   |
29 |             println!("cargo:rustc-cfg=freebsd10")
   |             ^^^^^^^
```
2023-04-18 14:10:40 +10:00
..
1_68.nix rustc: remove unused inputs 2023-03-29 08:00:08 +10:00
binary.nix rustc: don't strip bootstrap on darwin 2022-10-20 09:02:51 +10:00
bootstrap.nix
cargo-auditable-cargo-wrapper.nix cargo-auditable-cargo-wrapper: Use writeShellScriptBin instead of writeShellApplication 2023-01-19 13:50:01 +10:00
cargo-auditable.nix rustPlatform.buildRustPackage: make auditable the default 2023-03-26 22:47:06 -04:00
cargo.nix Merge staging-next into staging 2023-04-03 12:02:00 +00:00
clippy.nix clippy: enable debug info 2023-04-14 09:01:29 +00:00
default.nix clippy: use the right rustc when cross compiling 2023-04-13 10:19:53 +00:00
make-rust-platform.nix rustPlatform.buildRustPackage: fix auditable option when cargo-auditable is not provided to makeRustPlatform 2023-04-13 13:30:39 -04:00
print-hashes.sh rust: add mips64el to list of bootstrap tarballs 2022-03-18 13:00:34 +10:00
rust-lib-src.nix rust-{lib-}src: deprecate phases 2022-02-25 22:57:59 +01:00
rust-src.nix rust-{lib-}src: deprecate phases 2022-02-25 22:57:59 +01:00
rustc.nix rustc: fix >=1.68 host!=build 2023-04-18 14:10:40 +10:00
rustfmt.nix rustfmt: fix build for 1.68 2023-03-27 08:08:40 +10:00
setup-hook.sh