caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Creating nativecode apps
@ 2005-07-22  4:49 Jonathan Roewen
  2005-07-22 11:22 ` Damien Bobillot
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Roewen @ 2005-07-22  4:49 UTC (permalink / raw)
  To: caml-list

Hi,

Where could I find information about how the ocamlopt compiler
generates object files?

I'm almost at a point where DST could retrofit the ocamlopt.opt
compiler to run on it, and it might be an idea to write some tools in
ocaml to do things like linking and what not so that we don't need a C
environment to be self-hosting.

Jonathan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Creating nativecode apps
  2005-07-22  4:49 [Caml-list] Creating nativecode apps Jonathan Roewen
@ 2005-07-22 11:22 ` Damien Bobillot
  2005-07-23  5:38   ` Jonathan Roewen
  0 siblings, 1 reply; 5+ messages in thread
From: Damien Bobillot @ 2005-07-22 11:22 UTC (permalink / raw)
  To: Jonathan Roewen; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]


Le 22 juil. 05 à 06:49, Jonathan Roewen a écrit :

> Where could I find information about how the ocamlopt compiler
> generates object files?
>
> I'm almost at a point where DST could retrofit the ocamlopt.opt
> compiler to run on it, and it might be an idea to write some tools in
> ocaml to do things like linking and what not so that we don't need a C
> environment to be self-hosting.

ocamlopt work exactly the same way ocamlc does.

"ocamlopt -c file.ml" to compile one ocaml source (you'll get a  
file.cmx and a file.o files)

"ocamlopt -o test file.cmx alib.cmxa" to link the executable against  
the alib library.

-- 
Damien alias Schmurtz
aim:goim?screenname=schmuuurtz


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2375 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Creating nativecode apps
  2005-07-22 11:22 ` Damien Bobillot
@ 2005-07-23  5:38   ` Jonathan Roewen
       [not found]     ` <1122104179.42e1f37350e2a@www.crans.org>
  2005-07-23 12:36     ` Jacques Garrigue
  0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Roewen @ 2005-07-23  5:38 UTC (permalink / raw)
  To: Damien Bobillot; +Cc: caml-list

> ocamlopt work exactly the same way ocamlc does.
> 
> "ocamlopt -c file.ml" to compile one ocaml source (you'll get a
> file.cmx and a file.o files)
> 
> "ocamlopt -o test file.cmx alib.cmxa" to link the executable against
> the alib library.

Let me rephrase. What do the ocaml compilers need a C compiler for?
And, if I use -output-obj, is the object file created solely by the
ocaml compilers, or does this depend on a C compiler?

Jonathan


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Creating nativecode apps
       [not found]     ` <1122104179.42e1f37350e2a@www.crans.org>
@ 2005-07-23  7:46       ` Stephane.Glondu
  0 siblings, 0 replies; 5+ messages in thread
From: Stephane.Glondu @ 2005-07-23  7:46 UTC (permalink / raw)
  To: Jonathan Roewen; +Cc: caml-list

Ooops... Sorry for double mail, Jonathan.

Selon Jonathan Roewen <jonathan.roewen@gmail.com>:
> Let me rephrase. What do the ocaml compilers need a C compiler for?
> And, if I use -output-obj, is the object file created solely by the
> ocaml compilers, or does this depend on a C compiler?

It depends on a C compiler. Actually, ocamlopt generates an assembler file
which is then linked with the runtime, which is written in C (but already
compiled, of course). That runtime uses a lot of C stdlib, but you should be
able to get rid of it for your purpose.


Stephane Glondu


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Creating nativecode apps
  2005-07-23  5:38   ` Jonathan Roewen
       [not found]     ` <1122104179.42e1f37350e2a@www.crans.org>
@ 2005-07-23 12:36     ` Jacques Garrigue
  1 sibling, 0 replies; 5+ messages in thread
From: Jacques Garrigue @ 2005-07-23 12:36 UTC (permalink / raw)
  To: jonathan.roewen; +Cc: caml-list

From: Jonathan Roewen <jonathan.roewen@gmail.com>

> Let me rephrase. What do the ocaml compilers need a C compiler for?
> And, if I use -output-obj, is the object file created solely by the
> ocaml compilers, or does this depend on a C compiler?

You must distinguish the bytecode and native code cases.
As far as I can follow the code in bytecomp/bytelink.ml and
asmcomp/asmlink.ml, in the first case a C compiler is needed, as
ocamlc generates some glue code written in C. This is not surprising,
as ocamlc knows nothing about native objects, so all interaction
requires some glue compiled with a C compiler, this is also true for
-custom. On the other hand, ocamlopt can generate assembler code, so
it doesn't really require a C compiler. However it requires working
assembler and linker. In some cases it may even choose to use gcc as
front end to either of them, while not feeding it C code.

The problem is of course that generally, if you've got a  linker and
an assembler, you've also got a C compiler. The only exception that
comes to mind is commercial Unixes like Solaris, if you really don't
want to install gcc. So I'm afraid that the answer is rather that
ocamlopt depends on a working compiling environment, even if this
might not include a C compiler.

The only case nothing is required from the environment is when using
ocamlc with shared libraries (i.e. without -custom). This was an
important reason to support them.

Jacques Garrigue


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-07-23 12:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-22  4:49 [Caml-list] Creating nativecode apps Jonathan Roewen
2005-07-22 11:22 ` Damien Bobillot
2005-07-23  5:38   ` Jonathan Roewen
     [not found]     ` <1122104179.42e1f37350e2a@www.crans.org>
2005-07-23  7:46       ` Stephane.Glondu
2005-07-23 12:36     ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).