| Anonymous | Login | Signup for a new account | 2013-06-19 10:39 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0003866 | OCaml | OCaml general | public | 2005-11-15 20:19 | 2009-04-01 18:53 | |||
| Reporter | administrator | |||||||
| Assigned To | xleroy | |||||||
| Priority | normal | Severity | feature | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | ||||||||
| Target Version | Fixed in Version | 3.11.0 | ||||||
| Summary | 0003866: Patch to build and install libcamlrun.so | |||||||
| 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 $(BYTECC) $(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) -o ocamlrun$(EXE) \ @@ -51,6 +58,9 @@ cp ocamlrun$(EXE) $(BINDIR)/ocamlrun$(EXE) cp libcamlrun.a $(LIBDIR)/libcamlrun.a cd $(LIBDIR); $(RANLIB) libcamlrun.a +ifeq ($(SUPPORTS_SHARED_LIBRARIES),true) + cp libcamlrun.so $(LIBDIR)/libcamlrun.so +endif if test -d $(LIBDIR)/caml; then : ; else mkdir $(LIBDIR)/caml; fi for i in $(PUBLIC_INCLUDES); do \ sed -f ../tools/cleanup-header $$i > $(LIBDIR)/caml/$$i; \ @@ -69,8 +79,11 @@ ar rc libcamlrund.a $(DOBJS) $(RANLIB) libcamlrund.a +libcamlrun.so: $(PICOBJS) + $(MKSHAREDLIB) $@ $(PICOBJS) + clean: - rm -f ocamlrun$(EXE) ocamlrund$(EXE) *.o lib*.a + rm -f ocamlrun$(EXE) ocamlrund$(EXE) *.o lib*.a lib*.so rm -f primitives prims.c opnames.h jumptbl.h ld.conf 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: + @ if test -f $*.o; then mv $*.o $*.f.o; else :; fi + $(CC) $(CFLAGS) $(SHAREDCCCOMPOPTS) -c $< + mv $*.o $*.pic.o + @ if test -f $*.f.o; then mv $*.f.o $*.o; else :; fi + 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 | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0003413) zack (reporter) 2005-12-02 17:09 |
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. |
|
(0003704) Richard Jones (reporter) 2006-07-10 16:43 |
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. |
|
(0004167) zack (reporter) 2007-09-28 17:02 |
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, Cheers. |
|
(0004168) Richard Jones (reporter) 2007-09-28 18:31 |
We need this change in Fedora too, but in order to accept it we need an indication from INRIA that they would be prepared to make this change in an upcoming version of OCaml. See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=444360 [^] |
|
(0004240) xleroy (administrator) 2007-11-06 16:46 |
I'm OK with the proposed solution (build and install a libcamlrun_shared.so DLL) and will incorporate it in 3.11. |
|
(0004573) xleroy (administrator) 2008-08-06 10:57 |
As promised, the CVS working sources (soon to become release 3.11) now build and install libcamlrun_shared.so. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2005-11-18 10:13 | administrator | New Issue | |
| 2005-12-02 17:09 | zack | Note Added: 0003413 | |
| 2006-07-10 16:43 | Richard Jones | Note Added: 0003704 | |
| 2007-09-28 17:02 | zack | Note Added: 0004167 | |
| 2007-09-28 17:03 | zack | File Added: camlrun_shared.dpatch | |
| 2007-09-28 18:31 | Richard Jones | Note Added: 0004168 | |
| 2007-11-06 16:46 | xleroy | Note Added: 0004240 | |
| 2007-11-06 16:46 | xleroy | Assigned To | => xleroy |
| 2007-11-06 16:46 | xleroy | Description Updated | |
| 2008-08-06 10:57 | xleroy | Note Added: 0004573 | |
| 2008-08-06 10:57 | xleroy | Status | acknowledged => resolved |
| 2008-08-06 10:57 | xleroy | Resolution | open => fixed |
| 2009-04-01 18:53 | xleroy | Status | resolved => closed |
| 2009-04-01 18:53 | xleroy | Fixed in Version | => 3.11.0 |
| Copyright © 2000 - 2011 MantisBT Group |