Really Should make 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.
Post Reply
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Really Should make a Cross Compiler...

Post 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
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post 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.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
INF1n1t
Member
Member
Posts: 60
Joined: Fri Dec 22, 2006 5:32 pm
Location: Somewhere Down...

Post 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!
I think, I have problems with Bochs. The biggest one: Bochs hates me!
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
nick8325
Member
Member
Posts: 200
Joined: Wed Oct 18, 2006 5:49 am

Post 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).
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
Post Reply