caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jeremy Yallop <yallop@gmail.com>
To: Mike McClurg <mike.mcclurg@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] ctypes with -thread: inconsistent assumptions over implementation Foreign
Date: Wed, 20 Nov 2013 08:23:52 +0000	[thread overview]
Message-ID: <CAAxsn=G_VrseqXT0rw6w1Ex3byiTqg+Fy2uB6_z30Xcpw5NYhw@mail.gmail.com> (raw)
In-Reply-To: <CALru5wXhvwb7q58WOO6ydSs--t=QiCd5VyKNdV3Lm_8ui9nxtQ@mail.gmail.com>

On 19 November 2013 22:57, Mike McClurg <mike.mcclurg@gmail.com> wrote:
> $ ocamlfind ocamlopt -verbose -package ctypes,ctypes.foreign -linkpkg
> -thread -o test test.ml
[...]
> File "test.ml", line 1:
> Error: Files test.cmx
>        and /Users/mike/.opam/system/lib/ctypes/ctypes-foreign-threaded.cmxa
>        make inconsistent assumptions over implementation Foreign
[...]
> Am I doing something wrong here? Or is something wrong with the way ctypes
> is built and packaged?

It's a packaging problem.  Ctypes uses a findlib feature[1] that
selects the library to link according to whether threads are enabled,
as you can see in the META file:

    archive(native, mt) = "ctypes-foreign-threaded.cmxa"
    [...]
    archive(native) = "ctypes-foreign-unthreaded.cmxa"
    (from [2])

This shows up in your command-line as expected: when you don't pass
-thread to ocamlfind it picks the -unthreaded version of the
ctypes-foreign library

   + ocamlopt.opt [...]
/Users/mike/.opam/system/lib/ctypes/ctypes-foreign-unthreaded.cmxa
test.ml

and when you pass -thread you get the -threaded version

   + ocamlopt.opt [...]
/Users/mike/.opam/system/lib/ctypes/ctypes-foreign-threaded.cmxa
test.ml

So far, so good.  However, although there are two cmxa implementations
installed for ctypes-foreign there's only one set of cmx files, which
happen to match the -unthreaded version of the library.  Compiling
with the -thread option picks the -threaded library but the
-unthreaded cmx, leading to the mismatch that you're seeing.  If you
simply delete the offending cmx file (as a diagnostic step, not a
long-term solution!) you should see the problem disappear:

   rm /Users/mike/.opam/system/lib/ctypes/foreign.cmx

[1] http://projects.camlcity.org/projects/dl/findlib-1.4/doc/guide-html/x261.html
[2] https://github.com/ocamllabs/ocaml-ctypes/blob/ocaml-ctypes-0.2.1/META#L39-L43

  reply	other threads:[~2013-11-20  8:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19 22:57 Mike McClurg
2013-11-20  8:23 ` Jeremy Yallop [this message]
2013-11-20 15:28   ` Jeremy Yallop
2013-11-20 15:55     ` Mike McClurg

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='CAAxsn=G_VrseqXT0rw6w1Ex3byiTqg+Fy2uB6_z30Xcpw5NYhw@mail.gmail.com' \
    --to=yallop@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=mike.mcclurg@gmail.com \
    /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).