rubyjs / therubyracer

Embed the V8 Javascript Interpreter into Ruby
1.66k stars 193 forks source link

Undefined Symbol when using --with-system-v8 #254

Closed clark800 closed 9 years ago

clark800 commented 11 years ago

I'm trying to install Gitlab on an ARM5 system running Arch Linux ARM. The libv8 gem build fails with the default settings, so I built V8 version 3.11.8 from source and copied it to the system location at /usr/lib/libv8.so. I also copied the executable to /usr/bin/d8, and the headers to /usr/include. Then I built libv8 using

gem install libv8 -v '3.11.8.17' --user-install -- --with-system-v8

and manually copied it into the bundle (the bundle install of the libv8 gem fails with a "NoMethodError: undefined method `size' for nil:NilClass" even with the "bundle config build.libv8 --with-system-v8" option). Then the bundle install succeeded. But when I try to do a bundle exec, therubyracer fails due to a missing symbol. The symbol is in the system's libv8.so, so it seems that libv8.so is not being loaded. Here is an excerpt from my console.

Using libv8 (3.11.8.17)
...
Installing therubyracer (0.11.4) 
Installing uglifier (1.3.0) 
Your bundle is complete!
Gems in the groups development, test and mysql were not installed.
It was installed into ./vendor/bundle
$ bundle exec rake db:setup RAILS_ENV=production
ruby: symbol lookup error: /home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/therubyracer-0.11.4/lib/v8/init.so: undefined symbol: _ZN2v82V821AddGCPrologueCallbackEPFvNS_6GCTypeENS_15GCCallbackFlagsEES1_
$ nm /usr/lib/libv8.so | grep AddGCPrologue
000404e4 T _ZN2v82V821AddGCPrologueCallbackEPFvNS_6GCTypeENS_15GCCallbackFlagsEES1_

And from "gem env":

  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [armv5tel-linux-eabi]

The bundler version is 1.3.5.

ignisf commented 11 years ago

This looks like an issue with the libv8 gem. We're collecting feedback in https://github.com/cowboyd/libv8/issues/98.

mamash commented 10 years ago

I've just hit the same problem on SunOS/SmartOS with a system V8. The following patch fixes it for me.

--- ext/v8/extconf.rb.orig  2014-01-23 11:49:29.626635920 +0000
+++ ext/v8/extconf.rb
@@ -2,6 +2,7 @@ require 'mkmf'

 have_library('pthread')
 have_library('objc') if RUBY_PLATFORM =~ /darwin/
+have_library('v8')
 $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
 $CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
 $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"

Let me know if you don't feel it's the same issue, but I just don't see how therubyracer would ever work with a system shared libv8.so otherwise. Might need some conditioning for cases where v8 is not provided by the system, and you'd know better; for my purposes (pkgsrc/SmartOS) though no other scenario applies.

cowboyd commented 9 years ago

This should have been resolved with 3.14.16.x