[opam-devel] ocamlc.opt and pthreads

Anil Madhavapeddy anil at recoil.org
Fri Jun 13 10:55:23 BST 2014


Without looking closely at the specifics, this does seem like a configure script
issue.  I suspect it would be better reported on Mantis with the configure outputs
pasted into the report, as that should take care of linking pthread or not depending
on the OS it's running on.

-anil

On 13 Jun 2014, at 02:43, Mika Illouz <mika at illouz.net> wrote:

> Dear OPAM-ers,
> 
> I have two systems on which opam is installed.  System A runs Ubuntu
> 11.10 (ancient, I know) and opam 1.0.0, with the 4.00.1 ocaml compiler.
> 
> A $ lsb_release -i -c
> Distributor ID: Ubuntu
> Codename:       natty
> A $ opam --version
> 1.0.0
> 
> I have a second system, system B, running Ubuntu 13.10 (less ancient)
> and opam 1.1.1, with the 3.12.1 and 4.01.0 compilers
> 
> B $ lsb_release -i -c
> Distributor ID: Ubuntu
> Codename:       saucy
> B $ opam --version
> 1.1.1
> 
> I will try to compile a simple ocaml program into bytecode, on both
> systems, and for the heck of it, link against system threads library:
> A $ echo "let _ = print_endline \"hi\"" > /tmp/x.ml
> A $ /home/mika/.opam/4.00.1/bin/ocamlc -thread /home/mika/.opam/4.00.1/lib/ocaml/threads/threads.cma /tmp/x.ml -o /tmp/x
> A $ /home/mika/.opam/4.00.1/bin/ocamlc.opt -thread /home/mika/.opam/4.00.1/lib/ocaml/threads/threads.cma /tmp/x.ml -o /tmp/x
> 
> No problem so far.
> 
> Now on system B:
> B $ echo "let _ = print_endline \"hi\"" > /tmp/x.ml
> B $ /home/mika/.opam/3.12.1/bin/ocamlc -thread /home/mika/.opam/3.12.1/lib/ocaml/threads/threads.cma /tmp/x.ml -o /tmp/x
> B $ /home/mika/.opam/3.12.1/bin/ocamlc.opt -thread /home/mika/.opam/3.12.1/lib/ocaml/threads/threads.cma /tmp/x.ml -o /tmp/x
> File "/tmp/x.ml", line 1, characters 0-1:
> Error: Error on dynamically loaded library: /home/mika/.opam/3.12.1/lib/ocaml/stublibs/dllthreads.so: /home/mika/.opam/3.12.1/lib/ocaml/stublibs/dllthreads.so: undefined symbol: pthread_sigmask
> 
> On system B, ocamlc.opt seems to have trouble, whereas ocamlc does
> not.  (4.01.0 also has the identical issue).  Trying to figure out
> why, I looked at the DLL dependencies of the ocamlc.opt's :
> 
> A $ ldd /home/mika/.opam/4.00.1/bin/ocamlc.opt
>         linux-vdso.so.1 =>  (0x00007fffa29ff000)
>         libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fad8291b000)
>         libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fad82717000)
>         libncurses.so.5 => /lib/libncurses.so.5 (0x00007fad824d2000)
>         libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fad822b4000)
>         libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fad81f1c000)
>         /lib64/ld-linux-x86-64.so.2 (0x00007fad82bc7000)
> 
> B $ ldd /home/mika/.opam/3.12.1/bin/ocamlc.opt
>         linux-vdso.so.1 =>  (0x00007fff8affe000)
>         libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f128410c000)
>         libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1283f08000)
>         libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1283b3f000)
>         /lib64/ld-linux-x86-64.so.2 (0x00007f128441c000)
> 
> The critical difference seems to be that system A's ocamlc.opt is linked
> against libpthread.so (and libncurses.so, for whatever reason), and
> system B's does not.  In fact, compilation succeeds on system B if I
> use LD_PRELOAD:
> 
> B $ LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0  /home/mika/.opam/3.12.1/bin/ocamlc -thread /home/mika/.opam/3.12.1/lib/ocaml/threads/threads.cma /tmp/x.ml -o /tmp/x
> 
> Incidentally, if I compile ocaml from Inria's tarball, compilation
> using ocamlc.opt also fails on system B, unless I configure the the
> compilation of the compiler with "./configure -libs -lpthread" .
> 
> The ocaml installed through opam on system A seems to do the right
> thing.  Does anyone have any idea how I can make system B's compiler
> behave similarly?
> 
> thanks
> mika
> _______________________________________________
> opam-devel mailing list
> opam-devel at lists.ocaml.org
> http://lists.ocaml.org/listinfo/opam-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/opam-devel/attachments/20140613/d252ff87/attachment.html>


More information about the opam-devel mailing list