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