* undefined symbol `caml_tuplify2' in dynamic rocaml extension @ 2007-08-01 4:01 Jos Backus 2007-08-01 7:44 ` [Caml-list] " Julien Moutinho 2007-08-01 9:16 ` Mauricio Fernandez 0 siblings, 2 replies; 13+ messages in thread From: Jos Backus @ 2007-08-01 4:01 UTC (permalink / raw) To: caml-list 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. Thanks, -- Jos Backus jos at catnook.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension 2007-08-01 4:01 undefined symbol `caml_tuplify2' in dynamic rocaml extension Jos Backus @ 2007-08-01 7:44 ` Julien Moutinho 2007-08-01 9:43 ` Mauricio Fernandez 2007-08-01 13:59 ` Gordon Henriksen 2007-08-01 9:16 ` Mauricio Fernandez 1 sibling, 2 replies; 13+ messages in thread From: Julien Moutinho @ 2007-08-01 7:44 UTC (permalink / raw) To: Jos Backus; +Cc: caml-list 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_<name_of_the_output>.o in the current directory. Anyway, maybe there is a better way for your own concern. Have a glance at -output-obj perhaps. HTH. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension 2007-08-01 7:44 ` [Caml-list] " Julien Moutinho @ 2007-08-01 9:43 ` Mauricio Fernandez 2007-08-01 13:59 ` Gordon Henriksen 1 sibling, 0 replies; 13+ messages in thread From: Mauricio Fernandez @ 2007-08-01 9:43 UTC (permalink / raw) To: caml-list 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_<name_of_the_output>.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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension 2007-08-01 7:44 ` [Caml-list] " Julien Moutinho 2007-08-01 9:43 ` Mauricio Fernandez @ 2007-08-01 13:59 ` Gordon Henriksen 1 sibling, 0 replies; 13+ messages in thread From: Gordon Henriksen @ 2007-08-01 13:59 UTC (permalink / raw) To: Julien Moutinho; +Cc: Jos Backus, caml-list On Aug 1, 2007, at 03:44, 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_<name_of_the_output>.o in the current > directory. > > Anyway, maybe there is a better way for your own concern. Have a > glance at -output-obj perhaps. > > HTH. I wonder if there's a reason ocamlopt doesn't simply emit these glue functions alongside their uses as linkonce symbols. This is the same technique that a C++ compiler uses for template instantiations to avoid problems of this nature. — Gordon ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension 2007-08-01 4:01 undefined symbol `caml_tuplify2' in dynamic rocaml extension Jos Backus 2007-08-01 7:44 ` [Caml-list] " Julien Moutinho @ 2007-08-01 9:16 ` Mauricio Fernandez 2007-08-01 16:17 ` Jos Backus 1 sibling, 1 reply; 13+ messages in thread From: Mauricio Fernandez @ 2007-08-01 9:16 UTC (permalink / raw) To: jos, caml-list 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. Do the examples included in rocaml work for you? In particular "oo", where an abstract type is used from Ruby, and "simple", which passes tuples to a function returning a tuple. If you could pinpoint the conversion that's triggering the problem (and it's indeed a problem caused by a Ruby <-> OCaml conversion) we'd be one step away from fixing it. Have you tried to disassemble the extension and see where caml_tuplify2 is being called? -- Mauricio Fernandez - http://eigenclass.org ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension 2007-08-01 9:16 ` Mauricio Fernandez @ 2007-08-01 16:17 ` Jos Backus 2007-08-01 17:59 ` Jos Backus 0 siblings, 1 reply; 13+ messages in thread From: Jos Backus @ 2007-08-01 16:17 UTC (permalink / raw) To: caml-list On Wed, Aug 01, 2007 at 11:16:47AM +0200, Mauricio Fernandez 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. > > Do the examples included in rocaml work for you? In particular "oo", where an > abstract type is used from Ruby, and "simple", which passes tuples to a > function returning a tuple. Yes; all the examples work fine. The case that is failing is where I try to call functions in a .a created with ocamlopt (it's an internal library written in Ocaml). I had to modify the Makefile to add the .a to LOCAL_LIBS and surround it with -Wl,--whole-archive .a -Wl,--no-whole-archive. Without this option the resulting .so built by rocaml would not have the Ruby-visible symbols (`KPP.make' in this case) and the extension would fail with caml_named_value() returning NULL because the named value would not be present. > If you could pinpoint the conversion that's triggering the problem (and it's > indeed a problem caused by a Ruby <-> OCaml conversion) we'd be one step > away from fixing it. Have you tried to disassemble the extension and see > where caml_tuplify2 is being called? I'll have a look. I do see references to caml_tuplify2 in other .a's as well. Thanks for rocaml! -- Jos Backus jos at catnook.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension 2007-08-01 16:17 ` Jos Backus @ 2007-08-01 17:59 ` Jos Backus 2007-08-01 23:24 ` [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) Jos Backus 2007-08-01 23:34 ` rocaml bug + fix Jos Backus 0 siblings, 2 replies; 13+ messages in thread From: Jos Backus @ 2007-08-01 17:59 UTC (permalink / raw) To: caml-list On Wed, Aug 01, 2007 at 09:17:02AM -0700, Jos Backus wrote: > On Wed, Aug 01, 2007 at 11:16:47AM +0200, Mauricio Fernandez wrote: [snip] > > If you could pinpoint the conversion that's triggering the problem (and it's > > indeed a problem caused by a Ruby <-> OCaml conversion) we'd be one step > > away from fixing it. Have you tried to disassemble the extension and see > > where caml_tuplify2 is being called? > > I'll have a look. I do see references to caml_tuplify2 in other .a's as well. It turns out my extension doesn't call it but one of the required libraries does. Here's what I am doing: Exerpt from extconf.rb: # extension name, XXX in require 'XXX' EXT_NAME = "kpp" Interface.generate("kpp") do def_class("KPP") do |c| t = c.abstract_type fun "make", STRING => t method "eval", [t, STRING] => LIST(STRING) end end $ ruby extconf.rb $ make [lots of errors because of unfound header files] $ vi Makefile [Add `-I/usr/lib/ocaml' to INCFLAGS] $ make kpp_rocaml_wrapper.c:39: error: missing terminating " character $ vi kpp_rocaml_wrapper.c [Change line 39: static VALUE String_list_caml_to_ruby(value v);" to static VALUE String_list_caml_to_ruby(value v); ] $ make gcc -I. -I/usr/lib/ruby/1.8/i386-linux -I/usr/lib/ruby/1.8/i386-linux -I. -I/usr/lib/ocaml -fPIC -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -Wall -fPIC -c kpp_rocaml_wrapper.c kpp_rocaml_wrapper.c: In function `string_ruby_to_caml_safe': kpp_rocaml_wrapper.c:133: warning: implicit declaration of function `caml_alloc_string' kpp_rocaml_wrapper.c: At top level: kpp_rocaml_wrapper.c:45: warning: 'do_raise_exception' defined but not used kpp_rocaml_wrapper.c:59: warning: 'do_raise_exception_tag' defined but not used ocamlopt.opt -c rubyOCamlUtil.ml ocamlopt.opt -output-obj -o kpp_rocaml_runtime.o nums.cmxa rubyOCamlUtil.cmx rubyOCamlUtil.o gcc -shared -L"/usr/lib" -o kpp.so kpp_rocaml_wrapper.o kpp_rocaml_runtime.o /usr/lib/ocaml/libasmrun.a /usr/lib/ocaml/libunix.a /usr/lib/ocaml/libnums.a -lruby -lpthread -ldl -lcrypt -lm -lc $ cat test_kpp.rb require 'kpp' kpp = KPP.make "" p kpp.eval("") $ ruby test_kpp.rb test_kpp.rb:3:in `make': Couldn't find OCaml value 'KPP.make'. (StandardError) from test_kpp.rb:3 $ vi Makefile [Add `-Wl,--whole-archive ../kpp/kpp.a -Wl,--no-whole-archive' to LOCAL_LIBS] $ make clean all $ ruby test_kpp.rb ./kpp.so: ./kpp.so: undefined symbol: camlStr__parse_368 - ./kpp.so (LoadError) from test_kpp.rb:1 $ vi Makefile [Add `/usr/lib/ocaml/str.a' to LOCAL_LIBS] $ make clean all $ ruby test_kpp.rb ./kpp.so: ./kpp.so: undefined symbol: camlCamlinternalOO__create_object_opt_357 - ./kpp.so (LoadError) from test_kpp.rb:1 $ vi Makefile [Add `/usr/lib/ocaml/stdlib.a' to LOCAL_LIBS] $ make clean all $ ruby test_kpp.rb ./kpp.so: ./kpp.so: undefined symbol: caml_hash_univ_param - ./kpp.so (LoadError) from test_kpp.rb:1 $ vi Makefile [Add `/usr/lib/ocaml/libasmrun.a' (again) to LOCAL_LIBS] $ make clean all $ ruby test_kpp.rb ./kpp.so: ./kpp.so: undefined symbol: caml_tuplify2 - ./kpp.so (LoadError) from test_kpp.rb:1 $ At this point, LOCAL_LIBS looks like this: LOCAL_LIBS = kpp_rocaml_runtime.o /usr/lib/ocaml/libasmrun.a \ /usr/lib/ocaml/libunix.a /usr/lib/ocaml/libnums.a -Wl,--whole-archive \ ../kpp/kpp.a -Wl,--no-whole-archive /usr/lib/ocaml/str.a \ /usr/lib/ocaml/stdlib.a /usr/lib/ocaml/libasmrun.a This is where I'm stuck. -- Jos Backus jos at catnook.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) 2007-08-01 17:59 ` Jos Backus @ 2007-08-01 23:24 ` Jos Backus 2007-08-02 9:20 ` Mauricio Fernandez 2007-08-01 23:34 ` rocaml bug + fix Jos Backus 1 sibling, 1 reply; 13+ messages in thread From: Jos Backus @ 2007-08-01 23:24 UTC (permalink / raw) To: caml-list On Wed, Aug 01, 2007 at 10:59:07AM -0700, Jos Backus wrote: > On Wed, Aug 01, 2007 at 09:17:02AM -0700, Jos Backus wrote: > > On Wed, Aug 01, 2007 at 11:16:47AM +0200, Mauricio Fernandez wrote: > [snip] > > > If you could pinpoint the conversion that's triggering the problem (and it's > > > indeed a problem caused by a Ruby <-> OCaml conversion) we'd be one step > > > away from fixing it. Have you tried to disassemble the extension and see > > > where caml_tuplify2 is being called? > > > > I'll have a look. I do see references to caml_tuplify2 in other .a's as well. > > It turns out my extension doesn't call it but one of the required libraries > does. > > Here's what I am doing: [snip] Some good news. We got this to work by creating a kpp.ml file (containing the Callback.register calls) in the extension directory, and adding some values to CAML_LIBS, CAML_OBJS and CAML_INCLUDES. Yay! It looks like we are really close. The next (final?) issue is that we have a function with signature val eval : kpp -> string -> value list -> value list where type value = | Vstr of string | Vtup of value list which we want to export to Ruby. We tried: Interface.generate(EXT_NAME) do value = sym_variant("value") do |t| non_constant :Vstr, STRING non_constant :Vtup, LIST(t) end def_class("KPP") do |c| t = c.abstract_type fun "make", STRING => t method "eval", [t, STRING, value] => LIST(STRING) end end but it doesn't work (it segfaults inside the extension). How does one represent `value' on the Ruby side? Btw, besides having to remove the stray `"' we also found that we had to patch the kpp_rocaml_wrapper.c to make it compile, basically doing a `%s/t_value /t_value_/g' in this case. Hope this feedback is useful. Thanks! -- Jos Backus jos at catnook.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) 2007-08-01 23:24 ` [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) Jos Backus @ 2007-08-02 9:20 ` Mauricio Fernandez 2007-08-02 9:58 ` Mauricio Fernandez 2007-08-02 18:58 ` Jos Backus 0 siblings, 2 replies; 13+ messages in thread From: Mauricio Fernandez @ 2007-08-02 9:20 UTC (permalink / raw) To: jos, caml-list On Wed, Aug 01, 2007 at 04:24:05PM -0700, Jos Backus wrote: > On Wed, Aug 01, 2007 at 10:59:07AM -0700, Jos Backus wrote: > > On Wed, Aug 01, 2007 at 09:17:02AM -0700, Jos Backus wrote: > > > On Wed, Aug 01, 2007 at 11:16:47AM +0200, Mauricio Fernandez wrote: > > [snip] > > > > If you could pinpoint the conversion that's triggering the problem (and it's > > > > indeed a problem caused by a Ruby <-> OCaml conversion) we'd be one step > > > > away from fixing it. Have you tried to disassemble the extension and see > > > > where caml_tuplify2 is being called? > > > > > > I'll have a look. I do see references to caml_tuplify2 in other .a's as well. > > > > It turns out my extension doesn't call it but one of the required libraries > > does. > > > > Here's what I am doing: > [snip] > > Some good news. We got this to work by creating a kpp.ml file (containing the > Callback.register calls) in the extension directory, and adding some values to > CAML_LIBS, CAML_OBJS and CAML_INCLUDES. Yay! Yes, I wrote a very long message telling you exactly this (that you needed to use CAML_LIBS so that -output-obj could work correctly) late at night but forgot to send it :) > It looks like we are really close. The next (final?) issue is that we have a > function with signature > > val eval : kpp -> string -> value list -> value list > > where > > type value = > | Vstr of string > | Vtup of value list > > which we want to export to Ruby. We tried: > > Interface.generate(EXT_NAME) do > value = sym_variant("value") do |t| > non_constant :Vstr, STRING > non_constant :Vtup, LIST(t) > end [...] > but it doesn't work (it segfaults inside the extension). > > How does one represent `value' on the Ruby side? I think you have to wrap the LIST(t) in a TUPLE(): value = sym_variant("value") do |t| non_constant :Vstr, STRING non_constant :Vtup, TUPLE(LIST(t)) end I'll try to either auto-detect this or perform a compile-time check. > Btw, besides having to remove the stray `"' we also found that we had to patch > the kpp_rocaml_wrapper.c to make it compile, basically doing a `%s/t_value > /t_value_/g' in this case. Chris Waterson has kindly sent me a patch fixing the problems you saw; I've just pushed it to the online repository, along with an example of the above TUPLE(LIST(t)) in examples/variants. I'll work on the INCFLAGS issue so there's no need to hand-edit the generated Makefile/wrappers. -- Mauricio Fernandez - http://eigenclass.org ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) 2007-08-02 9:20 ` Mauricio Fernandez @ 2007-08-02 9:58 ` Mauricio Fernandez 2007-08-02 18:54 ` Jos Backus 2007-08-02 18:58 ` Jos Backus 1 sibling, 1 reply; 13+ messages in thread From: Mauricio Fernandez @ 2007-08-02 9:58 UTC (permalink / raw) To: jos, caml-list On Thu, Aug 02, 2007 at 11:20:50AM +0200, Mauricio Fernandez wrote: > > It looks like we are really close. The next (final?) issue is that we have a > > function with signature > > > > val eval : kpp -> string -> value list -> value list > > > > where > > > > type value = > > | Vstr of string > > | Vtup of value list > > > > which we want to export to Ruby. We tried: > > > > Interface.generate(EXT_NAME) do > > value = sym_variant("value") do |t| > > non_constant :Vstr, STRING > > non_constant :Vtup, LIST(t) > > end > [...] > > but it doesn't work (it segfaults inside the extension). > > > > How does one represent `value' on the Ruby side? > > I think you have to wrap the LIST(t) in a TUPLE(): > > value = sym_variant("value") do |t| > non_constant :Vstr, STRING > non_constant :Vtup, TUPLE(LIST(t)) > end > > I'll try to either auto-detect this or perform a compile-time check. Ignore that; I forgot that rocaml already detects when such extra boxing is needed and performs it automatically, so non_constant :Vtup, LIST(foo) should work already. It can't be due to the type being recursive either because that works fine in the tree example. Just to make sure, are you calling eval as in kpp.eval(str, [[[ :Vtup, [ [[:Vstr, "foo"]] ] ]]]) The outer pair of [ ] because it's a block, the next one because it holds a LIST, then the block represented as [symbol, value] where value is a block holding a list of [symbol, value] blocks. If you've got the wrong number of [ ], maybe the generated extension isn't detecting it, and hence the crash. Yes, it's hard to get the above right, so I'll see if something can be done from Ruby to make it easier. -- Mauricio Fernandez - http://eigenclass.org ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) 2007-08-02 9:58 ` Mauricio Fernandez @ 2007-08-02 18:54 ` Jos Backus 0 siblings, 0 replies; 13+ messages in thread From: Jos Backus @ 2007-08-02 18:54 UTC (permalink / raw) To: caml-list On Thu, Aug 02, 2007 at 11:58:57AM +0200, Mauricio Fernandez wrote: > On Thu, Aug 02, 2007 at 11:20:50AM +0200, Mauricio Fernandez wrote: > > > It looks like we are really close. The next (final?) issue is that we have a > > > function with signature > > > > > > val eval : kpp -> string -> value list -> value list > > > > > > where > > > > > > type value = > > > | Vstr of string > > > | Vtup of value list > > > > > > which we want to export to Ruby. We tried: > > > > > > Interface.generate(EXT_NAME) do > > > value = sym_variant("value") do |t| > > > non_constant :Vstr, STRING > > > non_constant :Vtup, LIST(t) > > > end > > [...] > > > but it doesn't work (it segfaults inside the extension). > > > > > > How does one represent `value' on the Ruby side? > > > > I think you have to wrap the LIST(t) in a TUPLE(): > > > > value = sym_variant("value") do |t| > > non_constant :Vstr, STRING > > non_constant :Vtup, TUPLE(LIST(t)) > > end > > > > I'll try to either auto-detect this or perform a compile-time check. > > Ignore that; I forgot that rocaml already detects when such extra boxing is > needed and performs it automatically, so non_constant :Vtup, LIST(foo) > should work already. It can't be due to the type being recursive either > because that works fine in the tree example. Thanks. We ended up doing Interface.generate(EXT_NAME) do kpp_value_t = sym_variant("kpp_value_t") do |t| non_constant :Vstr, STRING non_constant :Vtup, LIST(t) end def_class("KPP") do |c| t = c.abstract_type ctxt = LIST(kpp_value_t) fun "make", STRING => t method "eval", [t, STRING, ctxt] => ctxt ... end end so we can say kpp.eval("", [[:Vstr, "woot!"]]) > Just to make sure, are you calling eval as in > > kpp.eval(str, [[[ :Vtup, [ [[:Vstr, "foo"]] ] ]]]) > > The outer pair of [ ] because it's a block, the next one because it holds a > LIST, then the block represented as [symbol, value] where value is a block > holding a list of [symbol, value] blocks. > > If you've got the wrong number of [ ], maybe the generated extension isn't > detecting it, and hence the crash. > > Yes, it's hard to get the above right, so I'll see if something can be done > from Ruby to make it easier. That would be nice. Thanks for the explanation Mauricio. And thanks to everybody responding on this thread - it looks like we are all set now. -- Jos Backus jos at catnook.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) 2007-08-02 9:20 ` Mauricio Fernandez 2007-08-02 9:58 ` Mauricio Fernandez @ 2007-08-02 18:58 ` Jos Backus 1 sibling, 0 replies; 13+ messages in thread From: Jos Backus @ 2007-08-02 18:58 UTC (permalink / raw) To: caml-list On Thu, Aug 02, 2007 at 11:20:50AM +0200, Mauricio Fernandez wrote: > On Wed, Aug 01, 2007 at 04:24:05PM -0700, Jos Backus wrote: > > On Wed, Aug 01, 2007 at 10:59:07AM -0700, Jos Backus wrote: [snip] > > Some good news. We got this to work by creating a kpp.ml file (containing the > > Callback.register calls) in the extension directory, and adding some values to > > CAML_LIBS, CAML_OBJS and CAML_INCLUDES. Yay! > > Yes, I wrote a very long message telling you exactly this (that you needed to > use CAML_LIBS so that -output-obj could work correctly) late at night but > forgot to send it :) Heh. All's well that ends well. > > Btw, besides having to remove the stray `"' we also found that we had to patch > > the kpp_rocaml_wrapper.c to make it compile, basically doing a `%s/t_value > > /t_value_/g' in this case. > > Chris Waterson has kindly sent me a patch fixing the problems you saw; I've > just pushed it to the online repository, along with an example of the above > TUPLE(LIST(t)) in examples/variants. Yeah, I dragged Chris into working on this yesterday (thanks Chris!) and he beat me to the patch :) > I'll work on the INCFLAGS issue so there's no need to hand-edit the > generated Makefile/wrappers. That would be nice. While you're at it, can you add LOCAL_LIBS, too? Those were the only variables we needed to change in the Makefile. > -- Mauricio Fernandez - http://eigenclass.org Thanks again Mauricio. -- Jos Backus jos at catnook.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* rocaml bug + fix 2007-08-01 17:59 ` Jos Backus 2007-08-01 23:24 ` [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) Jos Backus @ 2007-08-01 23:34 ` Jos Backus 1 sibling, 0 replies; 13+ messages in thread From: Jos Backus @ 2007-08-01 23:34 UTC (permalink / raw) To: caml-list On Wed, Aug 01, 2007 at 10:59:07AM -0700, Jos Backus wrote: [snip] > $ make > kpp_rocaml_wrapper.c:39: error: missing terminating " character > $ vi kpp_rocaml_wrapper.c > [Change line 39: > > static VALUE String_list_caml_to_ruby(value v);" > > to > > static VALUE String_list_caml_to_ruby(value v); > ] --- rocaml.rb.orig 2007-08-01 19:30:01.000000000 -0400 +++ rocaml.rb 2007-08-01 19:30:33.000000000 -0400 @@ -512,7 +512,7 @@ def caml_to_ruby_prototype <<-EOF -static VALUE #{@typename}_list_caml_to_ruby(value v);" +static VALUE #{@typename}_list_caml_to_ruby(value v); EOF end -- Jos Backus jos at catnook.com ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-08-02 18:58 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-08-01 4:01 undefined symbol `caml_tuplify2' in dynamic rocaml extension Jos Backus 2007-08-01 7:44 ` [Caml-list] " Julien Moutinho 2007-08-01 9:43 ` Mauricio Fernandez 2007-08-01 13:59 ` Gordon Henriksen 2007-08-01 9:16 ` Mauricio Fernandez 2007-08-01 16:17 ` Jos Backus 2007-08-01 17:59 ` Jos Backus 2007-08-01 23:24 ` [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) Jos Backus 2007-08-02 9:20 ` Mauricio Fernandez 2007-08-02 9:58 ` Mauricio Fernandez 2007-08-02 18:54 ` Jos Backus 2007-08-02 18:58 ` Jos Backus 2007-08-01 23:34 ` rocaml bug + fix Jos Backus
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox