rubyjs/libv8

libv8 fails to compile with OS X 10.11.4/Xcode 7.3/clang 7.3.0

RISCfuture opened this issue ยท 20 comments

Installing libv8 3.16.14.13 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/ext/libv8
/Users/tmorgan/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160321-41246-m0y5mf.rb extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.10
Using compiler: /usr/bin/c++ (clang version 7.3.0)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o has no symbols
In file included from ../src/accessors.cc:28:
In file included from ../src/v8.h:60:
In file included from ../src/objects-inl.h:38:
In file included from ../src/elements.h:32:
../src/objects.h:5252:44: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
  static const int kElementsKindMask = (-1 << kElementsKindShift) &
                                        ~~ ^
../src/objects.h:7386:36: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
      (~kMaxCachedArrayIndexLength << kArrayIndexHashLengthShift) |
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
2 errors generated.
make[1]: *** [/Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o] Error 1
make: *** [x64.release] Error 2
/Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    from /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/ext/libv8/location.rb:35:in `each'
    from /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'
GYP_GENERATORS=make \
    build/gyp/gyp --generator-output="out" build/all.gyp \
                  -Ibuild/standalone.gypi --depth=. \
                  -Dv8_target_arch=x64 \
                  -S.x64  -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror=''
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/conversions.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/diy-fp.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/dtoa.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fast-dtoa.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fixed-dtoa.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/once.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparse-data.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser-api.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/scanner.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/strtod.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/token.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/unicode.o
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser_lib/src/utils.o
  LIBTOOL-STATIC /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/libpreparser_lib.a
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/preparser/preparser/preparser-process.o
  LINK(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/preparser
  CXX(target) /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13/vendor/v8/out/x64.release/obj.target/v8_base/src/accessors.o

extconf failed, exit code 1

Gem files will remain installed in /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/gems/libv8-3.16.14.13 for inspection.
Results logged to /Users/tmorgan/.rvm/gems/ruby-2.3.0@squash/extensions/x86_64-darwin-15/2.3.0/libv8-3.16.14.13/gem_make.out

+1 I have the same issue. Do you have a solution @RISCfuture ?

I just compiled libv8 and therubyracer with --use-system-v8 (or whatever the option is called).

@RISCfuture what version of libv8 did you use in your system to be able to do that? I've tried the one from homebrew master (4.x) and one from homebrew versions (3.15) - didn't work.

The only way I managed to install it all so far:

  1. brew install https://gist.githubusercontent.com/kovyrin/35a29d83749f7515ca00/raw/29f7f4b7d329be94c7877f7533ea91598d5f898c/v8.rb
  2. gem install libv8 -v 3.16.14.13 -- --with-system-v8
  3. gem install therubyracer -v '0.12.2' -- --with-system-v8 --with-v8-dir=/usr/local/opt/v8

I tapped homebrew/versions and installed v8-315.

cool, thanks!

The following worked for me:

brew tap homebrew/versions
brew uninstall v8
brew install v8-315
gem uninstall -a libv8
gem uninstall -a therubyracer
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -v '0.12.1' -- --with-v8-dir=$(brew --prefix v8-315)

The versions are the ones I needed from my Gemfile.lock.

Unfortunately the hints above doesn't work for me. I guess it's because of the mismatch of v8 version between 3.15 in brew and the 3.16 that is required by therubyracer.

The following worked for me (using older Apple's GCC for compiling):

gem uninstall -a libv8
gem uninstall -a therubyracer

brew tap homebrew/dupes
brew install apple-gcc42

gem install libv8 -v '3.16.14.7' -- --with-cxx=/usr/local/bin/g++-4.2
gem install therubyracer -v '0.12.1'

Change the gem versions according to your Gemfile.lock. Or omit the gem install and just tell bundler to use the build options:

bundle config --local build.libv8 --with-cxx=/usr/local/bin/g++-4.2
bundle

@joergschiller's bundle config seems to be the best solution.

Thank you @joergschiller!!! That solved all my issues after trying numerous other avenues, and thanks for including the bundle config!

Thanks @Haegin your solution worked for me.

FWIW there's a 3.16.14.11 build for x86_64-darwin-15 (IOW, 10.11) on rubygems.org, so skipping the build entirely by locking onto that version might be useful to quickly get out of a bind.

@lloeki That's what I did too. If you only need libv8 for rubyracer (for a rails project for example) It's better to just lock-in the working version (which is just one down), and wait for a patch to libv8 for clang 7.3.

Nah, if you only need therubyracer for stuff like coffeescript or autoprefixer, you should just install nodejs. Execjs will find and use it and you don't need neither therubyracer nor execjs in your Gemfile.

+1 I have the same issue

aviat commented

I fixed the issue with Clang 7.3 in #207.
The issue mostly occurs on rubies built on darwin15, with machines using Clang 7.3 (XCode 7.3) since no darwin15 binaries for 3.16.14.13 have been pushed on rubygems.org. So the install fallbacks on the source.
Finally Clang 7.3 is unable to compile V8 as is because of the it now enables the -Wshift-negative-value warning - itself turned into error by a global -Werror.

reiz commented

Thank. this worked for me gem install libv8 -v 3.16.14.13 -- --with-system-v8!

Should be fixed by #207

If you're still having this issue just do a bundle update libv8, don't try the workarounds mentioned above.

@kovyrin answer worked for me. Kudos
#205 (comment)