Browse thread
Using OCaml in a kernel
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-12-06 (08:09) |
From: | Ville-Pertti Keinonen <will@e...> |
Subject: | Re: [Caml-list] Using OCaml in a kernel |
On Mon, 2004-12-06 at 13:48 +1300, Jonathan Roewen wrote: > I'm developing an operating system, and I want to write as much of it > as possible in OCaml. I had hoped to use the ocamlopt compiler, and > have it target i586-elf, like my gcc (3.4.1) cross-compiler. I'm using > newlib with my cross-compiler, so I have a C library available. > > However, I'm lost at how to get OCaml into the mix. Anyone able to > offer some suggestions of the sorts of things I could try? You should familiarize yourself with how OCaml works in detail before you even start to plan the capabilities; it isn't going to "just work". OCaml is going to place a lot of restrictions on what you can and can't do (e.g. if you want to make the system pre-emptible, multithreaded or SMP-capable you either need to make significant changes to the OCaml runtime or exercise unusual discipline - no sharing of data except through non-OCaml objects). Note that you don't necessarily need to set up OCaml as a cross-compiler. The simplest way to start would probably be to use the native OCaml compiler on your development platform (assuming it's also i586-elf) to compile the OCaml parts. The part you need to build against newlib is the OCaml runtime (libasmrun.a) - you can do that manually. You can then use the -output-obj option of ocamlopt to produce a single OCaml object, which you can link against your C objects, newlib and your manually built libasmrun.a. There are some changes that you're definitely going to want to make if you're serious - rip out the signal handling and I/O altogether, modify the memory allocation interfaces etc. - but if you have something sufficiently functional that you can get newlib to build and work, then you might be able to get started without doing these at first.