From: Nikita Karetnikov <nikita@karetnikov.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: bug-guix@gnu.org
Subject: Re: Initial cross-compilation support
Date: Sat, 09 Mar 2013 13:56:50 +0400 [thread overview]
Message-ID: <87li9wew0t.fsf@karetnikov.org> (raw)
In-Reply-To: <87obezp0i3.fsf@karetnikov.org> (Nikita Karetnikov's message of "Mon, 04 Mar 2013 20:56:20 +0400")
[-- Attachment #1: Type: text/plain, Size: 3244 bytes --]
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
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2013-03-09 9:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-27 20:05 Initial cross-compilation support Ludovic Courtès
2013-03-03 16:26 ` Andreas Enge
2013-03-03 21:32 ` Ludovic Courtès
2013-03-28 9:35 ` Nikita Karetnikov
2013-03-28 13:38 ` Ludovic Courtès
2013-03-28 21:00 ` Nikita Karetnikov
2013-03-28 22:41 ` Ludovic Courtès
2013-03-29 1:49 ` Nikita Karetnikov
2013-03-29 9:46 ` Ludovic Courtès
2013-03-29 21:20 ` Nikita Karetnikov
2013-03-29 21:39 ` Ludovic Courtès
2013-03-29 22:06 ` Nikita Karetnikov
2013-05-20 19:40 ` Ludovic Courtès
2013-05-21 18:46 ` Nikita Karetnikov
2013-05-21 20:04 ` Ludovic Courtès
2013-05-21 20:23 ` Nikita Karetnikov
2013-05-21 20:54 ` Nikita Karetnikov
2013-05-21 21:00 ` Ludovic Courtès
2013-03-04 0:19 ` Nikita Karetnikov
2013-03-04 10:10 ` Ludovic Courtès
2013-03-04 16:56 ` Nikita Karetnikov
2013-03-09 9:56 ` Nikita Karetnikov [this message]
2013-05-24 21:30 ` Ludovic Courtès
2013-05-24 21:59 ` Nikita Karetnikov
2013-05-24 22:26 ` Ludovic Courtès
2013-05-27 21:49 ` Ludovic Courtès
2013-05-24 22:04 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87li9wew0t.fsf@karetnikov.org \
--to=nikita@karetnikov.org \
--cc=bug-guix@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.