From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 031E0BC86 for ; Wed, 1 Aug 2007 11:43:41 +0200 (CEST) Received: from ctsmtpout2.frontal.correo (smtp.telefonica.net [213.4.149.66]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l719heXj024323 for ; Wed, 1 Aug 2007 11:43:40 +0200 Received: from tux-chan (88.6.11.46) by ctsmtpout2.frontal.correo (7.2.056.6) (authenticated as ferferse$telefonica.net) id 46AE33E60003E3C3 for caml-list@inria.fr; Wed, 1 Aug 2007 11:43:40 +0200 Received: from batsman by tux-chan with local (Exim 3.36 #1 (Debian)) id 1IGAjz-00074G-00 for ; Wed, 01 Aug 2007 11:43:39 +0200 Date: Wed, 1 Aug 2007 11:43:39 +0200 From: Mauricio Fernandez To: caml-list@inria.fr Subject: Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension Message-ID: <20070801094338.GC31718@tux-chan> Mail-Followup-To: caml-list@inria.fr References: <20070801040102.GA88101@lizzy.catnook.local> <20070801074422.GA5362@jiyu.gnu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070801074422.GA5362@jiyu.gnu> User-Agent: Mutt/1.5.11 Sender: =?iso-8859-1?Q?Mauricio_Julio_Fern=E1ndez_Pradier?= X-Miltered: at concorde with ID 46B055CC.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0200,:01 ocaml:01 ocaml:01 patched:01 ocamlopt:01 -output-obj:01 -output-obj:01 gcc:01 lib:01 -fpic:01 ocamlopt:01 runtime:01 cmxa:01 cmx:01 cmx:01 On Wed, Aug 01, 2007 at 09:44:22AM +0200, Julien Moutinho wrote: > On Tue, Jul 31, 2007 at 09:01:02PM -0700, Jos Backus wrote: > > Hi. I'm trying to use rocaml to wrap an Ocaml library so it can be accessed > > from a dynamic Ruby extension (using Callback.register). Everything works, > > except when I try to access the Ocaml type from Ruby the following Ruby > > LoadError is emitted: > > > > undefined symbol: caml_tuplify2 > > > > So my question is: what do I need to do in order to satisfy this symbol? It > > doesn't appear in any library. ocaml version is 3.09.2. > > AFAICS, when needed, caml_tuplifyN end up within the /tmp/camlstartup*.s file > mechanically generated at link time. > You can keep this file with -dstartup. > > Unfortunately, due to its quasi-random name, > it is not easy to retrieve it mechanically. > > Personally I have patched ocamlopt in order to have a -startup option > keeping camlstartup_.o in the current directory. > > Anyway, maybe there is a better way for your own concern. > Have a glance at -output-obj perhaps. rocaml already uses -output-obj; these are the steps it follows when building an extension: gcc -I. -Ipath/to/lib/ruby/1.8/i686-linux -I. -fPIC -g -O2 -c oo_rocaml_wrapper.c ocamlopt.opt -c oo.ml ocamlopt.opt -c rubyOCamlUtil.ml ocamlopt.opt -output-obj -o oo_rocaml_runtime.o nums.cmxa oo.cmx \ rubyOCamlUtil.cmx oo.o rubyOCamlUtil.o gcc -shared -L'path/to/usr/lib' -Wl,-R'path/to/usr/lib' -o oo.so \ oo_rocaml_wrapper.o oo_rocaml_runtime.o /usr/lib/ocaml/3.09.2/libasmrun.a \ /usr/lib/ocaml/3.09.2/libunix.a /usr/lib/ocaml/3.09.2/libnums.a \ -ldl -lcrypt -lm -lc oo_rocaml_wrapper.c and rubyOCamlUtil.ml are generated by rocaml, the actual OCaml code is in oo.ml. Under which circumstances would something like the above oo.so not be self-contained as far as the OCaml code is concerned? PS: I realize that the above only works as is on x86, Linux + Windows (maybe elsewhere), but will fail on x86_64, whose linker cannot handle non-PIC code. This is described in http://caml.inria.fr/mantis/view.php?id=3924 I believed it was fixed in 3.10 since the changelog indicates: - Intel/AMD 64 bits: generate position-independent code by default. but I've had no success with 3.10 and -fPIC (I have to try again though, I just realized that this could refer only to (2) in the bug report). -- Mauricio Fernandez - http://eigenclass.org