Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

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

Closed
RISCfuture opened this issue Mar 22, 2016 · 20 comments
Closed

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

RISCfuture opened this issue Mar 22, 2016 · 20 comments

Comments

@RISCfuture
Copy link

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
@tnsderek
Copy link

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

@RISCfuture
Copy link
Author

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

@kovyrin
Copy link

kovyrin commented Mar 23, 2016

@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.

@kovyrin
Copy link

kovyrin commented Mar 23, 2016

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

@RISCfuture
Copy link
Author

I tapped homebrew/versions and installed v8-315.

@kovyrin
Copy link

kovyrin commented Mar 23, 2016

cool, thanks!

@Haegin
Copy link

Haegin commented Mar 24, 2016

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.

@joergschiller
Copy link

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

@JohnMorales
Copy link

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

@AHaymond
Copy link

AHaymond commented Apr 8, 2016

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

@markorapaic
Copy link

Thanks @Haegin your solution worked for me.

@lloeki
Copy link
Contributor

lloeki commented Apr 13, 2016

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.

@wspurgin
Copy link

@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.

@ignisf
Copy link
Collaborator

ignisf commented Apr 14, 2016

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.

@ghost
Copy link

ghost commented Apr 23, 2016

+1 I have the same issue

@aviat
Copy link
Contributor

aviat commented Apr 24, 2016

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
Copy link

reiz commented Apr 24, 2016

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

@ignisf
Copy link
Collaborator

ignisf commented Apr 24, 2016

Should be fixed by #207

@ignisf ignisf closed this as completed Apr 24, 2016
@rmoriz
Copy link

rmoriz commented Aug 3, 2016

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

technicalpickles added a commit to technicalpickles/home-assistant.io that referenced this issue Aug 21, 2016
See rubyjs/libv8#205 for some details of the
problem. It's fixed in 3.16.14.15 of libv8
balloob pushed a commit to home-assistant/home-assistant.io that referenced this issue Aug 21, 2016
See rubyjs/libv8#205 for some details of the
problem. It's fixed in 3.16.14.15 of libv8
hectorcorrea pushed a commit to Brown-University-Library/OLD-ARCHIVED_bul-search that referenced this issue Nov 14, 2016
@taimoorsendoso
Copy link

taimoorsendoso commented Nov 12, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.