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

Add -Wno-unused-variable flag to OS X clang flag #124

Merged
merged 1 commit into from
Jun 10, 2014

Conversation

sikachu
Copy link
Contributor

@sikachu sikachu commented Jun 9, 2014

Without this flag, it's unable to compile libv8 on OS X 10.10 due to this error message:

ruby ext/libv8/extconf.rb
creating Makefile
HEAD is now at 7ce3fe1... Version 3.16.14
Using existing [svn-remote "svn"]
HEAD is now at f7bc250... Make gyp/win32 compatible with upstream ninja.
Compiling v8 for x64
Using python 2.7.6
Using compiler: /usr/bin/c++ (clang version 5.1)
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
                 ^
1 error generated.
make[1]: *** [/Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o] Error 1
make: *** [x64.release] Error 2
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
  CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
  CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
  CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
  CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
  CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o

This has been tested against this version of clang and OS X:

$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

This should fix #123


I'm really not sure if this is the right way to fix this issue, and I would rather have v8 devs fix the warning. However, this make the gems works on OS X 10.10, and it would be great if you could accept this patch.

Thank you.

Without this flag, it's unable to compile libv8 on OS X 10.10 due to
this error message:

    ruby ext/libv8/extconf.rb
    creating Makefile
    HEAD is now at 7ce3fe1... Version 3.16.14
    Using existing [svn-remote "svn"]
    HEAD is now at f7bc250... Make gyp/win32 compatible with upstream ninja.
    Compiling v8 for x64
    Using python 2.7.6
    Using compiler: /usr/bin/c++ (clang version 5.1)
    ../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
    static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
                     ^
    1 error generated.
    make[1]: *** [/Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o] Error 1
    make: *** [x64.release] Error 2
    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
      CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
      CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
      CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
      CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
      CXX(target) /Users/sikachu/Projects/libv8/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o

This has been tested against this version of clang and OS X:

    $ g++ -v
    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
    Target: x86_64-apple-darwin14.0.0
    Thread model: posix

This should fix rubyjs#123
@nixpulvis
Copy link

Wow, literally 2 min before me. I had the same thing committed on a local branch. Anyway LGTM. 👍

@kreeger
Copy link

kreeger commented Jun 9, 2014

Building off of your fork on this under 10.10 ran successfully for me — and because of it, I was able to install therubyracer as well. Thanks, @sikachu!

@sikachu
Copy link
Contributor Author

sikachu commented Jun 10, 2014

@nixpulvis thanks! I actually was pulling my hair out about 2 hours before this patch is completed ... >_<

The build is error because of outdated version of rbx, and it should be fixed after #125 got merged.

@ignisf
Copy link
Collaborator

ignisf commented Jun 10, 2014

Thanks!

ignisf added a commit that referenced this pull request Jun 10, 2014
Add `-Wno-unused-variable` flag to OS X clang flag
@ignisf ignisf merged commit 4e644f7 into rubyjs:master Jun 10, 2014
@nixpulvis
Copy link

hey @kreeger how'd you get therubyracer to pick up a custom libv8. I'm able to install this fine, but when installing therubyracer it complains.

@ignisf
Copy link
Collaborator

ignisf commented Jun 12, 2014

@nixpulvis
Copy link

Gah submodules: true thanks >.< knew it was something silly like that.

@kreeger
Copy link

kreeger commented Jun 12, 2014

@nixpulvis I just cloned the source for the libv8 gem, ran rake install inside of that project, and then just a gem install therubyracer command. It picked the custom-built gem right up, so long as it was all under the same version of Ruby (I use rbenv).

@nixpulvis
Copy link

Thanks guys. Got it all worked out.

@lloeki
Copy link
Contributor

lloeki commented Aug 21, 2014

For those poor souls like me that need to build libv8 for an old ruby:

brew edit gcc # see https://github.com/Homebrew/homebrew/issues/29845#issuecomment-50105819
brew install gcc # brings in 4.9.1
CC=gcc-4.9 rbenv install 1.8.7-p374
rbenv local 1.8.7-p374 # outside libv8 as `rake clean` removes `.ruby-version`
gem install bundler
git clone https://github.com/cowboyd/libv8
cd libv8
git checkout v3.16.14.3
cat >> Gemfile
# newer versions need ruby 1.9+
gem 'rubyzip', '< 1.0.0'
gem 'rake-compiler', '<0.9'
^D
bundle install
rake checkout
curl https://raw.githubusercontent.com/sikachu/libv8/20093a74bfc77bd5ef772d8173f14e603682c373/patches/clang51/no-unused-variable.patch -o patches/no-unused-variable.patch
git add patches/no-unused-variable.patch # otherwise it gets `git clean`ed by `rake clean`
rake install

