Linux and C in the browser

There was a time when it was difficult to learn to write low-level driver or kernel code. You really needed two machines: one to work with, and one to screw repeatedly until fixed. These days you can just spin a virtual machine and bring it back every time you screw it completely. More easy! We don’t think it’s all real, but [nsommer] There is an interesting post about loading a C compiler and compiling Linux for a virtual machine. What’s new? Oops, the virtual machine is in your browser.

The v86 CPU emulator runs in browsers and looks like a Pentium III computer with simple hardware. You might think it’s slow and it certainly won’t be as fast as a rocket, but it translates machine code into WebAssearch, so the performance isn’t as bad as you might think.

This post describes in detail how to create and create a simple machine web page hosted by v86. Once you have cross-compiled the kernel you can virtually boot the machine. Other interesting parts are added tcc Which is a fantastic capable C compiler and much smaller and faster than very traditional gcc.

The tcc Building is difficult because the normal build process compiles the compiler and then uses the same compiler to create the default library. When cross-compiling, it doesn’t work well because the library you want for the host compile is different from the library you want for the second pass. You will see how to work around this in the post. The post continues to show how to do remote debugging and even takes QIMU into the mix. Debugging inside v86 doesn’t seem to work yet. Promised to have more posts on this topic.

Honestly, it’s one of those things that teaches a chicken to play checkers. It can be done, there is little practical value, but it is still something to look forward to. On the other hand, if you work through it on the weekends, it will seem easier to compare your next Linux porting project.

What you can pull off with WebAssearch is amazing. If you need a quick introduction, check it out [Ben James].

Leave a Reply

Your email address will not be published.