Repository: rust
Issue: Cross-building rust 1.83.0 on & for NetBSD failure
Labels: A-cross,O-netbsd,T-bootstrap,C-bug

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I am doing my best to try to keep the various NetBSD targets for rust working.
As part of that process, I am cross-building binaries from x86_64 to most of the
other targets, and carry out testing of the results, for some of the targets this involves
self-hosting the rust compiler.

I have two new observations for rust 1.83.0 (1.82.0 works fine):

1. A new seemingly-non-fatal error message which is difficult to get a grasp on has started appearing in the build log:
```
   1.288127806s  INFO prepare_target{force=false package_id=sysroot v0.0.0 (/usr
/pkgsrc/wip/rust183/work/rustc-1.83.0-src/library/sysroot) target="sysroot"}: ca
rgo::core::compiler::fingerprint: fingerprint error for sysroot v0.0.0 (/usr/pkg
src/wip/rust183/work/rustc-1.83.0-src/library/sysroot)/Build/TargetInner { name_inferred: true, ..: lib_target("sysroot", ["lib"], "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/library/sysroot/src/lib.rs", Edition2021) }
   1.288196443s  INFO prepare_target{force=false package_id=sysroot v0.0.0 (/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/library/sysroot) target="sysroot"}: cargo::core::compiler::fingerprint:     err: failed to read `/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage0-std/x86_64-unknown-netbsd/release/.fingerprint/sysroot-40f70deaa15a4468/lib-sysroot`

Caused by:
    No such file or directory (os error 2)
```
   There are *many* such instances.  Testing for the existence of the quoted file name afterwards does not reproduce the problem(!)
   Looking for the file afterwards shows that it exists:
```
$ find work -type f -name lib-sysroot
work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1-std/armv7-unknown-netbsd-eabihf/release/.fingerprint/sysroot-76159fffe79d6c08/lib-sysroot
work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1-std/x86_64-unknown-netbsd/release/.fingerprint/sysroot-904060a630664f36/lib-sysroot
work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage0-std/x86_64-unknown-netbsd/release/.fingerprint/sysroot-40f70deaa15a4468/lib-sysroot
$ 
$ cat /usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage0-std/x86_64-unknown-netbsd/release/.fingerprint/sysroot-40f70deaa15a4468/lib-sysroot; echo
07b22e914d1cad45
$ 
```

2. While natively building the rust compiler on x86_64 works fine, and the resulting compiler also works, I get a new (to me) problem while cross-  building the rust compiler, in this first instance for our `armv7hf` target:
```
using sysroot /usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1
running: "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1/bin/rustc" "--target" "armv7-unknown-netbsd-eabihf" "--print=file-names" "--crate-type=proc-macro" "-" (failure_mode=Exit) (created at src/core/builder.rs:1704:33, executed at src/core/builder.rs:1710:26)

Command "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1/bin/rustc" "--target" "armv7-unknown-netbsd-eabihf" "--print=file-names" "--crate-type=proc-macro" "-" (failure_mode=Exit) did not execute successfully.
Expected success, got exit status: 1
Created at: src/core/builder.rs:1704:33
Executed at: src/core/builder.rs:1710:26

STDOUT ----


STDERR ----
/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1/bin/rustc: Shared object "librustc_driver-299f82a8112084d1.so" not found
```
   The asked-for file exists in the build tree, ref.:
```
$ find work -name librustc_driver-299f82a8112084d1.so -type f
work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1/lib/librustc_driver-299f82a8112084d1.so
work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage0-sysroot/lib/rustlib/x86_64-unknown-netbsd/lib/librustc_driver-299f82a8112084d1.so
work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage0-rustc/x86_64-unknown-netbsd/release/deps/librustc_driver-299f82a8112084d1.so
$ 
```
   but apparently, this particular `rustc` instance isn't being pointed in the right direction.
   It is also somewhat unclear to me whether this second problem is related to the first issue listed above.

My initial build attempt was done with `-j 32` (I have the resources for it), but repeating it with `-j 1` to root out whether this is a bug related to parallelism of the build reveals that the answer to that question is "no".


I expected to see this happen: Cross-building the rust compiler ought to succeed.

Instead, this happened: 

The build errored out with
```
    Finished `release` profile [optimized] target(s) in 2m 45s
using sysroot /usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1
running: "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1/bin/rustc" "--target" "armv7-unknown-netbsd-eabihf" "--print=file-names" "--crate-type=proc-macro" "-" (failure_mode=Exit) (created at src/core/builder.rs:1704:33, executed at src/core/builder.rs:1710:26)

Command "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1/bin/rustc" "--target" "armv7-unknown-netbsd-eabihf" "--print=file-names" "--crate-type=proc-macro" "-" (failure_mode=Exit) did not execute successfully.
Expected success, got exit status: 1
Created at: src/core/builder.rs:1704:33
Executed at: src/core/builder.rs:1710:26

STDOUT ----


STDERR ----
/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1/bin/rustc: Shared object "librustc_driver-299f82a8112084d1.so" not found

Traceback (most recent call last):
  File "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/./x.py", line 50, in <module>
    bootstrap.main()
  File "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/src/bootstrap/bootstrap.py", line 1227, in main
    bootstrap(args)
  File "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/src/bootstrap/bootstrap.py", line 1203, in bootstrap
    run(args, env=env, verbose=build.verbose, is_bootstrap=True)
  File "/usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/src/bootstrap/bootstrap.py", line 202, in run
    raise RuntimeError(err)
RuntimeError: failed to run: /usr/pkgsrc/wip/rust183/work/rustc-1.83.0-src/build/bootstrap/debug/bootstrap -v dist -j 1
*** Error code 1

Stop.
make[1]: stopped in /usr/pkgsrc/wip/rust183
*** Error code 1

```



### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

This build is obviously using the previous version, `rust 1.82.0`:

`rustc --version --verbose`:
```
$ work/rust-1.82.0-x86_64-unknown-netbsd/rustc/bin/rustc --version --verbose
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-netbsd
release: 1.82.0
LLVM version: 19.1.1
$ 
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Backtrace</summary>
<p>

Backtraces and details from the build provided above.
If wanted, I can provide a copy of the entire build log, hints for how to do so appreciated.

</p>
</details>