This is the mail archive of the
crossgcc@cygnus.com
mailing list for the crossgcc project.
Re: NT/Win32 cross Linux compiler
- To: crossgcc@cygnus.com
- Subject: Re: NT/Win32 cross Linux compiler
- From: "Kai Ruottu" <karuottu@freenet.hut.fi>
- Date: Thu, 1 Jul 1999 12:53:26 +0000
- Organization: Freenet Finland
- Reply-To: crossgcc@cygnus.com
Brendan Simon <brendan@dgs.monash.edu.au> wrote:
> Kevin Farrell wrote:
>
> > Hi,
> >
> > I'm trying to build a Win32-hosted Linux-targetting cross-compiler using the
> > Canadian cross compiler process.
> >
> > (2-1) Now I'm wondering where do I get the linker from? Do I use the linker
> > from a Windows installation of the Cygwin32 binaries?
>
> You can use the cygwin32 linker (ie. ld) but you must use the linker scripts for
> your target and link with libraries compiled for your target.
This isn't possible, the cygwin linker supports only the i386pe-format :
E:\cygnus\cygwin-b20\H-i586-cygwin32\bin>ld -V
GNU ld version 2.9.4 (with BFD 2.9.4)
Supported emulations:
i386pe
but the Linux-binaries need the support for elf_i386 (and for the old i386linux
'aout') format :
E:\usr\local\i586-linux-gnu\bin>ld -V
GNU ld version 2.9.1 (with BFD 2.9.1)
Supported emulations:
elf_i386
i386linux
Building GNU binutils for the i586-cygwin host / i586-linux-gnu target
(or for both the i586-cygwin and i586-linux-gnu targets) is the only way.
> > (2-2) I tried to build the binutils-2.9.1 using the i586-cygwin32
> > Linux->Windows compiler (which I mentioned at the start of this mail), but I
> > get the following error:
> >
> > ../libiberty/libiberty.a ../bfd/.libs/libbfd.a: could not read symbols:
> > Archive has no index; run ranlib to add one
> >
> > I tried running ranlib on libbfd.a but it doesn't make any difference.
Running 'ranlib' is a little misleading info, the 'libiberty.a' and 'libbfd.a'
are libraries for the 'host' to come, i.e. 'cygwin', so handling them with your
'i586-cygwin-ranlib' would have been the right info... But the error messages
are of course always 'generic' and it is assumed that the user knows which
'ranlib' to run.
Anyway the Makefile should have found your 'ar', 'ranlib', 'nm' etc. for the
cygwin target when building the 'libiberty.a' and 'libbfd.a'. I cannot be sure,
because I always define these things when configuring anything. In your case I
would have used a script something like follows :
GCC_FOR_BUILD=gcc \
AR_FOR_BUILD=ar \
RANLIB_FOR_BUILD=ranlib \
NM_FOR_BUILD=nm \
CC="i586-cygwin32-gcc -m486" \
CFLAGS="-O -Wall" \
AR=i586-cygwin32-ar \
RANLIB=i586-cygwin32-ranlib \
NM=i586-cygwin32-nm \
./configure --build=i586-linux-gnu --host=i586-cygwin32 \
--target=i586-linux-gnu
to configure the binutils sources for 'cygwin32-to-i586-linux-gnu'. The
CC and CFLAGS are used as demonstrations about how to give several options for
a tool...
Making this kind of 'conf_cygw2linux.sh' script and then running it for
the first time takes just a little more time than writing it straight to a
command line, but when it is available as a template for further configures,
you'll find it very useful. The build system defs are always the same, and if
the host is the same too, just editing the '--target=xxx' is enough. Having a
naming systems helps too, e.g :
conf_linux2cygw2.sh - configures for Linux-to-Cygwin
conf_linux2m68k-coff.sh - configures for Linux-to-m68k-coff
conf_cygw2m68k-coff.sh - configures for Cygwin-to-m68k-coff
conf_cygw2arm-coff.sh - configures for Cygwin-to-arm-coff
Not letting 'configure' to guess anything is always the safe way...
If you want to use the same linker for both the 'i386pe' and 'elf_i386'
formats, just use the '--target=i586-cygwin32 --enable-targets=i586-linux-gnu',
to make your cygwin-hosted binutils to support both the cygwin and linux
formats. But the resulting 'as.exe' doesn't support 'elf_i386' etc. and you
must rebuild 'plain i586-linux-gnu'-target binutils to get the right
'as.exe'... I suggest building the 'plain i586-linux-gnu' binutils first, and
thinking the combination of the native-cygwin and linux-target binutils
later...i.e. your 'universal' linker would the show something like :
E:\usr\bin>ld -V
GNU ld version 2.9.4 (with BFD 990324)
Supported emulations:
i386pe
elf_i386
i386linux
Regards, Kai
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.