From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Karetnikov Subject: Re: Initial cross-compilation support Date: Sat, 09 Mar 2013 13:56:50 +0400 Message-ID: <87li9wew0t.fsf@karetnikov.org> References: <87txoxv7x9.fsf@gnu.org> <201303031726.08488.andreas@enge.fr> <87txos2f03.fsf@karetnikov.org> <878v63iifr.fsf@gnu.org> <87obezp0i3.fsf@karetnikov.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:44624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UEGUY-0007wz-2b for bug-guix@gnu.org; Sat, 09 Mar 2013 04:55:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UEGUQ-0004HB-U0 for bug-guix@gnu.org; Sat, 09 Mar 2013 04:55:01 -0500 In-Reply-To: <87obezp0i3.fsf@karetnikov.org> (Nikita Karetnikov's message of "Mon, 04 Mar 2013 20:56:20 +0400") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: bug-guix@gnu.org --=-=-= 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 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 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJROwdmAAoJEM+IQzI9IQ38QVAP/1NiWPDvusN9jri/KG8U+rm+ efjcDO+qHvwQVe7rSdewQgOeqa0kaJzBDWpvylci6nNDQXpMALhJNJRMApJfSCvJ v2GZsjJKLB0ReoFdFeUIlk86N55NyrT9BekNSSwxav7o9cRSgCI2uTJO0XcJ5TYm RVn0Wmu+z86iWBEz0xyHHFwYESpQianmEw2Z7PC157BPVsdW94ZW7S+g32Ep/cg7 5BnWBAkEV2ZQAWoOt02id460nmSuWkbqQqM/ViwXPcLng5iLwsH4Xrv8+ZQMSHZg l7VT5wSVWbouCqEAH8y0DR7DIgk69RUiXtWcPVZHWmHnKA+EsRxODzNvOwGTv9o8 +37ROnJCzWrt4SxV8ZCK84slS9NP2UeJJAPGsmgP1cDkvkJECud+uOPXqx/gCWYm dZBkWAV8dUSt6KN4QlRzZvuexN0fXWbjixhW8yklYcODIWMujskGgGx6gafTatb3 pgGsY4g/8oKYCiIuW+r5HhbpA+gF5wTiV8K1PGwRvKQa0R79aSQ7C+LJq3XCDM/H HwyigFaWHduGwM+bqceDc7mOptKOc/7dEZRPZt91pjWMxSqaGydIRtvPQH21o4ac e5ZuktvCyB1/hbK6X17Qee+LfkiaJ4w/JzDWqJkjj2LexrOPRh5ZPRdmDKEHNg95 GKY/tKqON7+v8LtIuQiD =baPN -----END PGP SIGNATURE----- --=-=-=--