Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Ömer Sinan Ağacan" <omeragacan@gmail.com>
To: Dawid Toton <d0@wp.pl>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: OCaml binary formats -- how are they linked?
Date: Fri, 14 Jun 2013 22:17:05 +0300	[thread overview]
Message-ID: <CAMQQO3mEPo6mtt_d0HzM6Eps2mqM=4vSJdKwK=YoAx=8r_LAfw@mail.gmail.com> (raw)
In-Reply-To: <kpf971$3f8$1@ger.gmane.org>

Dawid, thanks for your answer. It really helped.

And now I have some more questions(that's a part of learning process, right? ;-)

> You can see what actually happens with
>
> ocamlopt -verbose -c a.ml
> ocamlopt -verbose -cc 'gcc --verbose' a.cmx

I added -verbose parameter in my Makefile, and output was interesting,
it called gcc! At first I thought it's called just for linking
purposes, but later I realized there is also a C file passed to gcc.

It first passed output parameter (`-o executableName`), later some -L
parameters. And after that it passed the file `/tmp/camlprimcb16b7.c`.
What is that file? I couldn't read it because it was deleted after
compilation.

Later some parameters are passed for statically linking(-ldl, -lm,
-lpthread, -lcamlrun etc.).


> strace -e trace=open ./myexecutable

This is so great .. A format-independent way to see dynamically linked
libraries. Thanks for the tip! (btw, is there a different name given
to the process of dynamically loading and linking libraries with
`dload` like system calls? is it also called `dynamically linked`?)


> Bytecode is compiled to a files with #! prefix.

Interesting, I just tried reading an OCaml executable created with
ocamlc, and it had a ELF header. Am I compiling to my program to
native by mistake? I'm not calling ocamlopt, only ocamlc.

Thanks again,


---
Ömer Sinan Ağacan
http://osa1.net

  reply	other threads:[~2013-06-14 19:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-14  9:30 [Caml-list] " Ömer Sinan Ağacan
2013-06-14 10:16 ` [Caml-list] " Dawid Toton
2013-06-14 12:02   ` Ömer Sinan Ağacan
2013-06-14 14:26     ` Dawid Toton
2013-06-14 19:17       ` Ömer Sinan Ağacan [this message]
2013-06-17  0:18         ` Philippe Wang
2013-06-17 12:12           ` Ömer Sinan Ağacan
2013-06-17 12:34             ` Philippe Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMQQO3mEPo6mtt_d0HzM6Eps2mqM=4vSJdKwK=YoAx=8r_LAfw@mail.gmail.com' \
    --to=omeragacan@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=d0@wp.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox