Closed banister closed 9 years ago
+1
@mpapis can you elaborate? For the most part, we're just deferring to mkmf
. I'm not aware of where we should be using the CC
variable.
https://github.com/cowboyd/therubyracer/blob/master/ext/v8/extconf.rb
That said, on my fresh mavericks install:
~/C/therubyracer git:master ❯❯❯ ruby -v ⏎
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin13.0.2]
~/C/therubyracer git:master ❯❯❯ rake compile
mkdir -p tmp/x86_64-darwin13.0.2/init/1.9.3
cd tmp/x86_64-darwin13.0.2/init/1.9.3
/Users/cowboyd/.rbenv/versions/1.9.3-p448/bin/ruby -I. ../../../../ext/v8/extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
creating Makefile
cd -
cd tmp/x86_64-darwin13.0.2/init/1.9.3
make
compiling ../../../../ext/v8/accessor.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/array.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/backref.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/constants.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/constraints.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/context.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/date.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/exception.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/external.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/function.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/gc.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/handles.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/heap.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/init.cc
clang: warning: argument unused during compilation: '-rdynamic'
../../../../ext/v8/init.cc:11:20: warning: empty parentheses interpreted as a function declaration
[-Wvexing-parse]
v8::Locker lock();
^~
../../../../ext/v8/init.cc:11:20: note: remove parentheses to declare a variable
v8::Locker lock();
^~
../../../../ext/v8/init.cc:11:16: warning: 'lock' has C-linkage specified, but returns user-defined
type 'v8::Locker' which is incompatible with C [-Wreturn-type-c-linkage]
v8::Locker lock();
^
2 warnings generated.
compiling ../../../../ext/v8/invocation.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/locker.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/message.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/object.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/primitive.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/rr.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/script.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/signature.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/stack.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/string.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/template.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/trycatch.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/v8.cc
clang: warning: argument unused during compilation: '-rdynamic'
compiling ../../../../ext/v8/value.cc
clang: warning: argument unused during compilation: '-rdynamic'
linking shared-object v8/init.bundle
cd -
install -c tmp/x86_64-darwin13.0.2/init/1.9.3/init.bundle lib/v8/init.bundle
cp tmp/x86_64-darwin13.0.2/init/1.9.3/init.bundle tmp/x86_64-darwin13.0.2/stage/lib/v8/init.bundle
~/C/therubyracer git:master ❯❯❯ rake spec
/Users/cowboyd/.rbenv/versions/1.9.3-p448/bin/ruby -S rspec ./spec/c/array_spec.rb ./spec/c/constants_spec.rb ./spec/c/exception_spec.rb ./spec/c/external_spec.rb ./spec/c/function_spec.rb ./spec/c/handles_spec.rb ./spec/c/locker_spec.rb ./spec/c/object_spec.rb ./spec/c/script_spec.rb ./spec/c/string_spec.rb ./spec/c/template_spec.rb ./spec/c/trycatch_spec.rb ./spec/mem/blunt_spec.rb ./spec/redjs_spec.rb ./spec/threading_spec.rb ./spec/v8/context_spec.rb ./spec/v8/conversion_spec.rb ./spec/v8/error_spec.rb ./spec/v8/function_spec.rb ./spec/v8/object_spec.rb --tag ~memory --tag ~threads
Run options: exclude {:memory=>true, :threads=>true}
..............................*......................
Pending:
V8::Context not ready for prime-time
# No reason given
# ./spec/redjs_spec.rb:8
Finished in 0.03456 seconds
53 examples, 0 failures, 1 pending
@cowboyd this happens on older patchlevels then p448, they were not possible to build with clang
and gcc-4.x
was used for them, unfortunately therubyracer
did not use the CC
ruby and instead tried to compile with clang
anyway ruby 1.9.3 any patchlevel even if you were able to compile it with clang
can still have runtime issues and you would be safer recompiling it with gnu gcc
@banister can you run this one:
rvm config-get --all | grep -E 'CPP|CXX|CC|gcc|clang'
@mpapis
$ rvm config-get --all | grep -E 'CPP|CXX|CC|gcc|clang'
CC: /usr/local/opt/apple-gcc42/bin/gcc-4.2
CCDLFLAGS: -fno-common
CPP: /usr/local/opt/apple-gcc42/bin/gcc-4.2 -E
CPPFLAGS: -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
CPPOUTFILE: -o conftest.i
CXX: g++
CXXFLAGS: -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration
GCC: yes
LDSHARED: /usr/local/opt/apple-gcc42/bin/gcc-4.2 -dynamic -bundle
LIBRUBY_LDSHARED: /usr/local/opt/apple-gcc42/bin/gcc-4.2 -dynamiclib
configure_args: '--prefix=/Users/johnmair/.rvm/rubies/ruby-1.9.3-p194' '--with-opt-dir=/usr/local/opt/libyaml' '--without-tcl' '--without-tk' '--enable-shared' 'CC=/usr/local/opt/apple-gcc42/bin/gcc-4.2' 'CFLAGS=-O3 -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include' 'LDFLAGS=-L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib'
it looks like the problem could be https://github.com/cowboyd/therubyracer/blob/master/ext/v8/extconf.rb#L10
same on ruby-1.9.3-p448
rvm config-get --all | grep -E 'CPP|CXX|CC|gcc|clang'
CC: /usr/local/bin/gcc-4.2
CCDLFLAGS: -fno-common
CPP: /usr/local/bin/gcc-4.2 -E
CPPFLAGS: -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include
CPPOUTFILE: -o conftest.i
CXX: g++
CXXFLAGS: -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration
GCC: yes
LDSHARED: /usr/local/bin/gcc-4.2 -dynamic -bundle
LIBRUBY_LDSHARED: /usr/local/bin/gcc-4.2 -dynamiclib
configure_args: '--prefix=/Users/alecslupu/.rvm/rubies/ruby-1.9.3-p448' '--with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libksba:/usr/local/opt/openssl' '--without-tcl' '--without-tk' '--enable-shared' 'CC=/usr/local/bin/gcc-4.2'
I got it fixed by a dumb solution:
brew install v8
bundle install
# after failing go to
cd /Users/alecslupu/.rvm/gems/ruby-1.9.3-p448@my_gemset/gems/libv8-3.3.10.4/lib/libv8/build/v8
ln -s /usr/local/Cellar/v8/3.21.17/lib/libv8_base.x64.a ./libv8.a
bundle update
Aparently the problem is in libv8 (3.3.10.4) gem that is not building on a mavericks system, for that reason the "libv8.a" is never created.
@mpapis hmmm... That line should never get used on OSX systems since it does an explicit check for /darwin/
in the RUBY_PLATFORM
I do not have right now access to an OSX system, would need to see resulting Makefile
and check some code to tell you more, something makes it use clang
instead of gcc-4.2
which was set in CC
I tried a few of the above solutions, but still no fix. Any progress on a more permanent patch?
Edit: At work we've remove this gem from our current workflow temporarily since multiple people seem to be having the same issue.
@ashblue have you tried the "fix" i have proposed?
Yes, "bundle install" would run correctly. But "rails s" would crash saying that therubyracer was not installed.
Newer versions of libv8 build on mavericks. Is it possible to update libv8?
@michaelharro, could you me more specific? Which versions exactly?
@ignisf sure. We have a project that uses libv8. We were using gem 'libv8', '=3.11.8.17' and couldn't build on mavericks. I saw this http://stackoverflow.com/a/19586282 so I did some trial and error. I couldn't get any of the 3.11 versions to build on mavericks but all the 3.16 versions I tried worked just fine. So somewhere between 3.11.8.17 and 3.16 it was fixed.
I was the having the same issue with 0.10.1 and 0.10.2 on OSX Mavericks. @alecslupu's fix worked for me, but rails s, as well as rake db:create and several other commands would fail with uninitialized constant V8::JSError
@valachi I am running Rails 3.2.12 And i don't have any issues ... and therubyracer (0.10.2)
@valachi, yes, there are a bunch of fixes in the 3.16 tree. I have released a binary version for Mavericks of libv8 3.11.8.17 so you should be able to use it without the need to compile. We will probably release a new version in the 3.11 branch once the new changes in the 3.16 branch prove to be stable.
I'm also seeing a segfault when trying to require rubyracer/libv8 on mavericks. Managed to install them fine.
I tried the symlink solution, as well as upgrading to newer versions of both libv8
and therubyracer
, and wasn't having any success. However, I found another solution in http://stackoverflow.com/a/20145328/275058 and it seems to work great for me!
@mjjohnson did you try the latest version in the libv8 master branch? The patches necessary for compilation with clang and GCC 4.2 are in and need to be tested before we release.
@ignisf I hadn't tried that yet. :) I'm just getting an existing project running on my local box, and so for me it's better to be able to use the version they already had. But I can temporarily try from the master branch if you like.
The solution shared by @mjjohnson worked perfect for me too. Thanks.
+1
The solution suggested by @mjjohnson worked for me as well.
Nice work @mjjohnson :+1:
I talked to @mpapis (from #rvm channel on freenode) and he stated it was due to therubyracer not using the
CC
variable from Ruby: