Login or Sign Up WebLinux Linux live on the web!
Member Login
Not a member? Sign up now!
Rss Feed
Subscribe
Recent Posts
Oh the Insanity New Look I told you we weren't dead! Not Dead, Just Sleeping Compiled C live on the web Development Progress One Step Closer Adobe release 64 bit flash for Linux New site New Domain Its gonna be a while... Hello World! ALSA, runtime includes, and processes... 0.6.2 is released! Hurrying Slowly webLinux Blog - isnt it ugly
Darkroses blog
Compiled C live on the web
By: darkrose
I'm a little late getting this post up, as te snapshot below is now almost a week old. But it is still a fairly significant build, mainly because this is the first time we have successfully:

Written a program in C

Compiled it

Ran it on webLinux

This is a pretty huge step. But before anyone gets too excited, it was only a hello world, and that's about all the 'compiler' can handle at the moment... printf() and return.

And it's really fussy about how the program is written. Just about anything could cause it to go wrong. Including comments in the code, any variables, single quotes, functions other than printf... lots of things.

And fork() doesn't exist in the kernel yet, and there's no linking of libraries (I had to write an extremely basic printf() and put it in the initrd so it'd work).

But it's still pretty exciting, even if there is a long way to go. For the curious who don't want to download the whole snapshot, here's what a compiled hello world looks like in Process Object Format:

var element = {
	so_inc : 'stdio.h',
	o_inc : '',
	f_keys : {main:0},
	run : null,
	run_pos : null,
	set_adv : null,
	mem : null,
	scope : 0,
	0 : function() {printf([104,101,108,108,111,32,119,111,114,108,100,10]);},
	1 : function() {sys_exit.call(this,0);}
}


In the snapshot you'll find libc/simple_compile.php which is the extremely basic compiler that was used.

The kernel had a fair bit of work done to it to, there is now printk() and sys_exit() functions for output/logging from the kernel, and exiting processes. Memory management also got a bit of a rewrite to simplify things down a little, while giving easier access to memory... there's more to come there though.

Plus there's a config file for the kernel now at kernels/kernel_source/kconfig which allows for some settings to be changed relatively easily. At present it just contains default log levels which get written in at compile time.

We've made the source available in zip and tar.gz formats this time too, as it was pointed out to me a lot of windows users may not have the ability to extract a tarball.


There are no comments for this blog entry.