Problem with building a cross compiler

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Sorry to bring such an old post back from the dead, but I solved my problem and wanted to make sure no one else makes the same mistake I did.

First thing you want to make sure that you have downloaded all of the necessary tools to build gcc and binutils.

Then you want to make sure that your cygwin installation defaults to binary mode and not text mode. I changed a lot of things trying to get it to work and finally I made some progress after changing to binary mode.

Thank you everyone for helping me.
Ilya
Posts: 2
Joined: Tue May 01, 2007 5:08 am
Location: USA

Re: Problem with building a cross compiler

Post by Ilya »

I also got the error
undefined reference to `_bfd_i386_arch'
while trying to compile binutils under cygwin (comfigured for DOS mode as it was recommended for building eCos).
After spending a night on that I figured out that cpu-i386.o file was not linking because Cygwin did not handled `cat ofiles` properly in the makefile. The fix for that is the following: in binutils source code, in bfd/Makefile.in, replace the line

Code: Select all

echo $$f > tofiles
by

Code: Select all

echo $$f ' ' > tofiles
After that do 'configure' and 'make' again and it should work.
frank wrote: I got an error about an undefined reference to _bfd_i386_arch
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Hmmm... if it works for you, fine - but it should and does work without any modifications to the sources.
Every good solution is obvious once you've found it.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

I had a similar problem with gcc 4.1.2 and binutils 2.17. The also gave make errors during the Cygwin build. A rebuild all didn't fix it, however reinstalling cygwin with unix style fileformat instead of windows fixed the problem.

But i agree is should work normally.
Author of COBOS
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Yeah, once you set cygwin to binary it builds just fine with no problems at all.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

frank wrote:Yeah, once you set cygwin to binary it builds just fine with no problems at all.
There is a reason why the installer says "RECOMMENDED" in all caps :roll:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Well maybe some of us can't read, haven't considered that yet have you? :wink:
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

Combuster wrote:
frank wrote:Yeah, once you set cygwin to binary it builds just fine with no problems at all.
There is a reason why the installer says "RECOMMENDED" in all caps :roll:
Yeah and you know there is a difference between RECOMMENDED and REQUIRED do you? :wink:
Author of COBOS
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

os64dev wrote:Yeah and you know there is a difference between RECOMMENDED and REQUIRED do you? :wink:
There is also a different between guru and newbie :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Well see, here was my line of thought:
I use windows. Windows uses CR-LF. All of my files are in CR-LF. I do not want to make them LF. The only one that says anything about CR-LF is text mode.
Ilya
Posts: 2
Joined: Tue May 01, 2007 5:08 am
Location: USA

Post by Ilya »

OK guys. If you want to build eCos under Cygwin, you MUST use Cygwin in DOS mode, otherwise you won't be able to do it. It is written in eCos docs and seems to be true. That is why I used DOS mode when building cross tools.

Now, here is the Cygwin (or somebody's else?) bug:

There is a file 'ofiles', which contains the following:

Code: Select all

elf32-i386.lo elf32.lo elf.lo elflink.lo elf-strtab.lo elf-eh-frame.lo dwarf1.lo coff-i386.lo cofflink.lo elf32-gen.lo cpu-i386.lo
Filenames are separated by spaces, at the end there is 0D 0A (since it was generated in DOS mode).

Now, the makefile has the following line:

Code: Select all

/bin/sh ./libtool --mode=link gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2  -o libbfd.la -rpath /gnutools/i686-pc-cygwin/i386-elf/lib -release 2.13.1  archive.lo archures.lo bfd.lo cache.lo coffgen.lo corefile.lo format.lo init.lo libbfd.lo opncls.lo reloc.lo section.lo syms.lo targets.lo hash.lo linker.lo srec.lo binary.lo tekhex.lo ihex.lo stabs.lo stab-syms.lo merge.lo dwarf2.lo archive64.lo `cat ofiles`
As you can see, it is supposed to take all the files, including the ones that are listed in 'ofiles', and build them into a library. Now, here is what happens during the execution:

Code: Select all

libtool: link: warning: undefined symbols not allowed in i686-pc-cygwin shared libraries
ar cru .libs/libbfd.a  archive.o archures.o bfd.o cache.o coffgen.o corefile.o format.o init.o libbfd.o opncls.o reloc.o section.o syms.o targets.o hash.o linker.o srec.o binary.o tekhex.o ihex.o stabs.o stab-syms.o merge.o dwarf2.o archive64.o elf32-i386.o elf32.o elf.o elflink.o elf-strtab.o elf-eh-frame.o dwarf1.o coff-i386.o cofflink.o elf32-gen.o
ranlib .libs/libbfd.a
creating libbfd.la
Note that the last file listed in 'ofiles' (cpu-i386) is somehow lost. However, if you do

Code: Select all

echo `cat ofiles`
it works fine.

This seems to be the bug (may be `cat ofiles` adds \r to the end of the last name?). So you guys better find out why this is happening rather than discuss if binary mode is recommended or required and what is the difference.
Post Reply