caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mike McClurg <mike.mcclurg@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] ctypes with -thread: inconsistent assumptions over implementation Foreign
Date: Tue, 19 Nov 2013 15:57:15 -0700	[thread overview]
Message-ID: <CALru5wXhvwb7q58WOO6ydSs--t=QiCd5VyKNdV3Lm_8ui9nxtQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3212 bytes --]

Hi list,

I'm running into a strange issue when compiling a ctypes (0.2.1) library
with the -thread option. Here is my test program:

    open Ctypes
    open PosixTypes
    open Foreign

    let time = foreign "time" (ptr time_t @-> returning time_t)

    let _ = ignore (time (from_voidp time_t null))

This is the simplest example I could find from the ctypes tutorial. When I
compile it without -threaded, it works:

$ ocamlfind ocamlopt -verbose -package ctypes,ctypes.foreign -linkpkg -o
test test.ml
Effective set of compiler predicates:
pkg_unix,pkg_bigarray,pkg_ctypes,pkg_ctypes.foreign-base,pkg_ctypes.foreign,autolink,native
+ ocamlopt.opt -verbose -o test -I /Users/mike/.opam/system/lib/ctypes
/usr/local/lib/ocaml/unix.cmxa /usr/local/lib/ocaml/bigarray.cmxa
/Users/mike/.opam/system/lib/ctypes/ctypes.cmxa
/Users/mike/.opam/system/lib/ctypes/ctypes-foreign-base.cmxa
/Users/mike/.opam/system/lib/ctypes/ctypes-foreign-unthreaded.cmxa test.ml
+ clang -arch x86_64 -c -o 'test.o'
'/var/folders/56/7m5w0d2s31l99sh6jw_53_900000gn/T/camlasmeaa663.s'
+ clang -arch x86_64 -c -o
'/var/folders/56/7m5w0d2s31l99sh6jw_53_900000gn/T/camlstartup56e173.o'
'/var/folders/56/7m5w0d2s31l99sh6jw_53_900000gn/T/camlstartup78207e.s'
+ cc -Wl,-no_compact_unwind -o 'test'
'-L/Users/mike/.opam/system/lib/ctypes' '-L/usr/local/lib/ocaml'
'/var/folders/56/7m5w0d2s31l99sh6jw_53_900000gn/T/camlstartup56e173.o'
'/usr/local/lib/ocaml/std_exit.o' 'test.o'
'/Users/mike/.opam/system/lib/ctypes/ctypes-foreign-unthreaded.a'
'/Users/mike/.opam/system/lib/ctypes/ctypes-foreign-base.a'
'/Users/mike/.opam/system/lib/ctypes/ctypes.a'
'/usr/local/lib/ocaml/bigarray.a' '/usr/local/lib/ocaml/unix.a'
'/usr/local/lib/ocaml/stdlib.a' '-L/usr/local/Cellar/libffi/3.0.13/lib'
'-lffi' '-lctypes-foreign-base_stubs'
'-L/usr/local/Cellar/libffi/3.0.13/lib' '-lffi' '-lctypes_stubs'
'-lbigarray' '-lunix' '/usr/local/lib/ocaml/libasmrun.a'

But when I use the -thread option:

$ ocamlfind ocamlopt -verbose -package ctypes,ctypes.foreign -linkpkg
-thread -o test test.ml
Effective set of compiler predicates:
pkg_unix,pkg_threads.posix,pkg_threads,pkg_bigarray,pkg_ctypes,pkg_ctypes.foreign-base,pkg_ctypes.foreign,autolink,mt,mt_posix,native
+ ocamlopt.opt -verbose -o test -thread -I
/Users/mike/.opam/system/lib/ctypes /usr/local/lib/ocaml/unix.cmxa
/usr/local/lib/ocaml/threads/threads.cmxa
/usr/local/lib/ocaml/bigarray.cmxa
/Users/mike/.opam/system/lib/ctypes/ctypes.cmxa
/Users/mike/.opam/system/lib/ctypes/ctypes-foreign-base.cmxa
/Users/mike/.opam/system/lib/ctypes/ctypes-foreign-threaded.cmxa test.ml
+ clang -arch x86_64 -c -o 'test.o'
'/var/folders/56/7m5w0d2s31l99sh6jw_53_900000gn/T/camlasmd75109.s'
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

I've deleted all the cmx/cmi/o files and rerun the above command, but I
still get this error. Here I'm using ctypes 0.2.1 from opam on OSX, but
this also fails for me with a ctypes 0.2.1 rpm I built in a CentOS 6.4
environment.

Am I doing something wrong here? Or is something wrong with the way ctypes
is built and packaged?

Mike

[-- Attachment #2: Type: text/html, Size: 3853 bytes --]

             reply	other threads:[~2013-11-19 22:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19 22:57 Mike McClurg [this message]
2013-11-20  8:23 ` Jeremy Yallop
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='CALru5wXhvwb7q58WOO6ydSs--t=QiCd5VyKNdV3Lm_8ui9nxtQ@mail.gmail.com' \
    --to=mike.mcclurg@gmail.com \
    --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).