Hi,
Following
https://nixos.org/manual/nixpkgs/stable/#cross-qa-avoid-compiling-gcc-cross-compiler
I tried
$nix-build '<nixpkgs>' -A pkgsCross.raspberryPi.hello
and, because I’ve enabled flakes:
$ nix build -f channel:nixpkgs-unstable pkgsCross.raspberryPi.hello
and they both failed with “exec format error”, indicating that something is trying to run cross-compiled binaries on the host system. Here’s a full build log: cross-compile hello build log · GitHub .
I’m puzzled because this seems like a very basic cross-compilation task, so there’s possibly something fundamentally wrong with my setup. Everything not related to pkgsCross seems to work as expected.
I’m on NixOS 22.11, in a aarch-linux UTM virtual machine running on macOS M1.
Elias
It seems to be in order when cross compiling from x86_64-linux:
$ nixos-version
22.11.2759.7076110064c (Raccoon)
$ nix build -f '<nixpkgs>' pkgsCross.raspberryPi.hello
$ qemu-arm result/bin/hello
Hello, world!
I just upgraded to latest:
nixos-version
22.11.20230306.47c0034 (Raccoon)
And tried again. I got a similar build error.
raphi
March 7, 2023, 4:17pm
4
That seems very relevant, thank you! I’ll link to it in my bug report,
opened 04:24PM - 07 Mar 23 UTC
0.kind: build failure
### Steps To Reproduce
See also https://discourse.nixos.org/t/cross-compiling… -hello-to-raspberrypi/26093
Steps to reproduce the behavior:
1. `nix build -f '<nixpkgs>' pkgsCross.raspberryPi.hello`
### Build log
https://gist.github.com/eliasnaur/b57b5c0337ba4fdf17271708db252b45
### Additional context
This is such as basic cross-compilation that I wonder whether something is wrong in my setup. However, the `exec format` errors are surprising, because I thought most packages were cross-compilation aware enough to not run host binaries on the build platform.
### Metadata
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
```console
$ nix-shell -p nix-info --run "nix-info -m"
- system: `"aarch64-linux"`
- host os: `Linux 5.15.97, NixOS, 22.11 (Raccoon), 22.11.20230306.47c0034`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.11.1`
- channels(e): `""`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
```
I can confirm this PR fixes the issue. Thank you!