caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Segmentationfault on 64bit when called from C
Date: Tue, 31 Jul 2012 16:29:40 +0200	[thread overview]
Message-ID: <5017EBD4.9080904@inria.fr> (raw)
In-Reply-To: <4123447.LCvNL5nQdx@arges>

On Tuesday 31 July 2012 14:59:14 Gerd Stolpmann wrote:

> The -shared switch generates a library that is prepared to be loaded
> with Dynlink. Dynlink registers the frametable.

You're right that .so libraries produced by -shared should only be
used in conjunction with Dynlink.  However, in this case the frame
table isn't the culprit, as the crash occurs before the GC even has a
chance to run.

On 07/31/2012 04:03 PM, Georg Martius wrote:

> ocamlopt -output-obj -o camlcode.o interface.c m1.ml
> gcc -fPIC -g -Wall  -c -I/usr/local/lib/ocaml interface.c
> gcc -fPIC -o test main.c camlcode.o  interface.o -L/usr/local/lib/ocaml -lunix 
> -lm -lasmrun -ldl
> 
> works, but 
> ocamlopt -o libmytest.so -output-obj  interface.c m1.ml
> gcc -Wall main.c  -lmytest -o test
> does not! Is it clear why it doesn't work?

See my comments on PR#5707.  In the latter case, the dynamic loader is
invoked and trashes registers r10 and r11, which ocamlopt uses to pass
arguments to your "foo" function.  We'll have to come up with a better
choice of parameter registers.

> So I get away with static linking for now.

Please do if at all possible.  ocamlopt was designed for static
linking, and the relatively recent addition of dynamic linking support
isn't completely mature yet.

- Xavier Leroy

  reply	other threads:[~2012-07-31 14:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31 12:17 Georg Martius
2012-07-31 12:59 ` Gerd Stolpmann
2012-07-31 14:03   ` Georg Martius
2012-07-31 14:29     ` Xavier Leroy [this message]
2012-07-31 13:11 ` Anil Madhavapeddy

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=5017EBD4.9080904@inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).