Cannot cross-compile rust while providing pre-built LLVM #134811
Labels
A-cross
Area: Cross compilation
C-bug
Category: This is a bug.
O-NixOS
Operating system: NixOS, https://nixos.org/
T-bootstrap
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
I'm a little lost at how exactly to report this because I don't fully understand the error - I've spent several hours trying to reverse engineer the build process and the following is all I really have to show for it:
I'm trying to simplify the nixpkgs build of rustc, and I'm getting failures in cross configurations (linux x86_64->aarch64 as my testcase). This build configuration requires using pre-built LLVMs and providing the
llvm-config
binary for each target in a cross build. I'm getting build failures when linking the stage2:x86_64-unknown-linux-gnu -> stage3:aarch64-unknown-linux-gnurust-analyzer-proc-macro-srv
, claiming that it can't find-lLLVM-19
. Before this, it was successfully able to link the stage1:x86_64-unknown-linux-gnu -> stage2:aarch64-unknown-linux-gnurustc_driver
against libLLVM-19.so for the aarch64 platform without any issue.I was able to determine that it's deciding it needs to link with -lLLVM-19 because of some data in the librustc_llvm.rmeta file - when I edited the rmeta file to say
LLBM
instead, the error message changed accordingly but still failed in the same spot. Based on this, it seems like the underlying bug is that the corresponding-L
path flags aren't being propagated even though the-l
flags are.However, I haven't been able to determine why it does work in the non-cross case. I give it equal odds my hypothesis is just wrong vs there is some special cross/non-cross logic in the rustc build which is messing this up.
Note: I tried jamming the is_cross predicate in the rustc_llvm build script to
false
, since the comments around it seemed to not match super well for my nix use-case, but it failed the same way.Here's the config.toml (gzip'd to make github happy) for my build
Here's the build log for the failing build
llvm-config output:
If anyone would like to reproduce this with nix, you can do so with
nix build github:rhelmot/nixpkgs/04a5a2d2fb5216c0f401529d08a1c034fcbd890d#pkgsCross.aarch64-multiplatform.rustc.unwrapped
. It's based on a staging branch of nixpkgs, so it will have to rebuild the world and will take a few hours.Lemme know if there's anything else I can provide.
The text was updated successfully, but these errors were encountered: