From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A1265BC2F for ; Mon, 6 Dec 2004 09:09:30 +0100 (CET) Received: from will.iki.fi (will.iki.fi [217.169.64.20]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iB689U3I008089 for ; Mon, 6 Dec 2004 09:09:30 +0100 Received: from ZMCXXXIII.dsl.saunalahti.fi (ZMCXXXIII.dsl.saunalahti.fi [85.76.70.234]) by will.iki.fi (Postfix) with ESMTP id D645F1F6; Mon, 6 Dec 2004 10:09:29 +0200 (EET) Subject: Re: [Caml-list] Using OCaml in a kernel From: Ville-Pertti Keinonen To: Jonathan Roewen Cc: caml-list@yquem.inria.fr In-Reply-To: References: Content-Type: text/plain Date: Mon, 06 Dec 2004 10:09:12 +0200 Message-Id: <1102320552.663.45.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41B413BA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 wrote:01 ocaml:01 ocamlopt:01 compiler:01 gcc:01 runtime:01 non-ocaml:01 compiler:01 runtime:01 libasmrun:01 -output-obj:01 ocamlopt:01 libasmrun:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: 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.