[Nix-dev] Cross-compilation
Bjørn Forsman
bjorn.forsman at gmail.com
Fri May 17 21:23:13 CEST 2013
Hi,
I'm slowly getting into cross-compilation on NixOS and I have a question.
According to the wiki[1], building with crossSystem != null still
results in a native build, it is only when using .crossDrv that the
package is actually cross-built. This is confirmed with these commands
(the first two hashes are equal, the last third on is different -
because it is cross-built):
$ nix-build -A bison default.nix
/nix/store/f1gn1if4ryhrv64c4c4ljr6ig4w9m0ls-bison-2.6.5
$ nix-build -A bison sheevaplug.nix
/nix/store/f1gn1if4ryhrv64c4c4ljr6ig4w9m0ls-bison-2.6.5
$ nix-build -A bison.crossDrv sheevaplug.nix
/nix/store/cah8d34swnmaj49hiipib986gzxbqqg4-bison-2.6.5-armv5tel-unknown-linux-gnueabi
But when building python I get a different hash for the native builds:
$ nix-build -A python default.nix
/nix/store/yzj6p5f7iyh247pwxrg97y3klm6d0cni-python-2.7.3
$ nix-build -A python sheevaplug.nix
/nix/store/4vi4lzj59cjws0m7b26x091a5s4z15dc-python-2.7.3
(running "file" on result/bin/python2.7 after both of the above
commands returns "ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.35, not
stripped")
and the cross-built python fails:
$ nix-build -A python.crossDrv sheevaplug.nix
these derivations will be built:
/nix/store/s8aviykc791ryysk7q9linvlnyjqn6qj-python-2.7.3-armv5tel-unknown-linux-gnueabi.drv
building path(s)
`/nix/store/x8kqxk0k7i5cjv4f1khsxi4wsgj3svhi-python-2.7.3-armv5tel-unknown-linux-gnueabi'
building /nix/store/x8kqxk0k7i5cjv4f1khsxi4wsgj3svhi-python-2.7.3-armv5tel-unknown-linux-gnueabi
unpacking sources
unpacking source archive
/nix/store/zlkysqgg7bd63w0bjwnjcwh6fmh9g5r0-Python-2.7.3.tar.bz2
/nix/store/zpxdjsj0scgkk9xhclq6cj6znr9h8h98-bzip2-1.0.6-armv5tel-unknown-linux-gnueabi/bin/bzip2:
/nix/store/zpxdjsj0scgkk9xhclq6cj6znr9h8h98-bzip2-1.0.6-armv5tel-unknown-linux-gnueabi/bin/bzip2:
cannot execute binary file
tar: Child returned status 126
tar: Error is not recoverable: exiting now
builder for `/nix/store/s8aviykc791ryysk7q9linvlnyjqn6qj-python-2.7.3-armv5tel-unknown-linux-gnueabi.drv'
failed with exit code 2
error: build of
`/nix/store/s8aviykc791ryysk7q9linvlnyjqn6qj-python-2.7.3-armv5tel-unknown-linux-gnueabi.drv'
failed
I would have expected 1) python to get the same hash until I used
.crossDrv and 2) that python.crossDrv would get at least a bit further
than dying in the unpackPhase (it is trying to use the ARM version of
bzip2).
Can someone explain this? I realize that not all packages will
cross-build, and I did expect python to fail at some point, but not
this way :-)
[1]: http://nixos.org/wiki/CrossCompiling
Best regards,
Bjørn Forsman
More information about the nix-dev
mailing list