Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Teach ocamlbuild to create shared libraries using -output-obj #6733
Original bug ID: 6733
Currently I am using the following code (parts of which are pulled into myocamlbuild, not being accessible from ocamlbuild library):
Then, I just do
Possibly it is also useful to provide
Comment author: @whitequark
@gasche, I added a patch. It adds the .so targets, and also a runtime_variant parametric flag.
The flag is needed on, I think, mainly x86, where all code in a shared library must be linked with -fPIC. On e.g. ARM, there is no such restriction.
Until #6693 is fixed, the ocamlbuild testsuite will fail (on x86, at least).
I did not add a runtime_variant(_shared) flag to the default tags for .so targets, because:
I think it is OK to leave the default tags as-is, or if there will be a _pic variant of the runtime--a .a archive built with -fPIC--we could add runtime_variant(_pic) so that everything builds by default on all platforms. Having to manually specify "-runtime_variant(_pic), runtime_variant(_some_other)" is a bit awkward, but should be rarely needed.
Comment author: @gasche
Using the proposed patch, the test fails on my machine with the following log:
/home/gasche/.opam/4.03.0+local-git-trunk/bin/ocamldep.opt -modules hello.ml > hello.ml.depends
Indeed, #6693 builds no libasmrun_shared.a, only libasmrun_shared.so.