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

Problem with building a cross compiler

Post by frank »

Hello,

For several days now I have been trying to build a GCC cross compiler capable of producing plain binary files for my kernel. I cannot get it to work no matter how hard I try. Any help or suggestions?

Host Compiler: GCC version 3.4.4
Host binutils: version 2.17.50

The binutils version I am trying to build is 2.17 from gnu.org

I am using Cygwin. Everything is up too date and I just downloaded it a couple of days ago. I tried:

Code: Select all

configure --target=i686-elf --prefix=/cbin --disable-nls
and it worked just fine, but after running make I get the following error

Code: Select all

Configuring in ./libiberty
configure: error: invalid feature name: nls
I also tried it without --disable-nls but after about an hour of scrolling text I got an error about an undefined reference to _bfd_i386_arch

Thanks for your time,

Frank
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 »

there's a step-by-step explanation on the wiki. It lists some pitfalls. So far, that always worked for me.
"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 ]
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post by Candy »

i686-elf isn't a valid target, try i686-pc-elf. That could be a small problem, but I don't think it's your main problem...
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 »

Candy wrote:i686-elf isn't a valid target, try i686-pc-elf. That could be a small problem, but I don't think it's your main problem...
:shock:
I never noticed any differences between i386-elf and i386-*-elf...
"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 ]
User avatar
gaf
Member
Member
Posts: 349
Joined: Thu Oct 21, 2004 11:00 pm
Location: Munich, Germany

Post by gaf »

Hello,
I've uploaded a cygwin hosted toolchain to my sourceforge project some time ago (link). It's should still be up to data and you might give it a try if you can't solve your compiler issue.

regards,
gaf
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Thanks gaf. I will look into that. Can they output a plain binary?

I followed the step by step explanation on the wiki and I still get those errors. I never get past building binutils. Do you think that I should try to build earlier version of binutils, like 2.16.1.

Thanks for your help,
Frank
MHaggag
Posts: 1
Joined: Tue Jan 02, 2007 8:11 am

Post by MHaggag »

I've had different trouble with building i686-elf targetted tools before--they kept segfaulting on my kernel builds. I tried building for i586-elf instead and it worked, so it might be worth trying it out. (Reference thread: http://www.osdev.org/phpBB2/viewtopic.php?t=11813)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

frank wrote:I followed the step by step explanation on the wiki and I still get those errors. I never get past building binutils.
Check again pedantically that you are following the steps in the Wiki. I mean, pedantically.

For example, your example configure call doesn't have the leading ../binutils-... part - are you really outside the binutils source tree, and are you really calling the configure script of the binutils source tree? Please do try the exact instructions from the Wiki before trying any deviations. The Wiki instructions do work, and do so reliably.
Do you think that I should try to build earlier version of binutils, like 2.16.1.
No. 2.17 is proven to work.
Every good solution is obvious once you've found it.
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:Do you think that I should try to build earlier version of binutils, like 2.16.1.
From user experience: 2.16.1 has a nasty bug in GAS.
Also what people tend to forget, you need flex and bison installed
"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 »

Hello,

This is exactly what I tried and the output I received:

Code: Select all

Frank Holton@franks-computer /usr/src/build-binutils
$ export PREFIX=/usr/cross

Frank Holton@franks-computer /usr/src/build-binutils
$ export TARGET=i586-elf

Frank Holton@franks-computer /usr/src/build-binutils
$ cd /usr/src/build-binutils

