flexdll
flexdll copied to clipboard
"Cannot relocate" error with flexdll in OCaml for Windows 4.11 (and older versions)
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.
You need to downgrade the Cygwin mingw64 binutils package to 2.35, I’m afraid.
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...
You'll need to recompile everything, I'm afraid!
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!)
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!
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.
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!
For other people who may stumble upon this, the 4.12.1 fix is https://github.com/ocaml/ocaml/pull/10351.