Porting Nasm and Gcc

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
slasher
Posts: 17
Joined: Sun Oct 24, 2004 11:00 pm
Contact:

Porting Nasm and Gcc

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

Post 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.
"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
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post 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. ;-)
Every good solution is obvious once you've found it.
slasher
Posts: 17
Joined: Sun Oct 24, 2004 11:00 pm
Contact:

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