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

"Cannot relocate" error with flexdll in OCaml for Windows 4.11 (and older versions) #92

Open
maroneze opened this issue May 11, 2021 · 8 comments

Comments

@maroneze
Copy link

Hello,

I just installed OCaml for Windows 4.11.1 (4.11.1+mingw64c) and, as before, I tried to install and run the frama-c package, which uses dynamic loading for its plugins. Compilation worked fine, but trying to run it fails with:

[kernel] User Error: cannot load plug-in 'num.core': cannot load module
  Details: error loading shared library: Dynlink.Error (Dynlink.Cannot_open_dll "Failure(\"flexdll error: cannot relocate RELOC_REL32, target is too far: ffffffff6a110d73  000000006a110d73\")")
[kernel] User Error: cannot load plug-in 'zip': cannot load module
  Details: error loading shared library: Dynlink.Error (Dynlink.Cannot_open_dll "Failure(\"flexdll error: cannot relocate RELOC_REL32, target is too far: fffffffe488b648d  00000000488b648d\")")
[kernel] User Error: cannot load plug-in 'why3': cannot load module
  Details: error loading shared library: Dynlink.Error (Dynlink.Cannot_open_dll "Failure(\"Cannot resolve camlGzip\")")
[kernel] User Error: cannot load plug-in 'frama-c-wp': cannot load module
  Details: error loading shared library: Dynlink.Error (Dynlink.Cannot_open_dll "Failure(\"Cannot resolve camlWhy3__Ident\")")

I had never seen this issue before; frama-c worked with several previous versions of the OCaml compiler. After testing, I noticed it also happens with older versions of Frama-C, and with OCaml as old as 4.08.1 (I didn't have the time to test other versions; each compilation takes about 1 hour...). So I wonder if something changed on Windows or in flexdll. The same issue happened to one of our users, so it's not just my machine. I'm not sure what to do on the Frama-C side to debug it.

Are there any known issues issues related to the "flexdll error: cannot relocate RELOC_REL32, target is too far" message? Would you have any suggestions on how to proceed to debug this?

By the way, running flexlink -help displays FlexDLL version 0.38fdopen1; so I'm not sure I should contact fdopen directly to ask for help; sorry if the issue is unrelated to you.

@dra27
Copy link
Member

dra27 commented May 11, 2021

You need to downgrade the Cygwin mingw64 binutils package to 2.35, I’m afraid.

@maroneze
Copy link
Author

maroneze commented May 12, 2021

Thanks for the tip. I just downgraded to 2.35.2-1 (from 2.36.1-2) and recompiled Why3 and Frama-C, however it still didn't work. I'll try 2.35.1-1, and otherwise try a clean reinstall, just in case.

Oh wait, in fact I had reinstalled the binutils package, not the mingw64-x86_64-binutils, which remained at 2.36...

@dra27
Copy link
Member

dra27 commented May 12, 2021

You'll need to recompile everything, I'm afraid!

@dra27
Copy link
Member

dra27 commented May 12, 2021

The longer term fix for OCaml < 4.12 will be to add overrides for the image-base in flexlink and patch the old compilers to use it (so I'll keep the issue open to remind me!)

@maroneze
Copy link
Author

Just to make sure, is the issue still supposed to happen if I install the OCaml switch 4.12.0+mingw64c? Because I did so, and it still doesn't work with binutils 2.36 (same error).

However, after downgrading to mingw64-x86_64-binutils version 2.35.2-1 and reinstalling the opam switch, I was indeed able to avoid the flexdll error. Thank you very much!

@dra27
Copy link
Member

dra27 commented May 12, 2021

That's right - the fix will be in 4.12.1, but it's non-trivial to back-port the fix from 4.12 to earlier versions.

@maroneze
Copy link
Author

Ok, thanks for the clarification.

I think we have no constraints w.r.t. OCaml versions, so the backport is not very important to us. Just knowing that it will still work in the future, and that there's a workaround for the current versions, is great!

@yakobowski
Copy link
Contributor

yakobowski commented Oct 5, 2021

For other people who may stumble upon this, the 4.12.1 fix is ocaml/ocaml#10351.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants