From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA24024; Sat, 15 Nov 2003 19:54:53 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA24257 for ; Sat, 15 Nov 2003 19:54:52 +0100 (MET) Received: from mail1.tpgi.com.au (mail.tpgi.com.au [203.12.160.57]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAFIso105089 for ; Sat, 15 Nov 2003 19:54:51 +0100 (MET) Received: from 203-213-83-146-syd-ts15-2600.tpgi.com.au (203-213-83-146-syd-ts15-2600.tpgi.com.au [203.213.83.146]) by mail1.tpgi.com.au (8.11.6/8.11.6) with ESMTP id hAFIsgZ23413; Sun, 16 Nov 2003 05:54:42 +1100 Subject: Re: [Caml-list] Executable size? From: skaller Reply-To: skaller@ozemail.com.au To: John J Lee Cc: caml-list@inria.fr In-Reply-To: References: <3FB2B050.8050901@atcorp.com> <3FB3A6A6.8010108@atcorp.com> <1068903416.25869.96.camel@pelican> Content-Type: text/plain Message-Id: <1068918835.25869.263.camel@pelican> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 16 Nov 2003 04:53:56 +1100 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 ozemail:01 runtime:01 runtime:01 libgcc:01 libgcc:01 dynamically:01 hosted:99 kernels:01 way':01 libc:01 compiler:01 compiler:01 kernel:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 2003-11-16 at 02:01, John J Lee wrote: > On Sat, 16 Nov 2003, skaller wrote: > [...] > > A very large number of people do in fact build C all the > > time without any runtime library at all: embedded systems > > typically don't use any runtime. > > When you say "runtime", do you mean stuff like libc.so, or libgcc.a, or > both? Neither, crt0 is the key. It isn't a library, but initialisation code. > When, if ever, can you avoid linking with libgcc.a (or its equivalent)? > What do you lose by not linking with it? You cannot make a traditional 'main' program without some runtime support. This does things like pass command line arguments to 'main'. It also sets up registers for the generated code. For example on the x86 it is common to set all the segment registers equal. The startup code may also set up the floating point unit, signal handlers, etc. However, no 'library' code is ever required by ISO C programs unless you actually call the functions or refer to some variable. Still, if you consider say 'errno', evil as it is, you might refer to it even if you never do any file IO, so it had better be correctly initialised. Finally, even if you don't do IO, something like an 'assert' macro might, so perhaps *some* initialisation of some thing might be done in case you use them, with the compiler not really knowing if it is necessary or not. In C++, some initialisation for exception handling, RTTI, and other stuff may be needed .. even if you don't use it, it may be included *in case* you use it. In particular, this may be necessary if you dynamically link to a shared library that does use these features, and they're global and have to be set up on startup (RTTI and exception handling spring to mind here ..) Even on embedded systems, there is usually initialisation code, though it is often hand written by the client (in assembler). Finally, there is a special case where you must NOT use a runtime library, even on a hosted machine. And that is when bootstrapping the compiler and compiling the run time :-) > I don't ask for any practical reason, just to try and sort out how O'Caml, > C and C++ differ here. Well, for Ocaml the gc must be set up. In addition, signal and thread handling might have to be initialised. Perhaps some data such as command line arguments is fetched by startup code, whether or not you actually try to access it. The principal difference between Ocaml and C is that C is designed to be able to generate things like Linux kernels, and you certainly don't want to use the standard C library doing that: you're trying instead to build particular machine code in a 'high level way', and need to actually write all the functions you need yourself... since it is this kernel that actually provides some of the resources accessed by user space C libraries :-) Ocaml doesn't try to be a systems programming language, that's the difference. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners