Page 1 of 1

Really Should make a Cross Compiler...

Posted: Mon Apr 09, 2007 7:21 am
by AJ
Hi,

I normally compile my kernel on a WinXP machine using DJGPP with arguments to prevent use of the built in libc and standard runtime:

Code: Select all

-Wall -O -fno-builtin -nostartfiles -fstrength-reduce -nostdinc -fnostdlib -ffreestanding
which seems to work fine - I tend to produce coff executables which my second stage loader can handle.

Problem is, I just tried to 'install' djgpp on my home Win2k box and with the above parameters get the message:

Code: Select all

bin/main.o:main.c:(.text+0x13): undefined reference to `_alloca'
bin/main.o:main.c:(.text+0x18): undefined reference to `__main'
..which seems to indicate to me that gcc is attempting to use its built in runtime.

For this reason, I have tried to follow the cygwin x-compiler instructions but after binutils and gcc compile, I get error messages like the following:

Code: Select all

checking errno.h usability...   11138 [main] sh 116856 fork: child -1 - died wai
ting for longjmp before initialization, retry 0, exit code 0x80, errno 11
     44 [main] sh 107312 fork: child -1 - died waiting for longjmp before initia
lization, retry 0, exit code 0x80, errno 11
I don't mind whether I get cygwin or djgpp working, and sorry it's kind of 2 questions in one, but they're related to the same problem. Any ideas much appreciated.

Cheers,
Adam

Posted: Mon Apr 09, 2007 11:48 am
by mystran

Code: Select all

 -nostdinc -nostdlib -fno-builtin -ffreestanding -fno-common
That's what I use, works on Linux, GCC 3.3.2. Compiler flags like that can change a bit between different versions, so make sure you have the flags correctly for the version you are using.

Ofcourse I use lots of more flags, but those are the flags relevant for compiling without normal libs.

Posted: Tue Apr 10, 2007 2:38 pm
by INF1n1t
Maybe it won't help you, but on cygwin: run the setup program, reinstall cygwin, gcc, binutils important packages and then follow the gcc-cross-compiler tutorial. Sorry, if the advice is wrong!

Posted: Wed Apr 11, 2007 4:46 am
by AJ
Thanks - the extra switch (I wasn't using -nostartfiles) didn't help unfortunately.

I will give it a go re-installing cygwin again. I know in the past people have been told "The tutorial just works so make sure you follow it *exactly*..." but I have already re-installed a couple of times, and if I am doing something wrong, I am obviously doing it wrong every time...

Cheers,
Adam

Posted: Wed Apr 11, 2007 6:25 am
by nick8325
Do you still have DJGPP installed on the machine that's running Cygwin? If so, try removing that first (it could be that GCC's configure script is running DJGPP programs instead of Cygwin programs).

Posted: Wed Apr 11, 2007 6:40 am
by AJ
Hi,

Thanks, I'll try that. I had removed c:\djgpp\bin from my PATH variable and had assumed that would be enough, but I'll try a full uninstall - could work!

Unfortunately I'm just on my XP machine today so can't try yet...

Adam