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
Porting Nasm and Gcc
- Combuster
- 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:
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.
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.
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.
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.