Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc: fix >=1.68 host!=build #226593

Merged
merged 1 commit into from Apr 18, 2023
Merged

rustc: fix >=1.68 host!=build #226593

merged 1 commit into from Apr 18, 2023

Conversation

ghost
Copy link

@ghost ghost commented Apr 17, 2023

Fix for this issue.

Description of changes

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")
   |             ^^^^^^^
Things done
  • Built on platform(s)
    • aarch64-linux (cross from x86_64-linux)
  • Fits CONTRIBUTING.md.

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")
   |             ^^^^^^^
```
@ghost ghost requested review from Mic92, zowoq, winterqt and figsoda as code owners April 17, 2023 06:32
@ghost ghost mentioned this pull request Apr 17, 2023
12 tasks
@ghost
Copy link
Author

ghost commented Apr 17, 2023

@ofborg build pkgsCross.aarch64-multiplatform.rustc

@ghost
Copy link
Author

ghost commented Apr 18, 2023

@zowoq zowoq merged commit 53b6e1a into NixOS:master Apr 18, 2023
@ghost ghost deleted the pr/fixcross/rustc branch April 20, 2023 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants