caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joel Stanley <jstanley@galois.com>
To: caml-list@yquem.inria.fr
Subject: Dynamic libs w/ Ocaml + C code under Mac OS X
Date: Mon, 4 Feb 2008 14:39:21 -0800	[thread overview]
Message-ID: <11970BA6-EC2F-47FD-A194-BFD204057F06@galois.com> (raw)

Hi folks,

mfp from #ocaml suggested I send this off to the mailing list to see  
if anyone knows the answer.

The short question is: can I currently generate a shared library  
containing natively-compiled ocaml code together with arbitrary C code  
under Mac OS X?  Alain Frisch's natdynlink info page at http://alain.frisch.fr/natdynlink.html 
  seems to indicate that I can, but I'm not currently having much luck.

To wit, should I be doing something other than:

$ gcc -c wrapper.c
$ ocamlopt -dlcode -c simple.ml
...
$ ocamlopt -shared -o test simple.cmx wrapper.o

or perhaps just ocamlopt -shared -o test simple.ml wrapper.c?

The immediate problem is that this seems to be passing the wrong  
arguments to ld:

+ ld -bundle -flat_namespace -undefined suppress -read_only_relocs  
suppress -o 'test'  -I'/Users/jstanley/hbin/lib/ocaml' '-L/Users/ 
jstanley/hbin/lib/ocaml' 'test.startup.o' 'simple.o' 'wrapper.o'

(I'd expect to see gcc -dynamiclib (instead of bundle) here if Mac OS  
X is supported, and without the -I switch).

However, even attempting to use what I'd consider to be the "correct"  
linker invocation, I'm getting errors of the form:

ld: atom sorting error for _caml_shared_startup__code_begin and  
_caml_shared_startup__code_end in test.startup.o
ld: atom sorting error for _caml_shared_startup__code_begin and  
_caml_shared_startup__code_end in test.startup.o
ld: atom sorting error for _caml_shared_startup__code_begin and  
_caml_shared_startup__code_end in test.startup.o
ld: atom sorting error for _caml_shared_startup__code_begin and  
_caml_shared_startup__code_end in test.startup.o
ld: warning codegen in _camlSimple__f_58 (offset 0x00000008) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x00000004) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x00000009) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x0000000F) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x00000014) prevents  
image from loading in dyld shared cache
ld: warning codegen in _camlSimple__entry (offset 0x0000001E) prevents  
image from loading in dyld shared cache
ld: absolute addressing (perhaps -mdynamic-no-pic) used in  
_camlSimple__f_58 from simple.o not allowed in slidable image
collect2: ld returned 1 exit status

which lead me to believe that simple.o is not correctly being  
generated with position independence.

Thanks for any help you may be able to provide.

--
Joel Stanley






             reply	other threads:[~2008-02-04 22:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04 22:39 Joel Stanley [this message]
2008-02-05  4:52 ` [Caml-list] " Alain Frisch
2008-02-05 16:39   ` Joel Stanley
2008-02-05 21:00     ` Alain Frisch
2008-02-05 21:19       ` Joel Stanley
2008-02-05 21:49         ` Alain Frisch
2008-02-06  0:02           ` Joel Stanley

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=11970BA6-EC2F-47FD-A194-BFD204057F06@galois.com \
    --to=jstanley@galois.com \
    --cc=caml-list@yquem.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).