Page 1 of 1

Awesomeness of Porting Programs (Fully self-hosting)

Posted: Tue Apr 10, 2012 5:33 pm
by piranha
Whats the next logical step after porting gcc, make, nasm and bash? That's right, attempt self-hosting. Took several tries, and I had to modify the build system, but only slightly. All I had to do was manually create dependency files and tools (like the initrd generator).

Some ported programs: http://microsea.googlecode.com/files/selfhost1.jpeg

make compiling the kernel: http://microsea.googlecode.com/files/selfhost3.jpeg, http://microsea.googlecode.com/files/selfhost4.jpeg

Some serial port output: http://microsea.googlecode.com/files/selfhost2.jpeg

Assembling nasm files: http://microsea.googlecode.com/files/selfhost5.jpeg

Compiling modules: http://microsea.googlecode.com/files/selfhost6.jpeg

Hey, look! The compiled modules load and work properly!! http://microsea.googlecode.com/files/selfhost7.jpeg
So do the applications that are compiled! http://microsea.googlecode.com/files/selfhost8.jpeg

And then I copied the compiled kernel to /sys/kernel (which is loaded by grub on boot as the kernel) and:
Image

My operating system is officially self-hosting. I did other tests that I didn't capture, but everything was compiled properly and everything worked. Only minor things in the build system to work out, but it seems to be mostly working properly. Time to celebrate!
Edit: As an aside, it took half an hour to compile on my OS, as opposed to 30 seconds on linux.

-JL

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Tue Apr 10, 2012 5:51 pm
by gerryg400
Man, that's the definition of awesomeness.

TODO:
zlib
freetype
libpng
cairo
gtk
LXDE

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Tue Apr 10, 2012 6:02 pm
by gravaera
Yo:

...FUUUUUUUUUU D:

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Tue Apr 10, 2012 6:28 pm
by Hoozim
That's exactly where I hope to be within the next month. I just need to modify (possibly redo) my FAT filesystem driver to make it more 'ANSI C Library Compliant'. Then I need to port Newlib and finally port GCC etc.

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Tue Apr 10, 2012 8:45 pm
by Chandra
gerryg400 wrote:Man, that's the definition of awesomeness.
And Completeness, of course. piranha must be a happy man!

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Tue Apr 10, 2012 8:53 pm
by piranha
Chandra wrote:
gerryg400 wrote:Man, that's the definition of awesomeness.
And Completeness, of course. piranha must be a happy man!
If it were completeness, the date displayed after logging in wouldn't be 1982. :wink:
I am pretty happy about it.

-JL

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Tue Apr 10, 2012 10:06 pm
by Chandra
piranha wrote:If it were completeness, the date displayed after logging in wouldn't be 1982.
Hey, you're displaying your birthday in there? Kidding! Shouldn't be hard to fix.

Anyways, complete in the sense that your OS is a development platform itself.

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Wed Apr 11, 2012 7:24 am
by bluemoon
That's great! I can even feel your happiness!

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Wed Apr 11, 2012 7:53 am
by invalid
Congratulations! =D>

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Wed Apr 11, 2012 7:31 pm
by Kazinsal
Very well done. Not many folks can write an OS that can build itself, that's for sure! Lots of hobby OSes don't even have the ability to compile their own programs, let alone the kernel and modules.
piranha wrote:Edit: As an aside, it took half an hour to compile on my OS, as opposed to 30 seconds on linux.
Ah, the pitfalls of CPU emulation. What are the speeds in something like VirtualBox? Real hardware? Provided you have a working POSIX implementation and ported tools, I don't see why the OS would be at fault for speed issues. Then again, as someone who's never dabbled in tasks this complex, I'm probably not one to make anything other than wild mass guesses! ;)

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Wed Apr 11, 2012 8:56 pm
by piranha
Hey, you're displaying your birthday in there? Kidding! Shouldn't be hard to fix.
Fixed now. :wink:
Blacklight wrote:Very well done. Not many folks can write an OS that can build itself, that's for sure! Lots of hobby OSes don't even have the ability to compile their own programs, let alone the kernel and modules.
piranha wrote:Edit: As an aside, it took half an hour to compile on my OS, as opposed to 30 seconds on linux.
Ah, the pitfalls of CPU emulation. What are the speeds in something like VirtualBox? Real hardware? Provided you have a working POSIX implementation and ported tools, I don't see why the OS would be at fault for speed issues. Then again, as someone who's never dabbled in tasks this complex, I'm probably not one to make anything other than wild mass guesses! ;)
I haven't tried it recently on virtualbox, and I don't currently have a spare machine to try it on. My guess is that my POSIX stuff is not nearly as efficient as it could be (readdir is especially badly implemented, for example). Also, gcc calls /usr/libexec/.../cc1 to compile the program, and that binary is a whopping 8.5 MB. Not only is my exec() function slow, but my ata code is even slower (PIO, one sector at a time). To compile a simple program takes 12 seconds the first time gcc is invoked, and 4 seconds after that (because of read caches), but thats still really slow. The cache just speeds up access to blocks, it doesn't fix the fact that exec needs to map upwards of 9 MB of an executable each time gcc is called. Version 0.2 of my OS is focusing on doing things right, fixing bugs and hacks, and SMP and some networking. Version 0.3 will focus on making everything fast (and will require a lot of rewriting of the block device layer).

As for now, I don't mind waiting if the result is a self-compiling OS :wink:

-JL

Re: Awesomeness of Porting Programs (Fully self-hosting)

Posted: Thu Apr 12, 2012 6:52 am
by invalid
piranha wrote:Version 0.2 of my OS is focusing on doing things right, fixing bugs and hacks, and SMP and some networking. Version 0.3 will focus on making everything fast (and will require a lot of rewriting of the block device layer).
Just beware of the "second version antipattern" http://en.wikipedia.org/wiki/Second-system_effect ;)