-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Patch to build and install libcamlrun.so #3866
Comments
Comment author: zack Using the above patch will make "ocamlc -custom" always prefer linking libcamlrun.so over libcamlrun.a (at least on i386 with binutils 2.16.1). This means that custom executable will need to be run with a proper LD_LIBRARY_PATH environment variable and that they will be slower. Quick benchmarks seem to suggest a 15% slowdown. A proper solution seems to be to add a command line switch to ocamlc that let the user choose which runtime he wants to be linked in; or, as an alternative, a command line switch "-picruntime" which choose a "libcamlrun_pic.a" instead of the default "libcamlrun.a". I can provide a patch if someone has the autority to decide on the proper solution. Cheers. |
Comment author: Richard Jones I guess this issue isn't progressing anywhere, but we still very much need a way to link the OCaml runtime into shared libraries on AMD64. I think it's enough just to rename the shared library as libcamlrun_shared.so (or something similar). This can be completely ignored by ordinary users, and it won't get linked into custom toplevels. But for those of us requiring the feature, we will know where to look and how to link it in. Is this sufficient to get this into OCaml? Rich. |
Comment author: zack An updated patch implementing the proposed solution (i.e. not changing how libcamlrun is currently linked, but instead providing an alternative version of the library called libcamlrun_shared.so which includes only PIC code) is available at http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/ocaml/trunk/debian/patches/camlrun_shared.dpatch?op=file&rev=0&sc=0 It is working against ocaml 3.10 (note indeed that the initial patch, 2 year old now, does not longer work with 3.10). The patch reflects what we are going to ship in the ocaml Debian package. Can you please someone consider adopting this patch also in the official ocaml package? The feature we are asking here is badly needed in several cases and no one gave so far evidence that it would be worst than the status quo in any respect ... TIA, |
Comment author: Richard Jones We need this change in Fedora too, but in order to accept it See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=444360 |
Comment author: @xavierleroy I'm OK with the proposed solution (build and install a libcamlrun_shared.so DLL) and will incorporate it in 3.11. |
Comment author: @xavierleroy As promised, the CVS working sources (soon to become release 3.11) now build and install libcamlrun_shared.so. |
Original bug ID: 3866
Reporter: administrator
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2009-04-01T16:53:14Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 3.11.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: jm @Chris00 zack @alainfrisch
Bug description
Full_Name: Richard Jones
Version: 3.09.0
OS: Linux
Submission from: 84-45-213-206.no-dns-yet.enta.net (84.45.213.206)
It's occasionally useful to be able to link the bytecode interpreter
into a shared library. mod_caml (the Apache module for running OCaml
programs) is one program which does this.
On x86 this is possible just by linking your shared library with libcamlrun.a.
However on AMD64 (and Solaris 64 bit) this is not possible. The patch below
is very minimal - it simply builds libcamlrun.so, compiled with -fPIC, provided
the platform supports shared libraries.
It is against OCaml 3.09.0.
(Patch also available here:
http://annexia.org/tmp/libcamlrun.so.patch )
diff -ur ocaml-3.09.0.orig/byterun/Makefile ocaml-3.09.0/byterun/Makefile
--- ocaml-3.09.0.orig/byterun/Makefile 2005-10-18 15:03:52.000000000 +0100
+++ ocaml-3.09.0/byterun/Makefile 2005-11-15 19:12:54.000000000 +0000
@@ -29,6 +29,8 @@
DOBJS=$(OBJS:.o=.d.o) instrtrace.d.o
+PICOBJS=$(OBJS:.o=.pic.o)
+
PRIMS=alloc.c array.c compare.c extern.c floats.c gc_ctrl.c hash.c
intern.c interp.c ints.c io.c lexing.c md5.c meta.c obj.c parsing.c
signals.c str.c sys.c terminfo.c callback.c weak.c finalise.c stacks.c
@@ -37,7 +39,12 @@
PUBLIC_INCLUDES=alloc.h callback.h config.h custom.h fail.h intext.h
memory.h misc.h mlvalues.h printexc.h signals.h compatibility.h
+ifeq ($(SUPPORTS_SHARED_LIBRARIES),true)
+all: ocamlrun$(EXE) ld.conf libcamlrun.so
+else
all: ocamlrun$(EXE) ld.conf
+endif
+
ocamlrun$(EXE): libcamlrun.a prims.o
(BYTECCCOMPOPTS) (EXE) (EXE) (RANLIB) libcamlrun.a
@@ -51,6 +58,9 @@
cp ocamlrun$(EXE)
cp libcamlrun.a $(LIBDIR)/libcamlrun.a
cd
+ifeq ($(SUPPORTS_SHARED_LIBRARIES),true)
+endif (LIBDIR)/caml; fi $i;
if test -d
for i in $(PUBLIC_INCLUDES); do
sed -f ../tools/cleanup-header $$i >
@@ -69,8 +79,11 @@
ar rc libcamlrund.a $(DOBJS)
$(RANLIB) libcamlrund.a
+libcamlrun.so: $(PICOBJS)
clean:
primitives : $(PRIMS)
@@ -105,7 +118,7 @@
-e '/let *ocaml_version *= */s//#define OCAML_VERSION /p'
<../stdlib/sys.ml >version.h
-.SUFFIXES: .d.o
+.SUFFIXES: .d.o .pic.o
.c.d.o:
@ if test -f $.o; then mv $.o $.f.o; else :; fi
@@ -113,6 +126,12 @@
mv $.o $.d.o
@ if test -f $.f.o; then mv $.f.o $.o; else :; fi
+.c.pic.o:
depend : prims.c opnames.h jumptbl.h version.h
gcc -MM $(BYTECCCOMPOPTS) *.c > .depend
gcc -MM $(BYTECCCOMPOPTS) -DDEBUG *.c | sed -e 's/.o/.d.o/' >> .depend
File attachments
The text was updated successfully, but these errors were encountered: