From: Daniel Berger Date: 2007-10-19T05:16:37+09:00 Subject: Re: rocaml 0.6.0: fast, easy Ruby extensions in Objective Caml 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? > > diff -rN -u -w old-rocaml/rocaml_extconf.rb new-rocaml/rocaml_extconf.rb > --- old-rocaml/rocaml_extconf.rb 2007-10-18 21:03:41.000000000 +0200 > +++ new-rocaml/rocaml_extconf.rb 2007-10-18 21:03:41.000000000 +0200 > @@ -89,7 +89,9 @@ > > # needed by mkmf's create_makefile > $LOCAL_LIBS = "#{CAML_TARGET} #{ocaml_native_lib_path}/libasmrun.a #{extra_caml_libs.join(" ")}" > - > +# try to add GCC's libgcc, required on Sparc > +libgcc = Dir["/lib/libgcc*"].first # maybe some other search path(s) > +$LOCAL_LIBS << " " << libgcc if libgcc > > # determine whether camlp4 (or camlp5) can be used: > > You might have to change the search path. On my platform, libgcc can also be > found in /usr/lib/gcc/i486-linux-gnu/. Linking against either > libgcc.a or libgcc_s.so should do. In my particular case it's /opt/csw/gcc4/lib/libgcc which I added directly: djberge-/opt/csw/gcc4/lib-663>ll libg* lrwxrwxrwx 1 root root 15 Dec 12 2006 libgcc_s.so -> ./ libgcc_s.so.1 -rwxr-xr-x 1 root bin 63928 Oct 10 2005 libgcc_s.so.1 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 LDD led me to the fix: djberge-/export/home/djberge/src/ruby/rocaml-0.6.1-546>ldd foo.so libgcc_s.so.1 => (file not found) librt.so.1 => /lib/librt.so.1 libpthread.so.1 => /lib/libpthread.so.1 libdl.so.1 => /lib/libdl.so.1 libcrypt_i.so.1 => /usr/lib/libcrypt_i.so.1 libm.so.2 => /lib/libm.so.2 libc.so.1 => /lib/libc.so.1 libaio.so.1 => /lib/libaio.so.1 libmd5.so.1 => /lib/libmd5.so.1 libgen.so.1 => /lib/libgen.so.1 /platform/SUNW,Sun-Blade-100/lib/libc_psr.so.1 /platform/SUNW,Sun-Blade-100/lib/libmd5_psr.so.1 So, I slapped $LDFLAGS += " -L/opt/csw/gcc4/lib -R/opt/csw/gcc4/lib" into the rocaml_extconf.rb file. Looks better after that: djberge-/export/home/djberge/src/ruby/rocaml-0.6.1-605>ldd foo.so libgcc_s.so.1 => /opt/csw/gcc4/lib/libgcc_s.so.1 librt.so.1 => /lib/librt.so.1 libpthread.so.1 => /lib/libpthread.so.1 libdl.so.1 => /lib/libdl.so.1 libcrypt_i.so.1 => /usr/lib/libcrypt_i.so.1 libm.so.2 => /lib/libm.so.2 libc.so.1 => /lib/libc.so.1 libaio.so.1 => /lib/libaio.so.1 libmd5.so.1 => /lib/libmd5.so.1 libgen.so.1 => /lib/libgen.so.1 /platform/SUNW,Sun-Blade-100/lib/libc_psr.so.1 /platform/SUNW,Sun-Blade-100/lib/libmd5_psr.so.1 Back to irb: irb(main):002:0> require 'foo' NameError: (eval): uninitialized constant Kernel::Some from (eval) from /usr/local/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:in `require' from (irb):2 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? Thanks, Dan