I was able to cross-compile a "hello world" program. First, I created the following symlinks:
# ln -s /nix/store/mifp2p1zjlvb4ndslw1r8grkpglybqjf-glibc-cross-mips64el-linux-gnu-2.17/lib/crti.o /nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/lib/gcc/mips64el-linux-gnu/4.7.2/crti.o # ln -s /nix/store/mifp2p1zjlvb4ndslw1r8grkpglybqjf-glibc-cross-mips64el-linux-gnu-2.17/lib/crt1.o /nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/lib/gcc/mips64el-linux-gnu/4.7.2/crt1.o # ln -s /nix/store/mifp2p1zjlvb4ndslw1r8grkpglybqjf-glibc-cross-mips64el-linux-gnu-2.17/lib/crtn.o /nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/lib/gcc/mips64el-linux-gnu/4.7.2/crtn.o These are needed because I haven't found a way to set the CROSS_LIBRARY_PATH variable. (I'll show an example below.) Then I set this variable: # export COMPILER_PATH=/nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/libexec/gcc/mips64el-linux-gnu:/nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/libexec/gcc/mips64el-linux-gnu/4.7.2 which is used to locate subprograms [1]. After that I specified this one: # export C_INCLUDE_PATH=/nix/store/mifp2p1zjlvb4ndslw1r8grkpglybqjf-glibc-cross-mips64el-linux-gnu-2.17/include And compiled the following program: #include <stdio.h> int main () { printf ("Hello World!\n"); } # /nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/bin/mips64el-linux-gnu-gcc -static -o hello hello.c Then I ran 'hello' on mips64el and it worked. Is it enough to be sure that cross-compiler will also work for non-trivial programs? Here is the example I mentioned: # export CROSS_LIBRARY_PATH=foo # /nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/bin/mips64el-linux-gnu-gcc -static -o hello -v hello.c |& grep CROSS_LIBRARY_PATH CROSS_LIBRARY_PATH=/nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/lib/gcc/mips64el-linux-gnu/4.7.2/:/nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/lib/gcc/mips64el-linux-gnu/4.7.2/../../../../mips64el-linux-gnu/lib Note that CROSS_LIBRARY_PATH is not set to 'foo'. Could you explain why? Is it determined automatically (e.g., based on the location of GCC)? # ltrace /nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/bin/mips64el-linux-gnu-gcc -static -o hello -v hello.c |& grep CROSS_LIBRARY_PATH getenv("CROSS_LIBRARY_PATH") = "foo" strlen("CROSS_LIBRARY_PATH") = 18 memcpy(0x0867b044, "CROSS_LIBRARY_PATH", 18) = 0x0867b044 vfprintf(0xb77b3980, "%s\n", 0xbf9b3d88CROSS_LIBRARY_PATH=/nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/lib/gcc/mips64el-linux-gnu/4.7.2/:/nix/store/khdyz3i5aih56lxfk6hjvp3884apm7qb-gcc-cross-mips64el-linux-gnu-4.7.2/lib/gcc/mips64el-linux-gnu/4.7.2/../../../../mips64el-linux-gnu/lib/ putenv("CROSS_LIBRARY_PATH=/nix/store/kh"...) = 0 How did 'vfprintf' get its third argument? Comments? Do you know how to do it without the symlinks? [1] http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html
pgpfqMQa8_cUG.pgp
Description: PGP signature