Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynlink fails on linux #5093

Closed
vicuna opened this issue Jul 5, 2010 · 7 comments
Closed

Dynlink fails on linux #5093

vicuna opened this issue Jul 5, 2010 · 7 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 5, 2010

Original bug ID: 5093
Reporter: @dbuenzli
Assigned to: @xclerc
Status: closed (set by @xclerc on 2011-02-21T15:29:55Z)
Resolution: not a bug
Priority: normal
Severity: major
Platform: Unix
OS: Linux
OS Version: 2.6.32-23
Version: 3.12.0+beta1 or 3.12.0+rc1
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @dbuenzli

Bug description

In the attached program loading plugin.cmxs fails on linux because of undefined symbols. On osx, the same program works.

Thanks,

Daniel

Steps to reproduce

dbuenzli@minidip:/sync$ uname -a
Linux minidip 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 07:54:58 UTC 2010 i686 GNU/Linux
dbuenzli@minidip:
/sync$ tar -xjf bug-dlink.tbz
dbuenzli@minidip:/sync$ cd bug-dlink
build.sh* build.sh
* loader.ml plugin.ml _tags
dbuenzli@minidip:/sync/bug-dlink$ ./build.sh
/usr/local/bin/ocamldep.opt -modules plugin.ml > plugin.ml.depends
/usr/local/bin/ocamlc.opt -c -linkall -o plugin.cmo plugin.ml
/usr/local/bin/ocamlopt.opt -c -linkall -o plugin.cmx plugin.ml
/usr/local/bin/ocamlopt.opt -shared plugin.cmx -o plugin.cmxs
/usr/local/bin/ocamldep.opt -modules loader.ml > loader.ml.depends
/usr/local/bin/ocamlc.opt -c -linkall -o loader.cmo loader.ml
/usr/local/bin/ocamlopt.opt -c -linkall -o loader.cmx loader.ml
/usr/local/bin/ocamlopt.opt dynlink.cmxa loader.cmx -o loader.native
dbuenzli@minidip:
/sync/bug-dlink$ ./loader.native
error loading shared library: /home/dbuenzli/sync/bug-dlink/_build/plugin.cmxs: undefined symbol: camlPervasives__print_endline_1274

File attachments

@vicuna
Copy link
Author

vicuna commented Jul 6, 2010

Comment author: @alainfrisch

I cannot reproduce the bug on my 64-bit Linux machine. I get "no bug" printed.

$ uname -a
Linux LEROY 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 08:03:28 UTC 2010 x86_64 GNU/Linux

I'll try to find a 32-bit Linux...

@vicuna
Copy link
Author

vicuna commented Jul 6, 2010

Comment author: @alainfrisch

Same on a freshly installed 32-bit Linux machine:

$ uname -a
Linux ubuntu 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010 i686 GNU/Linux

I still cannot reproduce your problem.

Could you add the -verbose option to ocamlopt? Normally, the command line used for linking the main program should contain -Wl,-E, whose effect is to make all symbols from the main program available to shared libraries.

@vicuna
Copy link
Author

vicuna commented Jul 6, 2010

Comment author: @dbuenzli

That's it.

The option -Wl,-E is missing and if I add it with -cclib everything works perfectly.

What strange is that the output of configure mentions this option as link flags. It is also mentioned in the BYTECCLINKOPTS and NATDYNLINKOPTS variables of /usr/local/lib/ocaml/Makefile.config.

Can you find out where something is missing ? Let me know if I can help.

Daniel

@vicuna
Copy link
Author

vicuna commented Jul 6, 2010

Comment author: @alainfrisch

Normally the -Wl,-E option is stored in dynlink.cmxa (see otherlibs/dynlink/Makefile) and should thus be inserted on the command-line used to link your main program. Could you rebuild OCaml and look for the command-line that builds dynlink.cmxa?

@vicuna
Copy link
Author

vicuna commented Jul 6, 2010

Comment author: @dbuenzli

I build with build/fastworld.sh, _build/_log mentions :

Target: otherlibs/dynlink/nat/dynlink.cmxa, tags: { debug, dont_link_with, extension:cmxa, file:otherlibs/dynlink/nat/dynlink.cmxa, library, link, native, ocaml, otherlibs, quiet, traverse, use_stdlib }

./ocamlopt.opt -nostdlib -a -I stdlib myocamlbuild_config.cmx utils/misc.cmx parsing/linenum.cmx utils/terminfo.cmx utils/warnings.cmx parsing/location.cmx parsing/longident.cmx typing/ident.cmx typing/path.cmx typing/primitive.cmx typing/types.cmx typing/btype.cmx typing/predef.cmx typing/datarepr.cmx utils/tbl.cmx typing/subst.cmx utils/config.cmx utils/clflags.cmx utils/consistbl.cmx typing/env.cmx bytecomp/lambda.cmx asmcomp/debuginfo.cmx asmcomp/clambda.cmx otherlibs/dynlink/nat/dynlink.cmx -o otherlibs/dynlink/nat/dynlink.cmxa

Target: otherlibs/dynlink/dynlink.cmxa, tags: { }

cp -p otherlibs/dynlink/nat/dynlink.cmxa otherlibs/dynlink/dynlink.cmxa

@vicuna
Copy link
Author

vicuna commented Jul 6, 2010

Comment author: @alainfrisch

This is clearly the source of the problem. Just to be sure, could you rebuild with "make world opt" and confirm that your example works fine?

@vicuna
Copy link
Author

vicuna commented Jul 6, 2010

Comment author: @dbuenzli

Yes it works with make world.opt. Thanks for your support.

Btw, we are all losing our time here to minimize these issues could the dev team give a serious look at this suggestion :

#4738

Best,

Daniel

@vicuna vicuna closed this as completed Feb 21, 2011
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant