From: Joel Stanley <jstanley@galois.com>
To: Alain Frisch <alain@frisch.fr>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Dynamic libs w/ Ocaml + C code under Mac OS X
Date: Tue, 5 Feb 2008 13:19:32 -0800 [thread overview]
Message-ID: <2E251B0B-EE9B-4F03-AA31-8924D554AB57@galois.com> (raw)
In-Reply-To: <47A8CE53.40500@frisch.fr>
On Feb 5, 2008, at 1:00 PM, Alain Frisch wrote:
> Joel Stanley wrote:
>> Actually, I do want a stand-alone shared library that includes the
>> OCaml runtime, but I don't think that changes the parameters of the
>> problem much. Basically, I have an OCaml application that I'd like
>> to wrap up (together with some C glue code) into a shared library
>> for use by other applications.
>
> Then, you should rather try something like:
>
> ocamlopt -output-obj -o foo.so simple.ml wrapper.c
>
> In the CVS version, -output-obj has been extended to allow producing
> directly "standalone" .so/.dll libraries that can be loaded from C
> (or anything else).
Well, to try this out I have to get around the -I problem we talked
about before, but after doing so (and manually assembling the startup
code), I get the same error.
$ ocamlopt -dstartup -verbose -output-obj -o foo.so simple.ml wrapper.c
$ as -o foo.so.startup.o foo.so.startup.s
ld -bundle -flat_namespace -undefined suppress -read_only_relocs
suppress -o 'foo.so' '-L/Users/jstanley/hbin/lib/ocaml'
'foo.so.startup.o' 'simple.o' '/Users/jstanley/hbin/lib/ocaml/
stdlib.a' 'wrapper.o' '/Users/jstanley/hbin/lib/ocaml/libasmrun.a'
> ld: absolute addressing (perhaps -mdynamic-no-pic) used in
_caml_startup__code_begin from foo.so.startup.o not allowed in
slidable image for inferred architecture i386
>
>> The only real problem with the linker invocation above was the -I
>> switch, as the linker doesn't support it.
>
> If we simply remove the -I switch, then everything is ok?
Sorry, I meant to say that the -I just makes the linker invocation ill-
formed; it doesn't work better with a correctly-formed invocation.
That is, I am still getting the same error about absolute addresses in
the generated code. Here's a pared down version of what I'm witnessing:
ocamlopt -dlcode -output-obj -c simple.ml
gcc -c wrapper.c -I ...
gcc -bundle -flat_namespace -undefined suppress -o blah wrapper.o
simple.o
ld: absolute addressing (perhaps -mdynamic-no-pic) used in
_caml_startup__code_begin from simple.o not allowed in slidable image
Where the _caml_startup__code_begin comes from the assembled
camlstartup file generated by ocamlopt.
>> Hmm, -read_only_relocs still looks supported in the man page for ld
>> under 10.5.
>
> But does the linker really accept "-read_only_relocs suppress"?
>
> http://developer.apple.com/releasenotes/DeveloperTools/RN-Id/
> index.html
> seems to indicate the opposite.
You're right. I dug into this a bit more and asked some more
knowledgeable Mac OS X developers; this wasn't even officially
supported under 10.4, but it happened to work (albeit likely with
undefined behavior); now it is defunct, as per the page you referenced.
>> Anyone have any ideas as to how I could remedy the situation? At
>> this point it looks like I might have to switch the platform the
>> application I'm working on is used with, due to this linking
>> problem alone. There shouldn't be a need for the code generators
>> to produce PIC as long as the linker does the right thing, correct?
>
> Yes, correct.
From the experiments that I've been doing, it really looks like PIC
needs to be generated for the OS X linker to be happy. Do you have
any assessment as to how much work this is? Keep in mind that I don't
consider myself an x86 assembly hacker by any stretch of the
imagination ;) I'd really like to just run this natively on my main
platform, but if I can't, I can't.
Thanks,
Joel
--
Joel Stanley
jstanley@galois.com
next prev parent reply other threads:[~2008-02-05 21:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-04 22:39 Joel Stanley
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 [this message]
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=2E251B0B-EE9B-4F03-AA31-8924D554AB57@galois.com \
--to=jstanley@galois.com \
--cc=alain@frisch.fr \
--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