Page 1 of 1

Porting Nasm and Gcc

Posted: Thu Dec 07, 2006 2:31 pm
by slasher
The recent discussion about self hosting has made me wonder -

What has to be done to port Nasm/Yasm and Gcc over to an operating system?

I've tried to look for this information on the web but have not been successful in finding anything.

Please, can those that know about this topic enlighten the rest of us.

Thanks

Posted: Thu Dec 07, 2006 5:30 pm
by Combuster
The process consists of three steps:

1: Compile a set of tools to run on your dev' system and build for your os
2: Use 1 to compile the same set of tools to run on your own os and build for you own os
3: Use 2 to compile your os

Voila, you're self-hosted.

For GCC-based environments, the first step (and the preparation for the second step) is described on the wiki: GCC_Cross-Compiler.

In general, you need to write a runtime, library and usually also some sort of native kernel interface before you can compile the compiler. Making these parts work is afaik the most time consuming part.

But i'm just hanging somewhere between step 1 and 2, so you'll have to find someone else with experience on the later steps.

Posted: Fri Dec 08, 2006 1:07 am
by Solar
I don't know about NASM, but GCC and binutils (on which GCC is based) are very self-contained; I would be surprised if you'd need anything beyond a functional C library and GCC / binutils themselves to port them over. I should assume NASM is similar - any really decent compiler / assembler should be capable of compiling / assembling itself.

The Wiki page Combuster pointed out is "mine", at least in part, and with PDCLib I am working towards step 2. When PDCLib v1.0 is released, I'll probably return to OS development just for the sheer fun to see a native GCC running on nothing but my code. ;-)

Posted: Fri Dec 08, 2006 9:29 pm
by slasher
Thanks for the information given. I'll start looking into self hosting as soon as I can.
I'm looking at the WIKI page mentioned above.