[Nix-dev] Cross compiling

Lluís Batlle viriketo at gmail.com
Sun Nov 15 23:07:48 CET 2009


Hello,

I think I finally made a step forward in my cross-compilation work
done this weekend.
In stdenv-updates, I could finally, in x86_64, ask nix to build
"bisonArm", which has the same architecture as the sheevaplug as a
target, in an expression like this:
  bisonArm = import ../development/tools/parsing/bison/bison-2.3.nix {
    inherit fetchurl m4;
    stdenv = stdenvCross "armv5tel-unknown-linux-gnueabi";
  };

The 'stdenvCross "..."' triggers the whole toolchain to be ready.

Then in my x86_64 machine I did:
$ nix-store --export `nix-store -q -R
/nix/store/mqrsz3c6b8ylr16-bison-2.3` | bzip2 > bisonarm.nar.bz2

Moved the file to the sheevaplug:
# bzip2 -dc /tmp/bisonarm.nar.bz2 | nix-store --import
/nix/store/jw8zyjpcypisz0cqgsw9xmpc85xyzw9l-bootstrap-tools
/nix/store/yawm887jgkslpsns5pvzl06fwcbhsa3z-linux-headers-2.6.28.5
/nix/store/xpjxsnz9qlr0pmhn6j6bm09n8db5zglx-glibc-2.9
/nix/store/0ap5n3kjhqkzgs5431nxj26ggkps2inz-gmp-4.3.1
/nix/store/g10qpigr7di84lch5qy0i5nvkxx9cw6p-mpfr-2.4.1
/nix/store/6nqsjvbzk3f5pg0wvmb0mr219d3v3qc7-gcc-4.3.4
/nix/store/dz9ihgd45l1vn54lrbrnkaa2xq0gnf8k-gmp-4.3.1
/nix/store/jbf3c3jaq5y1wpls2f40lp9k59w1g17c-mpfr-2.4.1
/nix/store/r2a2rj6x6ziwcbaqvc4vqrjd5dy6p1dm-binutils-2.20-armv5tel-unknown-linux-gnueabi
/nix/store/1l57g5zdzndh72x1jhfq2lndnnpvi6pf-gcc-4.3.4-armv5tel-unknown-linux-gnueabi-stage-static
/nix/store/hgffbbajxclrjghjrr4vxlkxiw4az9rl-gnum4-1.4.13
/nix/store/mrs4abhi1g9q90ynbbqsrr2hg4nrk1db-linux-headers-2.6.28.5
/nix/store/igi3ffyanif4hicyh9n85nzw437p1ay0-glibc-2.9-armv5tel-unknown-linux-gnueabi
/nix/store/hk0kyfg8zvrhn68n05j42s5swklk0m7x-gcc-4.3.4-armv5tel-unknown-linux-gnueabi-stage-final
/nix/store/qpjd87bdpi9xy2sq3nmy4lg4pf3mv89q-bash-4.0-p28
/nix/store/mn4vprys1mcvz2812mqrsz3c6b8ylr16-bison-2.3

And then in the sheevaplug:
# /nix/store/mn4vprys1mcvz2812mqrsz3c6b8ylr16-bison-2.3/bin/bison  -V
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


I think this brings some hope at getting cross compilation in nixpkgs.
The next jobs should take the valuable ideas brought in by Nicolas, in
order to make nixpkgs 'bearable' to allow getting its dependency
information usable for native and *cross compilation too*, instead of
"rebuilding the tree".

Some expressions will need rework, as although many are done with
autotools, not many support directly the usual steps on cross
compilations: simply add the proper --build and --host  as
configureFlags.

My main target was getting cross compilers to get uboot for the
sheevaplug built in any non-arm computer, because debugging it can be
a bit annoying for me, if the only way to get an uboot binary is to
use the sheevaplug native compiler - and using the sheevaplug is the
only way to test and debug uboot. I will add a derivation for a
cross-uboot soon; I targeted first bison because the Cross-LFS guide
said it would build without any trick.

Any ideas on this new toolkit are welcome for discussion, and I hope
the work will not be abandoned, thinking that it clutters stdenv too
much.

Best regards,
Lluís.



More information about the nix-dev mailing list