@amerdidit
Copy link

@lloeki thanks a lot for the above. It was my last resort and it worked for me.
I needed to follow your steps even though I was using ruby 2.1.2.

For anybody else with the same problem, I changed the above to look like this:

brew edit gcc # see https://github.com/Homebrew/homebrew/issues/29845#issuecomment-50105819
brew install gcc # brings in 4.9.1
CC=gcc-4.9 rbenv install 2.1.2
rbenv local 2.1.2 # outside libv8 as `rake clean` removes `.ruby-version`
gem install bundler
git clone https://github.com/cowboyd/libv8
cd libv8
git checkout v3.16.14.3
bundle install
rake checkout
curl https://raw.githubusercontent.com/sikachu/libv8/20093a74bfc77bd5ef772d8173f14e603682c373/patches/clang51/no-unused-variable.patch -o patches/no-unused-variable.patch
git add patches/no-unused-variable.patch # otherwise it gets `git clean`ed by `rake clean`
rake install

@benlangfeld
Copy link

When might this be released? Looks like the last release was 9 months ago.

@ignisf
Copy link
Collaborator

ignisf commented Sep 5, 2014

@cowboyd, do you think we should release 3.16.14.4?

@mikebaldry
Copy link

@ignisf 👍 to that. This would be great to release

@cowboyd
Copy link
Collaborator

cowboyd commented Sep 8, 2014

Can do, and certainly with a source release.@ignisf Do you have access to the rubygem?

@ignisf
Copy link
Collaborator

ignisf commented Sep 8, 2014

yes, I do, I'd have done it, but I have no way of creating MacOS binaries, can take care of various linux and freebsd binaries though

@cowboyd
Copy link
Collaborator

cowboyd commented Sep 8, 2014

Hmm. Yeah, and I can't generate any OSX binaries on any other version but 10.9. It would be really nice if there were a Virtualization/CI story that could do multiple OSX versions, but wasn't hugely expensive to maintain.

@cowboyd
Copy link
Collaborator

cowboyd commented Sep 8, 2014

Let's go ahead and release the source version, and the binaries we can. I'll release the binary for 10.9

@ignisf
Copy link
Collaborator

ignisf commented Sep 8, 2014

Source gem is up as well as linux x86_64 binary

@lloeki
Copy link
Contributor

lloeki commented Sep 24, 2014

Dammit (Yosemite PB3, ruby 2.1.2, libv8 3.16.14.7):

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

    /Users/lloeki/.rbenv/versions/2.1.2/bin/ruby extconf.rb --with-cxx=g++ -Wno-unused-variable
creating Makefile
Compiling v8 for x64
Using python 2.7.6
Using compiler: /usr/bin/g++ (clang version 4.2.1)
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
                 ^
1 error generated.

Manual build and install of 3.16.14.7 (as described above) worked fine.

@ignisf
Copy link
Collaborator

ignisf commented Sep 24, 2014

This should no longer happen, as I explicitly disabled -Werror: fac6535

@rubyjs rubyjs locked and limited conversation to collaborators Sep 24, 2014
@ignisf
Copy link
Collaborator

ignisf commented Sep 24, 2014

@lloeki, please check why is this patch not affecting your system and why doesn't the werror=no make flag not having any effect and open up a new issue.

jbinto added a commit to jbinto/dinesafe that referenced this pull request Mar 18, 2015
floehopper added a commit to freerange/static that referenced this pull request Apr 13, 2015
I was seeing the following error when running `bundle install`:

    Unable to find a compiler officially supported by v8.
    It is recommended to use GCC v4.4 or higher
    Using compiler: g++

This then seems to have resulted in the following compilation error:

    ../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
    static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
                     ^
I believe the problem was fixed [1] between version 3.16.14.3 and version
3.16.14.7 of libv8 and a simple `bundle update libv8` seems to have done the
trick.

[1]: rubyjs/libv8#124
floehopper added a commit to freerange/imminence that referenced this pull request Apr 13, 2015
I was seeing the following error when running `bundle install`:

    Unable to find a compiler officially supported by v8.
    It is recommended to use GCC v4.4 or higher
    Using compiler: g++

This then seems to have resulted in the following compilation error:

    ../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
    static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
                     ^
I believe the problem was fixed [1] between version 3.16.14.3 and version
3.16.14.7 of `libv8`. Relaxing the Gemfile constraint on `therubyracer` and
bundle updating `therubyracer` & `libv8` seems to have done the trick.

See also a similar fix for the `static` app [2].

[1]: rubyjs/libv8#124
[2]: alphagov/static#570
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gem install libv8 failed for osx10.10
9 participants