Frank Holton@franks-computer /usr/src/build-binutils
$ ../binutils-2.17/configure --target=$TARGET --prefix=$PREFIX --disable-nls
creating cache ./config.cache
checking host system type... i686-pc-cygwin
checking target system type... i586-pc-elf
checking build system type... i686-pc-cygwin
checking for a BSD compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for gnatbind... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f
2
checking for correct version of gmp.h... no
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... makeinfo
checking for expect... expect
checking for runtest... runtest
checking for i686-pc-cygwin-ar... no
checking for ar... ar
checking for i686-pc-cygwin-as... no
checking for as... as
checking for i686-pc-cygwin-dlltool... no
checking for dlltool... dlltool
checking for i686-pc-cygwin-ld... /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../
i686-pc-cygwin/bin/ld.exe
checking for i686-pc-cygwin-lipo... no
checking for lipo... no
checking for i686-pc-cygwin-nm... no
checking for nm... nm
checking for i686-pc-cygwin-ranlib... no
checking for ranlib... ranlib
checking for i686-pc-cygwin-strip... no
checking for strip... strip
checking for i686-pc-cygwin-windres... no
checking for windres... windres
checking for i686-pc-cygwin-objcopy... no
checking for objcopy... objcopy
checking for i686-pc-cygwin-objdump... no
checking for objdump... objdump
checking for i586-elf-cc... no
checking for i586-elf-gcc... no
checking for i586-elf-c++... no
checking for i586-elf-g++... no
checking for i586-elf-cxx... no
checking for i586-elf-gxx... no
checking for i586-elf-gcc... no
checking for i586-elf-gcj... no
checking for i586-elf-gfortran... no
checking for ar... no
checking for i586-elf-ar... no
checking for as... no
checking for i586-elf-as... no
checking for dlltool... no
checking for i586-elf-dlltool... no
checking for ld... no
checking for i586-elf-ld... no
checking for lipo... no
checking for i586-elf-lipo... no
checking for nm... no
checking for i586-elf-nm... no
checking for objdump... no
checking for i586-elf-objdump... no
checking for ranlib... no
checking for i586-elf-ranlib... no
checking for strip... no
checking for i586-elf-strip... no
checking for windres... no
checking for i586-elf-windres... no
checking where to find the target ar... just compiled
checking where to find the target as... just compiled
checking where to find the target cc... pre-installed
checking where to find the target c++... pre-installed
checking where to find the target c++ for libstdc++... pre-installed
checking where to find the target dlltool... just compiled
checking where to find the target gcc... pre-installed
checking where to find the target gcj... pre-installed
checking where to find the target gfortran... pre-installed
checking where to find the target ld... just compiled
checking where to find the target lipo... pre-installed
checking where to find the target nm... just compiled
checking where to find the target objdump... just compiled
checking where to find the target ranlib... just compiled
checking where to find the target strip... just compiled
checking where to find the target windres... just compiled
checking whether to enable maintainer-specific portions of Makefiles... no
updating cache ./config.cache
creating ./config.status
creating Makefile

Frank Holton@franks-computer /usr/src/build-binutils
$ make all install
make[1]: Entering directory `/usr/src/build-binutils'
mkdir -p -- ./libiberty
Configuring in ./libiberty
configure: error: invalid feature name: nls
make[1]: *** [configure-libiberty] Error 1
make[1]: Leaving directory `/usr/src/build-binutils'
make: *** [all] Error 2
I'm sorry if I'm missing something really simple.

Yes I have flex and bison.

By the way, do I need to download the GCC packages to be able to build just binutils?

Thanks gaf, they will do just fine. I would really like to get all of this to work so I can build a compiler for my OS( one day )

Thanks for your help,
Frank
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 »

At this point, I suspect a broken cygwin download... :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 ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Once again the proof-of-concept regression test...

<deleting local Cygwin installation>
<installing Cygwin default install>
<installing Cygwin packages gcc-core / flex / bison / make>
<testing...>

Works for me. So either your Cygwin setup is broken, or... I don't know.
frank wrote:By the way, do I need to download the GCC packages to be able to build just binutils?
No.
Every good solution is obvious once you've found it.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Well thanks everybody for your help. Maybe one day in the future I will try it again.

Yea I think I got a bad download. It just takes forever on 56k and I can't watch it the whole time.

Thanks,
Frank
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

frank wrote:It just takes forever on 56k...
YIKES!

If you drop me a PM with your postal address, I can send you a CD or DVD with the current Cygwin packages.
Every good solution is obvious once you've found it.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Thanks, but it's not that big of a deal. It only takes a couple of hours. :wink:

I downloaded gaf's toolchain and I think that they will work until I need to port GCC over to my OS.

Thanks,
Frank
Post Reply