Awesomeness of Porting Programs (Fully self-hosting)

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Awesomeness of Porting Programs (Fully self-hosting)

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

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

Post by gerryg400 »

Man, that's the definition of awesomeness.

TODO:
zlib
freetype
libpng
cairo
gtk
LXDE
If a trainstation is where trains stop, what is a workstation ?
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

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

Post by gravaera »

Yo:

...FUUUUUUUUUU D:
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Hoozim
Member
Member
Posts: 53
Joined: Fri Jul 23, 2010 8:26 am

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

Post 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.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

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

Post by Chandra »

gerryg400 wrote:Man, that's the definition of awesomeness.
And Completeness, of course. piranha must be a happy man!
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

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

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

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

Post 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.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

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

Post by bluemoon »

That's great! I can even feel your happiness!
invalid
Member
Member
Posts: 60
Joined: Thu Feb 23, 2012 8:39 am

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

Post by invalid »

Congratulations! =D>
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

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

Post 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! ;)
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

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

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
invalid
Member
Member
Posts: 60
Joined: Thu Feb 23, 2012 8:39 am

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

Post 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 ;)
Post Reply