From: Mauricio Fernandez Date: 2007-10-19T06:36:32+09:00 Subject: Re: rocaml 0.6.0: fast, easy Ruby extensions in Objective Caml On Fri, Oct 19, 2007 at 05:16:37AM +0900, Daniel Berger wrote: > On Oct 18, 1:18 pm, Mauricio Fernandez wrote: > > > > It seems we're almost there (we went through the critical non-PIC code > > relocation phase :-) > > > > According to google, __muldi3 is an internal GCC library function. Do you have > > a native linker in addition to GCC's? GCC's will automatically link against > > libgcc, but it seems that's not the case with the native one. > > Did I mention that I built Ruby with Sun Studio 12, but OCaml with gcc > 4? Ocaml seemed to demand it. :| > > > At any rate, linking against either libgcc.a or libgcc_s.so.1 should work; > > something like this maybe? [...] > It builds correctly. But then I get a different linker error: > > LoadError: ld.so.1: ruby: fatal: libgcc_s.so.1: open failed: No such > file or directory - /export/home/djberge/src/ruby/rocaml-0.6.1/foo.so > from /export/home/djberge/src/ruby/rocaml-0.6.1/foo.so > from /usr/local/lib/ruby/site_ruby/1.8/rubygems/ > custom_require.rb:27:in `require' > from (irb):2 [...] > So, I slapped $LDFLAGS += " -L/opt/csw/gcc4/lib -R/opt/csw/gcc4/lib" > into the rocaml_extconf.rb file. Looks better after that: [...] > Back to irb: > > irb(main):002:0> require 'foo' > NameError: (eval): uninitialized constant Kernel::Some [...] > Hu...what? WTF? Never seen that one before. I dug through /usr/local/ > lib/ruby to make sure there wasn't some other "foo" it was picking up > - there isn't. > > Any ideas? Congrats, it seems you got it to work :) This is what you missed in a previous message: Note that the extension you're building ("foo") isn't complete. It includes the wrappers but not the OCaml implementations of the corresponding functions; in fact, it is only meant to serve as the extconf.rb template for new extensions. You can find the actual examples under examples/: * marshal: 3-line specialized marshallers that can be over 3 times faster than Ruby's Marshal (the largest speedup is achieved with float arrays) * tree: a 30-line RB tree with 3X faster lookup than RBTree (you'll need rbtree if you want to run the benchmarks in test_tree.rb) * oo, records, variants: show how abstract types, records and variants are converted between Ruby and OCaml. Abstract types become objects, records turn into hashes with symbol keys and variants are mapped to symbols or arrays. BTW, is the /opt/csw/gcc4/lib (de facto) "standard" in any way? I'd like to have as much as possible work out of the box (trying to detect common cases) and offer a convenient way to specify the things that cannot be inferred. Could you give me the output of $ ruby -v -rrbconfig -rpp -e "pp Config::CONFIG" ? Thanks, -- Mauricio Fernandez - http://eigenclass.org