Description
Original bug ID: 6693
Reporter: Richard Jones
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2017-02-16T14:15:13Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: amd64
OS: Linux
Target version: 4.02.2+dev / +rc1
Fixed in version: 4.02.2+dev / +rc1
Category: runtime system and C interface
Tags: patch
Related to: #6733 #6845
Monitored by: @whitequark @gasche @ygrek @hcarty
Bug description
I want to routinely build Linux .so files containing OCaml code. This can be done, see Gerd's instructions here:
http://www.camlcity.org/knowledge/kb_002_shared_library.html
but it requires that you recompile OCaml with -fPIC, otherwise you get this error:
/usr/bin/ld: /usr/lib64/ocaml/libasmrun.a(startup.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
So it would be nice if this just worked out of the box. I think by analogy to libcamlrun_shared.so, there should be libasmrun_shared.so, and ocamlopt should select '-lasmrun_shared' when asked to build a .so file.
This has been requested multiple times on the mailing list:
http://caml.inria.fr/pub/ml-archives/caml-list/2009/12/19e3dc20e585bd216f200789cbea922a.en.html
https://groups.google.com/d/topic/fa.caml/T6blKLDFDog/discussion
http://caml.inria.fr/pub/ml-archives/caml-list/2009/12/7a299d294aa5b8152ce26a18eb03a2dc.en.html