Page 1 of 1
Import GCC
Posted: Wed Jun 09, 2004 7:04 pm
by firas981
How to import GCC to my own os , so I can compile c programs under my os ?
thanks
Re:Import GCC
Posted: Thu Jun 10, 2004 1:38 am
by Solar
What you ask for is called "bootstrapping".
It's not really *that* difficult. Your OS must be capable of loading and executing programs. You will need a C runtime - i.e. a C library for your platform, and the code that does the startup and shutdown of a program. (There are things happening before int main() is called, and things happening after main() returns. This code usually resides in crt0.o.) You need to have a platform definition for GCC - if you are working with files of a known format on a known platform (e.g. ELF / x86), such a definition is already available.
At this point, you can build a cross-compiler for your platform - the
GCC Cross-Compiler page tells you the first few steps, and links to other pages explaining further steps.
And once you have a working cross-compiler, all you have to do is to cross-compile GCC itself... and there you have a GCC that runs on your platform.
(Note, that's the easy answer. There can be any number of problems, including necessary tweaks to GCC to understand your file system layout, bugs in your OS, or adaptions to your executable type etc. etc.)
Re:Import GCC
Posted: Thu Jun 10, 2004 1:39 am
by Pype.Clicker
well, make sure your kernel can load files generated by GCC and offer the STDlib (or at least the parts which GCC requires) ...
You may also want to use a simpler compiler at start (Tiny C Compiler, for instance) as the xMB of GCC sources might be a pain to crawl for library dependencies...
Re:Import GCC
Posted: Thu Jun 10, 2004 11:45 pm
by Nairou
What about posix? I always assumed GCC and all the GNU tools relied heavily on the posix API. What about OSs (like mine) that don't plan on having posix compliance?
Re:Import GCC
Posted: Fri Jun 11, 2004 6:14 am
by Solar
I'd daresay the API dependencies of GCC and binutils are much less serious than you might think. Basically, they are reading files, and writing files / printing to screen. There's little (if anything) in there that isn't covered by the plain C standard.
Regarding the Tiny C compiler... note that newer GCC versions require a C90 compatible compiler.