Page 1 of 1

Missing start files in custom toolchain.

Posted: Tue Sep 30, 2008 2:34 pm
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. :?

Re: Missing start files in custom toolchain.

Posted: Tue Sep 30, 2008 6:40 pm
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.

Re: Missing start files in custom toolchain.

Posted: Wed Oct 01, 2008 5:25 am
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.

Re: Missing start files in custom toolchain.

Posted: Wed Oct 01, 2008 5:57 am
by Combuster
in my case floating point stuff works out of the box.

I do however link with ld directly rather than via gcc

Re: Missing start files in custom toolchain.

Posted: Wed Oct 01, 2008 6:31 am
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

Re: Missing start files in custom toolchain.

Posted: Wed Oct 01, 2008 12:11 pm
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

Re: Missing start files in custom toolchain.

Posted: Thu Oct 02, 2008 3:56 pm
by JamesM
No, you should make a libgcc.

Code: Select all

make all-target-libgcc; make install-target-libgcc

Re: Missing start files in custom toolchain.

Posted: Sat Oct 04, 2008 3:19 pm
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.

Re: Missing start files in custom toolchain.

Posted: Fri Nov 28, 2008 11:13 pm
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