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
static linking fails #7697
Comments
Comment author: @nojb Hello, thanks for the report. It would be useful if you could run the command ocamlopt -ccopt -static ... with 4.05 and 4.06 adding the flag -verbose, which will show us a trace of the linking command used and any passed flags. A small reproduction case would also be useful if you can produce one. |
Comment author: korovin Thanks for quick reply. The project is in http://www.cs.man.ac.uk/~korovink/iprover/iprover_2017_Dec_22_7h.tar.gz To compile: ./configure --
|
Comment author: @nojb Diffing both traces, we see that for 4.06 we are passing -Wl,-E to the linker. Could you try adding the flag -ccopt -Wl,--no-export-dynamic to your ocamlopt invocation and see if it works? |
Comment author: korovin After including these flags (together with -static) I'm getting: ocamlopt -ccopt -Wl,--no-export-dynamic,-static obj/aiger.o obj/aigLoad.o obj/solver.o obj/solver_interface.o -o iproveropt
I briefly looked but could not find an easy fix to this. Thanks |
Comment author: @gasche (Once we understand how to get a smaller repro case, I think that having it in the testsuite would be helpful to catch future regressions such as this one.) |
Comment author: @nojb Could you try adding the flag -ccopt -static-libgcc on top of -ccopt -Wl,--no-export-dynamic to the ocamlopt invocation? |
Comment author: korovin It compiles with -ccopt -Wl,--no-export-dynamic -ccopt -static-libgcc (below) ldd shows:ldd iproveropt ========== ocamlopt -ccopt -Wl,--no-export-dynamic -ccopt -static-libgcc obj/aiger.o obj/aigLoad.o obj/solver.o obj/solver_interface.o -o iproveropt
|
Comment author: @nojb Thanks. I believe the "culprit" is 8b6df3a755. |
Comment author: @nojb But I am not sure what is the "right solution" in any case. |
Comment author: korovin Some clarification:
ocamlopt -verbose -ccopt -static static_linking_test.ml -o static_linking_test
Thanks |
Comment author: @nojb Personally I am leaning to marking this issue as "resolved, no change required". If one wants to link everything statically it can be done and just needs special flags to be passed to the compiler using -ccopt. The bug fix 8b6df3a755 made it necessary to pass one more flag to achieve static linking, but it is not a "regression" per se, in my view. |
Comment author: @gasche -ccopt -static is what is documented in the manual http://caml.inria.fr/pub/docs/manual-ocaml-4.06/intfc.html#sec418 and on the web http://rgrinberg.com/posts/static-binaries-tutorial/ At the very least, it would be nice to have the correct options be documented somewhere. |
Comment author: @nojb Ah, I had missed the fact that -ccopt -static is advertised in the manual, thanks for the pointer. In that case we need to do something about this. |
Comment author: @xavierleroy
Probably it should not be advertised. These days, many C compilers and C libraries just don't work with static linking or require other linking options beyond -static to achieve the same effect. When that part of the manual was written, "-ccopt -static" was a good way to produce Linux executables that could run on different distributions that have different libraries. This is no longer the case. |
Added back ability for static linking For memory workarround for static linking fails : ocaml/ocaml#7697
Added back ability for static linking For memory workarround for static linking fails : ocaml/ocaml#7697
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Original bug ID: 7697
Reporter: korovin
Status: confirmed (set by @nojb on 2017-12-22T16:42:41Z)
Resolution: open
Priority: normal
Severity: minor
OS: Ubuntu
OS Version: 14.04.4
Version: 4.06.0
Category: platform support (windows, cross-compilation, etc)
Related to: #7562
Monitored by: @nojb @gasche
Bug description
Hello,
Could you please take a look at the following issue.
After switching from OCaml 4.05 to 4.06 my project fails to link statically (if I switch back to 4.05 it compiles and links statically fine).
ocamlopt -ccopt -static ...
The error message:
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol
floor' with pointer equality in
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libm.a(s_floor.o)' cannot be used when making an executable; recompile with -fPIE and relink with -piecollect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking
Many thanks,
Konstantin
The text was updated successfully, but these errors were encountered: