* [Caml-list] state of native dynlink on os x @ 2012-02-15 11:17 Alan Schmitt 2012-02-15 12:34 ` Daniel Bünzli 2012-02-17 6:47 ` Alan Schmitt 0 siblings, 2 replies; 21+ messages in thread From: Alan Schmitt @ 2012-02-15 11:17 UTC (permalink / raw) To: caml-list Hello, As I'm using more and more programs that use native dynlink, I'm trying to understand what is the state of things on os x. According to this message http://alan.petitepomme.net/cwn/2008.10.21.html natdynlink does not work on 10.5 and above. However, if I read correctly this patch http://caml.inria.fr/mantis/view.php?id=4863 it is enabled for 64 bits architectures. As the patch is in godi, I built a version of ocaml with it, and I'm having mixed results. For some very simple files, things seem to work fine. But if I compile why3 with it (current git version), I get some errors when running why3config: == Found /usr/local/lib/why3/plugins/genequlin.cmxs == The plugin /usr/local/lib/why3/plugins/genequlin.cmxs dynlink failed : Dynlink error : error loading shared library: dlopen(/usr/local/lib/why3/plugins/genequlin.cmxs, 134): Symbol not found: _camlRandom Referenced from: /usr/local/lib/why3/plugins/genequlin.cmxs Expected in: flat namespace in /usr/local/lib/why3/plugins/genequlin.cmxs == Found /usr/local/lib/why3/plugins/tptp.cmxs == The plugin /usr/local/lib/why3/plugins/tptp.cmxs dynlink failed : Dynlink error : error loading shared library: dlopen(/usr/local/lib/why3/plugins/tptp.cmxs, 134): Symbol not found: _camlParsing Referenced from: /usr/local/lib/why3/plugins/tptp.cmxs Expected in: flat namespace in /usr/local/lib/why3/plugins/tptp.cmxs == Found /usr/local/lib/why3/plugins/tptpfof.cmxs == The plugin /usr/local/lib/why3/plugins/tptpfof.cmxs dynlink failed : Dynlink error : error loading shared library: dlopen(/usr/local/lib/why3/plugins/tptpfof.cmxs, 134): Symbol not found: _camlString Referenced from: /usr/local/lib/why3/plugins/tptpfof.cmxs Expected in: flat namespace in /usr/local/lib/why3/plugins/tptpfof.cmxs Note that there was a warning when compiling why3: ld: warning: -read_only_relocs cannot be used with x86_64 So I'm a bit confused as to the current state of things. My questions are: - is native dynlink on os x 64 bits architecture supported in ocaml 3.13dev? - if so, why do I get the ld warning and why does linking fails sometimes? - if not, is there hope it will be supported in the future? Thanks a lot, Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-15 11:17 [Caml-list] state of native dynlink on os x Alan Schmitt @ 2012-02-15 12:34 ` Daniel Bünzli 2012-02-15 14:16 ` Alan Schmitt 2012-02-17 6:47 ` Alan Schmitt 1 sibling, 1 reply; 21+ messages in thread From: Daniel Bünzli @ 2012-02-15 12:34 UTC (permalink / raw) To: Alan Schmitt; +Cc: caml-list Can't precisely answer your questions but : > to understand what is the state of things on os x. According to this > message http://alan.petitepomme.net/cwn/2008.10.21.html natdynlink does > not work on 10.5 and above. > At least here it does work without problems on 10.6.8. with this [1] config. Best, Daniel [1] > ocamlc -config version: 3.12.0 standard_library_default: /usr/local/lib/ocaml standard_library: /usr/local/lib/ocaml standard_runtime: /usr/local/bin/ocamlrun ccomp_type: cc bytecomp_c_compiler: gcc -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT bytecomp_c_libraries: -lcurses -lpthread native_c_compiler: gcc -D_FILE_OFFSET_BITS=64 -D_REENTRANT native_c_libraries: native_pack_linker: ld -r -arch x86_64 -o ranlib: ranlib cc_profile: -pg architecture: amd64 model: default system: macosx asm: as -arch x86_64 ext_obj: .o ext_asm: .s ext_lib: .a ext_dll: .so os_type: Unix default_executable_name: a.out systhread_supported: true ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-15 12:34 ` Daniel Bünzli @ 2012-02-15 14:16 ` Alan Schmitt 0 siblings, 0 replies; 21+ messages in thread From: Alan Schmitt @ 2012-02-15 14:16 UTC (permalink / raw) To: Daniel Bünzli; +Cc: caml-list On 15 Feb 2012, at 13:34, Daniel Bünzli wrote: > Can't precisely answer your questions but : >> to understand what is the state of things on os x. According to this >> message http://alan.petitepomme.net/cwn/2008.10.21.html natdynlink >> does >> not work on 10.5 and above. >> > > At least here it does work without problems on 10.6.8. with this [1] > config. OK, so I guess this is a bug with why3. I'll report it there. Thanks, Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-15 11:17 [Caml-list] state of native dynlink on os x Alan Schmitt 2012-02-15 12:34 ` Daniel Bünzli @ 2012-02-17 6:47 ` Alan Schmitt 2012-02-27 15:43 ` Damien Doligez 1 sibling, 1 reply; 21+ messages in thread From: Alan Schmitt @ 2012-02-17 6:47 UTC (permalink / raw) To: caml-list Hello, Following a suggestion by Daniel Bünzli, I used the minimum example from http://caml.inria.fr/mantis/view.php?id=5093 then I can see that native dynlink does work. However two questions remain. I get `ld: warning: -read_only_relocs cannot be used with x86_64` each time I link natively. Does this mean I should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch there is applied to my version of caml)? Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined? Thanks, Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-17 6:47 ` Alan Schmitt @ 2012-02-27 15:43 ` Damien Doligez 2012-02-27 17:49 ` Pierre-Alexandre Voye ` (2 more replies) 0 siblings, 3 replies; 21+ messages in thread From: Damien Doligez @ 2012-02-27 15:43 UTC (permalink / raw) To: caml-list Hi Alan, > Following a suggestion by Daniel Bünzli, I used the minimum example from http://caml.inria.fr/mantis/view.php?id=5093 then I can see that native dynlink does work. > > However two questions remain. I get `ld: warning: -read_only_relocs cannot be used with x86_64` each time I link natively. Does this mean I should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch there is applied to my version of caml)? Which version of Mac OS X, which version of OCaml, and what is the output of configure? > Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined? Looks like modules of the standard library, right ? ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-27 15:43 ` Damien Doligez @ 2012-02-27 17:49 ` Pierre-Alexandre Voye 2012-02-28 10:15 ` David MENTRE 2012-02-28 15:34 ` Alan Schmitt 2012-03-08 11:13 ` Alan Schmitt 2 siblings, 1 reply; 21+ messages in thread From: Pierre-Alexandre Voye @ 2012-02-27 17:49 UTC (permalink / raw) To: Damien Doligez; +Cc: caml-list [-- Attachment #1: Type: text/plain, Size: 4336 bytes --] 2012/2/27 Damien Doligez <damien.doligez@inria.fr> > Hi Alan, > > Following a suggestion by Daniel Bünzli, I used the minimum example from > http://caml.inria.fr/mantis/view.php?id=5093 then I can see that native > dynlink does work. > > > > However two questions remain. I get `ld: warning: -read_only_relocs > cannot be used with x86_64` each time I link natively. Does this mean I > should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch > there is applied to my version of caml)? > > Which version of Mac OS X, which version of OCaml, and what is the output > of configure? > I had it in Mac Lion ( 10.7.3 - 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64 ) Example, compiling Ocsigen : (end of make...) ocamlfind ocamlc -thread -o ocsigenserver -linkpkg -linkall -thread -I ../baselib -I ../http -package lwt.ssl -package lwt.extra -package netstring -package findlib -package cryptokit -package tyxml -package tyxml.parser -package dynlink -package tyxml.syntax -I . ../baselib/parsecommandline.cma ../baselib/baselib.cma ../baselib/polytables.cma ../http/http.cma ocsigenserver.cma server_main.cmo File "_none_", line 1, characters 0-1: Error: Error while linking /opt/local/lib/ocaml/camlp4/camlp4lib.cma(Camlp4): Reference to undefined global `Dynlink' make[4]: *** [ocsigenserver] Error 2 make[3]: *** [all] Error 2 make[2]: *** [all] Error 2 make[1]: *** [do-ocsigenserver-build] Error 2 make: *** [.ocsigenserver-build] Error 2 > > Also, when running why3, I get some undefined symbols (_camlRandom, > _camlParsing, _camlString). Where are these symbols defined? > > Looks like modules of the standard library, right ? > > > Here, i have : File "_none_", line 1, characters 0-1: Error: Cannot find file dynlink.cmxa make: *** [bin/why3config.opt] Error 2 make: *** Waiting for unfinished jobs.... configure of why3 : $ ./configure --enable-menhirlib --enable-doc checking executable suffix... <none> checking for ocamlc... ocamlc ocaml version is 3.12.1 ocaml library path is /opt/local/lib/ocaml checking for ocamlopt... ocamlopt checking ocamlopt version... ok checking for ocamlc.opt... ocamlc.opt checking ocamlc.opt version... ok checking for ocamlopt.opt... ocamlopt.opt checking ocamlc.opt version... ok checking for ocamldep... ocamldep checking for ocamldep.opt... ocamldep.opt checking for ocamllex... ocamllex checking for ocamllex.opt... ocamllex.opt checking for ocamlyacc... ocamlyacc checking for ocamldoc... ocamldoc checking for ocamldoc.opt... ocamldoc.opt checking for camlp5o... camlp5o checking for ocamlfind... yes checking for menhir... menhir ocamlfind found menhir library in /opt/local/lib/ocaml/site-lib/menhirLib checking for rubber... no configure: WARNING: cannot find rubber ocamlfind found lablgtk2 in /opt/local/lib/ocaml/lablgtk2 ocamlfind found sqlite3 in /opt/local/lib/ocaml/site-lib/sqlite3 checking for coqc... coqc checking Coq version... 8.3pl2 checking for /usr/local/lib/coq/kernel/term.cmi... yes ocamlfind found ocamlgraph in /opt/local/lib/ocaml/site-lib/ocamlgraph configure: creating ./config.status config.status: creating Makefile config.status: creating src/config.sh config.status: creating doc/version.tex config.status: creating share/provers-detection-data.conf config.status: creating META config.status: executing chmod commands Summary ----------------------------------------- OCaml version : 3.12.1 OCaml library path : /opt/local/lib/ocaml Verbose make : no Why IDE : yes Why bench tool : yes Why documentation : no Why plugins : yes Coq plugin support : no (not yet implemented) TPTP parser : yes Menhir library : yes hypothesis selection : yes profiling : no localdir : no > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > -- --------------------- https://twitter.com/#!/ontologiae/ http://linuxfr.org/users/montaigne [-- Attachment #2: Type: text/html, Size: 6065 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-27 17:49 ` Pierre-Alexandre Voye @ 2012-02-28 10:15 ` David MENTRE 2012-02-28 10:32 ` Pierre-Alexandre Voye 0 siblings, 1 reply; 21+ messages in thread From: David MENTRE @ 2012-02-28 10:15 UTC (permalink / raw) To: Pierre-Alexandre Voye; +Cc: Damien Doligez, caml-list Hello, 2012/2/27 Pierre-Alexandre Voye <ontologiae@gmail.com>: > make: *** Waiting for unfinished jobs.... Are you using parallel compilation of Why3 (make -j /n/?). I had compilation issue with parallel compilation of Why3. However it might not be related to your issue or it might have been fixed in the meantime. Best regards, david ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-28 10:15 ` David MENTRE @ 2012-02-28 10:32 ` Pierre-Alexandre Voye 0 siblings, 0 replies; 21+ messages in thread From: Pierre-Alexandre Voye @ 2012-02-28 10:32 UTC (permalink / raw) To: David MENTRE; +Cc: Damien Doligez, caml-list [-- Attachment #1: Type: text/plain, Size: 878 bytes --] It doesn't change anything : make clean ./configure --enable-menhirlib --enable-doc make ... ocamlopt.opt -a -w Aer-29 -dtypes -I src -I /opt/local/lib/ocaml/site-lib/ocamlgraph -o src/why3.cmxa src/why3.cmx Ocamlopt src/main.ml Linking bin/why3.opt File "_none_", line 1, characters 0-1: Error: Cannot find file dynlink.cmxa make: *** [bin/why3.opt] Error 2 2012/2/28 David MENTRE <dmentre@linux-france.org> > Hello, > > 2012/2/27 Pierre-Alexandre Voye <ontologiae@gmail.com>: > > make: *** Waiting for unfinished jobs.... > > Are you using parallel compilation of Why3 (make -j /n/?). I had > compilation issue with parallel compilation of Why3. However it might > not be related to your issue or it might have been fixed in the > meantime. > > Best regards, > david > -- --------------------- https://twitter.com/#!/ontologiae/ http://linuxfr.org/users/montaigne [-- Attachment #2: Type: text/html, Size: 1485 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-27 15:43 ` Damien Doligez 2012-02-27 17:49 ` Pierre-Alexandre Voye @ 2012-02-28 15:34 ` Alan Schmitt 2012-02-29 8:33 ` Alan Schmitt 2012-03-07 10:55 ` Damien Doligez 2012-03-08 11:13 ` Alan Schmitt 2 siblings, 2 replies; 21+ messages in thread From: Alan Schmitt @ 2012-02-28 15:34 UTC (permalink / raw) To: Damien Doligez; +Cc: caml-list On 27 févr. 2012, at 16:43, Damien Doligez wrote: > Hi Alan, >> Following a suggestion by Daniel Bünzli, I used the minimum example from http://caml.inria.fr/mantis/view.php?id=5093 then I can see that native dynlink does work. >> >> However two questions remain. I get `ld: warning: -read_only_relocs cannot be used with x86_64` each time I link natively. Does this mean I should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch there is applied to my version of caml)? > > Which version of Mac OS X, which version of OCaml, and what is the output of configure? OS X 10.7.3, ocaml 3.12.1-godi2. About the output of configure, I'm trying to see how to get it from godi, in the meantime here is my ocamlc -config: version: 3.12.1 standard_library_default: /Users/schmitta/godi/lib/ocaml/std-lib standard_library: /Users/schmitta/godi/lib/ocaml/std-lib standard_runtime: /Users/schmitta/godi/bin/ocamlrun ccomp_type: cc bytecomp_c_compiler: gcc -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT bytecomp_c_libraries: -lcurses -lpthread native_c_compiler: gcc -D_FILE_OFFSET_BITS=64 -D_REENTRANT native_c_libraries: native_pack_linker: ld -r -arch x86_64 -o ranlib: ranlib cc_profile: -pg architecture: amd64 model: default system: macosx asm: as -arch x86_64 ext_obj: .o ext_asm: .s ext_lib: .a ext_dll: .so os_type: Unix default_executable_name: a.out systhread_supported: true >> Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined? > > Looks like modules of the standard library, right ? Do they need to be loaded manually, or should they be loaded automatically by the native linker? Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-28 15:34 ` Alan Schmitt @ 2012-02-29 8:33 ` Alan Schmitt 2012-03-07 10:55 ` Damien Doligez 1 sibling, 0 replies; 21+ messages in thread From: Alan Schmitt @ 2012-02-29 8:33 UTC (permalink / raw) To: Damien Doligez; +Cc: caml-list On 27 févr. 2012, at 16:43, Damien Doligez wrote: > Hi Alan, >> Following a suggestion by Daniel Bünzli, I used the minimum example from http://caml.inria.fr/mantis/view.php?id=5093 then I can see that native dynlink does work. >> >> However two questions remain. I get `ld: warning: -read_only_relocs cannot be used with x86_64` each time I link natively. Does this mean I should reopen http://caml.inria.fr/mantis/view.php?id=4863 (the patch there is applied to my version of caml)? > > Which version of Mac OS X, which version of OCaml, and what is the output of configure? Here is the output of configure: Configuring for a i686-apple-darwin11.3.0 ... The C compiler is ANSI-compliant. Checking the sizes of integers and pointers... Wow! A 64 bit architecture! This is a little-endian architecture. Doubles can be word-aligned. 64-bit integers can be word-aligned. Native division and modulus have round-towards-zero semantics, will use them. ranlib found #! appears to work in shell scripts POSIX signal handling found. expm1() and log1p() found. getrusage() found. times() found. termcap functions found (with libraries '-lcurses') You have BSD sockets. socklen_t is defined in <sys/socket.h> inet_aton() found. IPv6 is supported. unistd.h found. off_t is defined in <sys/types.h> dirent.h found. rewinddir() found. lockf() found. mkfifo() found. getcwd() found. getwd() found. getpriority() found. utime() found. utimes() found. dup2() found. fchmod() found. truncate() found. sys/select.h found. select() found. symlink() found. waitpid() found. wait4() found. getgroups() found. setgroups() found. initgroups() found. POSIX termios found. Asynchronous I/O are supported. setitimer() found. gethostname() found. uname() found. gettimeofday() found. mktime() found. setsid() found. putenv() found. setlocale() and <locale.h> found. dlopen() found. Dynamic loading of shared libraries is supported. mmap() found. Replay debugger supported. System stack overflow can be detected. POSIX threads library supported. Options for linking with POSIX threads: -lpthread sigwait() found Bytecode threads library supported. Location of X11 include files: /usr/X11R6/include/X11 Options for linking with X11: -L/usr/X11R6/lib -lX11 NDBM found (in /usr/include) Configuring LablTk... tcl.h and tk.h version 8.5 found with "". Tcl/Tk libraries found. BFD library not found, 'objinfo' will be unable to display info on .cmxs files ** Configuration summary ** Directories where Objective Caml will be installed: binaries.................. /Users/schmitta/godi/bin standard library.......... /Users/schmitta/godi/lib/ocaml/std-lib manual pages.............. /Users/schmitta/godi/man (with extension .1) Configuration for the bytecode compiler: C compiler used........... gcc options for compiling..... -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT options for linking....... -lcurses -lpthread shared libraries are supported options for compiling..... -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT command for building...... gcc -bundle -flat_namespace -undefined suppress -read_only_relocs suppress -o lib.so /a/path objs Configuration for the native-code compiler: hardware architecture..... amd64 OS variant................ macosx C compiler used........... gcc options for compiling..... -D_FILE_OFFSET_BITS=64 -D_REENTRANT options for linking....... assembler ................ as -arch x86_64 preprocessed assembler ... gcc -arch x86_64 -c native dynlink ........... true profiling with gprof ..... supported Source-level replay debugger: supported Additional libraries supported: unix str num dynlink bigarray systhreads threads graph dbm labltk Configuration for the "num" library: target architecture ...... amd64 (asm level 1) Configuration for the "graph" library: options for compiling .... -I/usr/X11R6/include options for linking ...... -L/usr/X11R6/lib -lX11 Configuration for the "labltk" library: use tcl/tk version ....... 8.5 options for compiling .... options for linking ...... -ltk8.5 -ltcl8.5 Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-28 15:34 ` Alan Schmitt 2012-02-29 8:33 ` Alan Schmitt @ 2012-03-07 10:55 ` Damien Doligez 2012-03-07 15:14 ` Alan Schmitt 1 sibling, 1 reply; 21+ messages in thread From: Damien Doligez @ 2012-03-07 10:55 UTC (permalink / raw) To: Alan Schmitt; +Cc: caml-list Hi Alan, > OS X 10.7.3, ocaml 3.12.1-godi2. You need to apply the patch from this PR: http://caml.inria.fr/mantis/view.php?id=4863 From your "configure" output, I presume godi uses the patch from this PR: http://caml.inria.fr/mantis/view.php?id=5379 but it's incomplete. -- Damien ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-07 10:55 ` Damien Doligez @ 2012-03-07 15:14 ` Alan Schmitt 0 siblings, 0 replies; 21+ messages in thread From: Alan Schmitt @ 2012-03-07 15:14 UTC (permalink / raw) To: Damien Doligez; +Cc: caml-list On 7 mars 2012, at 11:55, Damien Doligez wrote: > Hi Alan, > >> OS X 10.7.3, ocaml 3.12.1-godi2. > > You need to apply the patch from this PR: > > http://caml.inria.fr/mantis/view.php?id=4863 > > From your "configure" output, I presume godi uses the patch from this PR: > > http://caml.inria.fr/mantis/view.php?id=5379 > > but it's incomplete. Thanks, it did work indeed (and I've reported this upstream to the godi list). Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-02-27 15:43 ` Damien Doligez 2012-02-27 17:49 ` Pierre-Alexandre Voye 2012-02-28 15:34 ` Alan Schmitt @ 2012-03-08 11:13 ` Alan Schmitt 2012-03-08 14:16 ` Alan Schmitt 2 siblings, 1 reply; 21+ messages in thread From: Alan Schmitt @ 2012-03-08 11:13 UTC (permalink / raw) To: caml-list list On 27 févr. 2012, at 16:43, Damien Doligez wrote: >> Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined? > > Looks like modules of the standard library, right ? Regarding this, should something special be done when dynlinking a file that depends on the standard library? I assume that dependencies are not automatically loaded, but should one load the standard library first? In other words, is this a bug in why3, or in ocaml? Thanks, Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-08 11:13 ` Alan Schmitt @ 2012-03-08 14:16 ` Alan Schmitt 2012-03-08 14:23 ` Pierre-Alexandre Voye 2012-03-08 16:16 ` Gabriel Scherer 0 siblings, 2 replies; 21+ messages in thread From: Alan Schmitt @ 2012-03-08 14:16 UTC (permalink / raw) To: caml-list list On 8 mars 2012, at 12:13, Alan Schmitt wrote: > On 27 févr. 2012, at 16:43, Damien Doligez wrote: > >>> Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined? >> >> Looks like modules of the standard library, right ? > > Regarding this, should something special be done when dynlinking a file that depends on the standard library? I assume that dependencies are not automatically loaded, but should one load the standard library first? > > In other words, is this a bug in why3, or in ocaml? Trying to get to the bottom of this, here is what I've done. - Adapting the minimal example from http://caml.inria.fr/mantis/view.php?id=5093 I checked that I can load a plugin that uses a function from Random. - I then tried to load a why3 plugin. It fails because it cannot find some symbol (_camlWhy3), and I could not find how to compile things to make sure why3.cmxa is linked with the plugin. - Getting back to the basics, I tried to create a small archive of my own, which I would use in a plugin, and this is where I'm stuck. I have the following files: test.ml: let f () = "foo" plugin.ml: let s = Test.f () let () = print_endline s loader.ml: let load f = try Dynlink.loadfile f with Dynlink.Error e -> print_endline (Dynlink.error_message e) let () = load "plugin.cmxs" to build everything, I do (I tried adding test.cmxa everywhere, to no avail. Everything lives in the same, current directory): ocamlopt.opt -a -o test.cmxa test.ml ocamlopt.opt -c -linkall -o plugin.cmx test.cmxa plugin.ml ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native When I run "./loader.native", I get: no implementation available for Test I googled this error and could only find references to problem related to the (deprecated) Dynlink.add_interfaces, which is not even supposed to work natively. What am I doing wrong? Thanks, Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-08 14:16 ` Alan Schmitt @ 2012-03-08 14:23 ` Pierre-Alexandre Voye 2012-03-08 14:35 ` Alan Schmitt 2012-03-08 16:16 ` Gabriel Scherer 1 sibling, 1 reply; 21+ messages in thread From: Pierre-Alexandre Voye @ 2012-03-08 14:23 UTC (permalink / raw) To: Alan Schmitt; +Cc: caml-list list [-- Attachment #1: Type: text/plain, Size: 2871 bytes --] In Mac Lion, i get : $ ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs ld: warning: -read_only_relocs cannot be used with x86_64 $ ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native File "loader.ml", line 1, characters 0-1: Error: Cannot find file dynlink.cmxa 2012/3/8 Alan Schmitt <alan.schmitt@polytechnique.org> > On 8 mars 2012, at 12:13, Alan Schmitt wrote: > > > On 27 févr. 2012, at 16:43, Damien Doligez wrote: > > > >>> Also, when running why3, I get some undefined symbols (_camlRandom, > _camlParsing, _camlString). Where are these symbols defined? > >> > >> Looks like modules of the standard library, right ? > > > > Regarding this, should something special be done when dynlinking a file > that depends on the standard library? I assume that dependencies are not > automatically loaded, but should one load the standard library first? > > > > In other words, is this a bug in why3, or in ocaml? > > Trying to get to the bottom of this, here is what I've done. > > - Adapting the minimal example from > http://caml.inria.fr/mantis/view.php?id=5093 I checked that I can load a > plugin that uses a function from Random. > - I then tried to load a why3 plugin. It fails because it cannot find some > symbol (_camlWhy3), and I could not find how to compile things to make sure > why3.cmxa is linked with the plugin. > - Getting back to the basics, I tried to create a small archive of my own, > which I would use in a plugin, and this is where I'm stuck. I have the > following files: > > test.ml: > > let f () = "foo" > > plugin.ml: > > let s = Test.f () > let () = print_endline s > > loader.ml: > > let load f = > try > Dynlink.loadfile f > with Dynlink.Error e -> print_endline (Dynlink.error_message e) > > let () = load "plugin.cmxs" > > to build everything, I do (I tried adding test.cmxa everywhere, to no > avail. Everything lives in the same, current directory): > > ocamlopt.opt -a -o test.cmxa test.ml > ocamlopt.opt -c -linkall -o plugin.cmx test.cmxa plugin.ml > ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs > ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native > > When I run "./loader.native", I get: > > no implementation available for Test > > I googled this error and could only find references to problem related to > the (deprecated) Dynlink.add_interfaces, which is not even supposed to work > natively. > > What am I doing wrong? > > Thanks, > > Alan > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > -- --------------------- https://twitter.com/#!/ontologiae/ http://linuxfr.org/users/montaigne [-- Attachment #2: Type: text/html, Size: 4213 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-08 14:23 ` Pierre-Alexandre Voye @ 2012-03-08 14:35 ` Alan Schmitt 2012-03-08 15:50 ` Pierre-Alexandre Voye 0 siblings, 1 reply; 21+ messages in thread From: Alan Schmitt @ 2012-03-08 14:35 UTC (permalink / raw) To: Pierre-Alexandre Voye; +Cc: caml-list list On 8 mars 2012, at 15:23, Pierre-Alexandre Voye wrote: > In Mac Lion, i get : > > $ ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs > ld: warning: -read_only_relocs cannot be used with x86_64 > $ ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native > File "loader.ml", line 1, characters 0-1: > Error: Cannot find file dynlink.cmxa You first need to patch ocaml with this: http://caml.inria.fr/mantis/view.php?id=4863 Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-08 14:35 ` Alan Schmitt @ 2012-03-08 15:50 ` Pierre-Alexandre Voye 2012-03-08 16:19 ` Jérémie Dimino 0 siblings, 1 reply; 21+ messages in thread From: Pierre-Alexandre Voye @ 2012-03-08 15:50 UTC (permalink / raw) To: Alan Schmitt; +Cc: caml-list list [-- Attachment #1: Type: text/plain, Size: 1309 bytes --] After applying the patch, recompiling, your example works fine, but while compiling Ocsigen framework, at the end, I have : ocamlfind ocamlc -thread -o ocsigenserver -linkpkg -linkall -thread -I ../baselib -I ../http -package lwt.ssl -package lwt.extra -package netstring -package findlib -package cryptokit -package tyxml -package tyxml.parser -package dynlink -package tyxml.syntax -I . ../baselib/parsecommandline.cma ../baselib/baselib.cma ../baselib/polytables.cma ../http/http.cma ocsigenserver.cma server_main.cmo File "_none_", line 1, characters 0-1: Error: Error while linking /opt/local/lib/ocaml/camlp4/camlp4lib.cma(Camlp4): Reference to undefined global `Dynlink' 2012/3/8 Alan Schmitt <alan.schmitt@polytechnique.org> > On 8 mars 2012, at 15:23, Pierre-Alexandre Voye wrote: > > > In Mac Lion, i get : > > > > $ ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs > > ld: warning: -read_only_relocs cannot be used with x86_64 > > $ ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native > > File "loader.ml", line 1, characters 0-1: > > Error: Cannot find file dynlink.cmxa > > You first need to patch ocaml with this: > http://caml.inria.fr/mantis/view.php?id=4863 > > Alan > -- --------------------- https://twitter.com/#!/ontologiae/ http://linuxfr.org/users/montaigne [-- Attachment #2: Type: text/html, Size: 2080 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-08 15:50 ` Pierre-Alexandre Voye @ 2012-03-08 16:19 ` Jérémie Dimino 0 siblings, 0 replies; 21+ messages in thread From: Jérémie Dimino @ 2012-03-08 16:19 UTC (permalink / raw) To: Pierre-Alexandre Voye; +Cc: caml-list list Le Thu, 8 Mar 2012 16:50:59 +0100, Pierre-Alexandre Voye <ontologiae@gmail.com> a écrit : > ocamlfind ocamlc -thread -o ocsigenserver -linkpkg -linkall -thread > -I ../baselib -I ../http -package lwt.ssl -package lwt.extra -package > netstring -package findlib -package cryptokit -package tyxml -package > tyxml.parser -package dynlink -package tyxml.syntax -I . > ../baselib/parsecommandline.cma ../baselib/baselib.cma > ../baselib/polytables.cma ../http/http.cma ocsigenserver.cma > server_main.cmo File "_none_", line 1, characters 0-1: > Error: Error while linking > /opt/local/lib/ocaml/camlp4/camlp4lib.cma(Camlp4): > Reference to undefined global `Dynlink' It is probably because there is a missing dependency from camlp4.lib to dynlink. You can check whether it is the case or not with: $ ocamlfind query -r -p-format camlp4.lib If it is not, add dynlink to the requires field of camlp4.lib in the camlp4 META's file. -- Jérémie ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-08 14:16 ` Alan Schmitt 2012-03-08 14:23 ` Pierre-Alexandre Voye @ 2012-03-08 16:16 ` Gabriel Scherer 2012-03-08 16:25 ` Jérémie Dimino 1 sibling, 1 reply; 21+ messages in thread From: Gabriel Scherer @ 2012-03-08 16:16 UTC (permalink / raw) To: Alan Schmitt; +Cc: caml-list list This error is not Mac-related (I can reproduce it on my Debian). I believe it is a result from the "link-by-need" semantics of the .cma and .cmxa: loader.ml does not explicitly depend on test, so when producing the executable test.cmxa isn't linked (modules included .cm{x,}a, contrarily to .cm{x,o}, are only linked when they are a runtime dependency of one of the other modules). I can remove the error by either: - compiling to "test.cmx" instead of "test.cmxa" - or adding a dummy dependency in loader.ml: let () = ignore (Test.f) I am not familiar with the building of dynlink plugins (no idea what "-shared" does and whether you are expecting the compiled code for Test to end up linked inside "plugin.cmxs" instead of linked at executable compile time), so there may be another solution for this. But I remember other people mentioning this "explicit dependency" thing in the past; the dummy dependency is probably the right thing to do if you consider Test a library that come with the loader application and should be usable by all dynlinked module. If it is morally local to "plugin", there must be another approach. On Thu, Mar 8, 2012 at 3:16 PM, Alan Schmitt <alan.schmitt@polytechnique.org> wrote: > On 8 mars 2012, at 12:13, Alan Schmitt wrote: > >> On 27 févr. 2012, at 16:43, Damien Doligez wrote: >> >>>> Also, when running why3, I get some undefined symbols (_camlRandom, _camlParsing, _camlString). Where are these symbols defined? >>> >>> Looks like modules of the standard library, right ? >> >> Regarding this, should something special be done when dynlinking a file that depends on the standard library? I assume that dependencies are not automatically loaded, but should one load the standard library first? >> >> In other words, is this a bug in why3, or in ocaml? > > Trying to get to the bottom of this, here is what I've done. > > - Adapting the minimal example from http://caml.inria.fr/mantis/view.php?id=5093 I checked that I can load a plugin that uses a function from Random. > - I then tried to load a why3 plugin. It fails because it cannot find some symbol (_camlWhy3), and I could not find how to compile things to make sure why3.cmxa is linked with the plugin. > - Getting back to the basics, I tried to create a small archive of my own, which I would use in a plugin, and this is where I'm stuck. I have the following files: > > test.ml: > > let f () = "foo" > > plugin.ml: > > let s = Test.f () > let () = print_endline s > > loader.ml: > > let load f = > try > Dynlink.loadfile f > with Dynlink.Error e -> print_endline (Dynlink.error_message e) > > let () = load "plugin.cmxs" > > to build everything, I do (I tried adding test.cmxa everywhere, to no avail. Everything lives in the same, current directory): > > ocamlopt.opt -a -o test.cmxa test.ml > ocamlopt.opt -c -linkall -o plugin.cmx test.cmxa plugin.ml > ocamlopt.opt -shared plugin.cmx test.cmxa -o plugin.cmxs > ocamlopt.opt test.cmxa dynlink.cmxa loader.ml -o loader.native > > When I run "./loader.native", I get: > > no implementation available for Test > > I googled this error and could only find references to problem related to the (deprecated) Dynlink.add_interfaces, which is not even supposed to work natively. > > What am I doing wrong? > > Thanks, > > Alan > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-08 16:16 ` Gabriel Scherer @ 2012-03-08 16:25 ` Jérémie Dimino 2012-03-08 16:31 ` Alan Schmitt 0 siblings, 1 reply; 21+ messages in thread From: Jérémie Dimino @ 2012-03-08 16:25 UTC (permalink / raw) To: Gabriel Scherer; +Cc: Alan Schmitt, caml-list list Le Thu, 8 Mar 2012 17:16:30 +0100, Gabriel Scherer <gabriel.scherer@gmail.com> a écrit : > This error is not Mac-related (I can reproduce it on my Debian). > I believe it is a result from the "link-by-need" semantics of the .cma > and .cmxa: loader.ml does not explicitly depend on test, so when > producing the executable test.cmxa isn't linked (modules included > .cm{x,}a, contrarily to .cm{x,o}, are only linked when they are a > runtime dependency of one of the other modules). > > I can remove the error by either: > - compiling to "test.cmx" instead of "test.cmxa" > - or adding a dummy dependency in loader.ml: > let () = ignore (Test.f) You can also use -linkall for building loader.native. In fact -linkall should always be used when you are using dynlink plugins. -- Jérémie ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Caml-list] state of native dynlink on os x 2012-03-08 16:25 ` Jérémie Dimino @ 2012-03-08 16:31 ` Alan Schmitt 0 siblings, 0 replies; 21+ messages in thread From: Alan Schmitt @ 2012-03-08 16:31 UTC (permalink / raw) To: Jérémie Dimino; +Cc: Gabriel Scherer, caml-list list On 8 mars 2012, at 17:25, Jérémie Dimino wrote: > Le Thu, 8 Mar 2012 17:16:30 +0100, > Gabriel Scherer <gabriel.scherer@gmail.com> a écrit : > >> This error is not Mac-related (I can reproduce it on my Debian). >> I believe it is a result from the "link-by-need" semantics of the .cma >> and .cmxa: loader.ml does not explicitly depend on test, so when >> producing the executable test.cmxa isn't linked (modules included >> .cm{x,}a, contrarily to .cm{x,o}, are only linked when they are a >> runtime dependency of one of the other modules). >> >> I can remove the error by either: >> - compiling to "test.cmx" instead of "test.cmxa" >> - or adding a dummy dependency in loader.ml: >> let () = ignore (Test.f) > > You can also use -linkall for building loader.native. In fact -linkall > should always be used when you are using dynlink plugins. That was it. Thanks a lot! Alan ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2012-03-08 16:32 UTC | newest] Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-02-15 11:17 [Caml-list] state of native dynlink on os x Alan Schmitt 2012-02-15 12:34 ` Daniel Bünzli 2012-02-15 14:16 ` Alan Schmitt 2012-02-17 6:47 ` Alan Schmitt 2012-02-27 15:43 ` Damien Doligez 2012-02-27 17:49 ` Pierre-Alexandre Voye 2012-02-28 10:15 ` David MENTRE 2012-02-28 10:32 ` Pierre-Alexandre Voye 2012-02-28 15:34 ` Alan Schmitt 2012-02-29 8:33 ` Alan Schmitt 2012-03-07 10:55 ` Damien Doligez 2012-03-07 15:14 ` Alan Schmitt 2012-03-08 11:13 ` Alan Schmitt 2012-03-08 14:16 ` Alan Schmitt 2012-03-08 14:23 ` Pierre-Alexandre Voye 2012-03-08 14:35 ` Alan Schmitt 2012-03-08 15:50 ` Pierre-Alexandre Voye 2012-03-08 16:19 ` Jérémie Dimino 2012-03-08 16:16 ` Gabriel Scherer 2012-03-08 16:25 ` Jérémie Dimino 2012-03-08 16:31 ` Alan Schmitt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox