Missing start files in custom toolchain.

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.
Post Reply
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Missing start files in custom toolchain.

Post by Stevo14 »

Hi,

I have been following the guide on the wiki about creating a custom tool chain specifically for my OS. My kernel compiles fine with the new tool chain but when I go to compile a test program, ld complains that it can't find "crtbegin.o". I know the reason for this, it is because my kernel uses a custom linker script that doesn't drag in start files and the like. I also understand that "crtbegin.o" (and probably "crtend.o") come from gcc. My question is, how can I get gcc to generate these files during the build process? Even if they are just asm stubs that do nothing?

Also, if I pass "-nostartfiles" (or something like that) to my custom gcc to build the program it stops complaining about the "crt*.o" files (as expected) but then complains about not being able to find "libgcc".

I have checked the installation directories and neither libgcc or any of the start files (except for crt0 form newlib) are there. It seems that something is missing from my gcc build, but I can't figure out what. :?
Mounter
Posts: 8
Joined: Sun Aug 12, 2007 12:45 pm
Location: Feliz, Rio Grande do Sul, Brazil
Contact:

Re: Missing start files in custom toolchain.

Post by Mounter »

This file is created when you run the command to compile the libgcc, for this run the command:

Code: Select all

make
and then

Code: Select all

make install
To finish the compilation of gcc.
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Re: Missing start files in custom toolchain.

Post by Stevo14 »

I've tried your suggestion and it now complains about not having floating/fixed point support. It seems logical that I would have to add it myself (floating point is rather hardware dependent) but I have no idea where to add it. Google hasn't been any help here.
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:

Re: Missing start files in custom toolchain.

Post by Combuster »

in my case floating point stuff works out of the box.

I do however link with ld directly rather than via gcc
"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
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Missing start files in custom toolchain.

Post by JamesM »

Stevo14 wrote:Hi,

I have been following the guide on the wiki about creating a custom tool chain specifically for my OS. My kernel compiles fine with the new tool chain but when I go to compile a test program, ld complains that it can't find "crtbegin.o". I know the reason for this, it is because my kernel uses a custom linker script that doesn't drag in start files and the like. I also understand that "crtbegin.o" (and probably "crtend.o") come from gcc. My question is, how can I get gcc to generate these files during the build process? Even if they are just asm stubs that do nothing?

Also, if I pass "-nostartfiles" (or something like that) to my custom gcc to build the program it stops complaining about the "crt*.o" files (as expected) but then complains about not being able to find "libgcc".

I have checked the installation directories and neither libgcc or any of the start files (except for crt0 form newlib) are there. It seems that something is missing from my gcc build, but I can't figure out what. :?
Just touch them. They don't need to contain anything, just exist.

Code: Select all

touch $PREFIX/lib/gcc/i686-elf/4.3.0/crt0.o $PREFIX/lib/gcc/i686-elf/4.3.0/crtbegin.o $PREFIX/lib/gcc/i686-elf/4.3.0/crtend.o
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Re: Missing start files in custom toolchain.

Post by Stevo14 »

JamesM wrote: Just touch them. They don't need to contain anything, just exist.

Code: Select all

touch $PREFIX/lib/gcc/i686-elf/4.3.0/crt0.o $PREFIX/lib/gcc/i686-elf/4.3.0/crtbegin.o $PREFIX/lib/gcc/i686-elf/4.3.0/crtend.o
Thanks, that seems to do the trick. However, it still complains about not finding libgcc. The exact error is:

Code: Select all

stephen@stephen-laptop ~/P/F/t/p/turtle> make
#
# turtle shell
/home/stephen/Programming/Fluidium/trunk/toolchain/cross/lib/gcc/i586-pc-fluidium/4.3.2/../../../../i586-pc-fluidium/bin/ld: cannot find -lgcc
collect2: ld returned 1 exit status
make: *** [all] Error 1
stephen@stephen-laptop ~/P/F/t/p/turtle> 
Should I do the same as above and just create an empty "libgcc.a" file?
Combuster wrote:in my case floating point stuff works out of the box.
I do however link with ld directly rather than via gcc
Here is the actual error. It happens during the configuration process:

Code: Select all

checking whether decimal floating point is supported... no
checking whether fixed-point is supported... no
*** Configuration i586-pc-fluidium not supported
make[1]: *** [configure-target-libgcc] Error 1
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Missing start files in custom toolchain.

Post by JamesM »

No, you should make a libgcc.

Code: Select all

make all-target-libgcc; make install-target-libgcc
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Re: Missing start files in custom toolchain.

Post by Stevo14 »

Thanks everyone for the help. I've solved these problems by a) targeting i586-elf instead of a custom target which fixes the floating point issue and b) compiling all of gcc ("make all" instead of "make all-gcc") which builds a libgcc (like JamesM pointed out) and fixes the problem with the start files.
User avatar
TyrelHaveman
Member
Member
Posts: 40
Joined: Thu Sep 20, 2007 11:20 pm
Location: Bellingham, WA
Contact:

Re: Missing start files in custom toolchain.

Post by TyrelHaveman »

Stevo14 wrote:Thanks everyone for the help. I've solved these problems by a) targeting i586-elf instead of a custom target which fixes the floating point issue and b) compiling all of gcc ("make all" instead of "make all-gcc") which builds a libgcc (like JamesM pointed out) and fixes the problem with the start files.
Hi,

I just discovered something that might help you even more (in the process of doing the same thing): to get libgcc to compile on your custom target, edit libgcc/config.host to include your OS. To match the style of the toolchain tutorial on the wiki:

Code: Select all

i[3-7]86-*-myos*)
        ;;
And then your make, instead of just all-gcc and install-gcc, should also have all-target-libgcc and install-target-libgcc. This will get you libgcc.a, crtbegin.o, crtend.o, etc.

That should probably be added to that wiki page.

Tyrel
Post Reply