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

ocamlc.opt on cygwin32/64 can not link to unix library #7268

Closed
vicuna opened this Issue May 30, 2016 · 8 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented May 30, 2016

Original bug ID: 7268
Reporter: persol
Assigned to: @alainfrisch
Status: resolved (set by @alainfrisch on 2016-07-13T15:42:40Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 4.03.0
Fixed in version: 4.04.0 +dev / +beta1 / +beta2
Category: platform support (windows, cross-compilation, etc)
Monitored by: antron @gasche @diml

Bug description

ocamlc.opt, can not link to unix.cma on cygwin32/cygwin64

Steps to reproduce

$ uname -rsv
CYGWIN_NT-10.0-WOW 2.5.1(0.297/5/3) 2016-04-21 22:12
$ cat foo.ml
let () = print_float (Unix.gettimeofday ()); print_newline ()
$ ocamlc.opt -o foo unix.cma foo.ml
Error: Error on dynamically loaded library: /home/pela/.opam/4.03.0/lib/ocaml/stublibs/dllunix.so: Cannot resolve caml_debugger_cleanup_fork

Additional information

ocamlc works fine

This is a show stopper because ocamlbuild uses ocamlc.opt with the consequence that many opam packages now can't be installed

Have tested this on both cygwin32 and cygwin64 with the same result

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jul 13, 2016

Comment author: @alainfrisch

The problem is that ocamlc.opt is linked (of course) with the native runtime, and this runtime does not expose caml_debugger_* symbols.

The DLL is opened in "not for execution" mode, but the DLL itself, in its entry point, will trigger the relocation. I don't think there is a way to prevent the DLL entry point from being executed (or is it?). So I can see two options:

  • Link the DLL without an entry point. Since it is explicitly opened by ocamlrun through flexdll, the relocation will be done explicitly.

    EDIT: I tried passing "-noentry" to flexlink for creating dllunix.so, but it fails with

    ertr000001.o:(.rdata+0x0): référence indéfinie vers « _pei386_runtime_relocator »

  • In "RTLD_NOEXEC" mode, set FLEXDLL_RELOCATE=0 (instead of &flexdll_relocate) to tell the entry point not to trigger the relocation.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jul 13, 2016

Comment author: @alainfrisch

Also, note that this only affects the Cygwin port, not other Windows ports (which go though LoadLibraryEx and pass some flag which disable the execution of the DLL entry point).

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jul 13, 2016

Comment author: @alainfrisch

Fixed in flexdll:

alainfrisch/flexdll@42ea731

@vicuna vicuna closed this Jul 13, 2016

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 17, 2016

Comment author: persol

I still get the same error when trying now to use ocaml 4.04 on cygwin64. When can I expect the fixes to flexdll reach the official cygwin distribution? Can I compile flexdll myself and replace the current cygwin flexdll (v.034) in the mean time?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 23, 2016

Comment author: antron

I can confirm that this is fixed with FlexDLL 0.35. I built FlexDLL from source 1 and replaced the one distributed by Cygwin.

Now, I'm actually not sure if this was broken due to FlexDLL, because there seems to be an issue with Cygwin packaging of OCaml. I tried to package OCaml 4.04, and got the error in this issue. The cygport packaging tool was stripping dllunix.so, presumably removing bytecode. I had to add RESTRICT=strip to the .cygport file to prevent this.

FYI I package OCaml, Camlp4, OPAM, and now FlexDLL, as Cygwin packages for use in Lwt's AppVeyor builds 2. If interested, I can adapt these packages and release to Cygwin's public repository.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 24, 2016

Comment author: persol

Thanks for your help, I will compile flexdll 0.35 and give it a try with ocaml 4.04. Of course it would be great if there will be an official release soon also, I have no knowledge who is the cygwin maintainer for ocaml/flexdll though.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 24, 2016

Comment author: antron

I will email the Cygwin mailing list later today. If anyone here has info on this, would be interested to know as well.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 26, 2016

Comment author: antron

FlexDLL 0.35 is now installable via Cygwin setup, both on x86 and x86_64. Package submitted by Yaakov Selkowitz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.