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

Errors when linking to bottled v8 #41091

Closed
jacobsa opened this issue Jun 25, 2015 · 16 comments
Closed

Errors when linking to bottled v8 #41091

jacobsa opened this issue Jun 25, 2015 · 16 comments

Comments

@jacobsa
Copy link
Contributor

jacobsa commented Jun 25, 2015

I'm attempting to get Google JS Test working with Homebrew (again, now that re2 has a non-head-only formula). The problem is that it no longer compiles with the bottle of v8 in homebrew:

% git checkout v8-4.1
% make clean && make
[...]
Undefined symbols for architecture x86_64:
  "std::_Rb_tree_decrement(std::_Rb_tree_node_base*)", referenced from:
      std::_Rb_tree<v8::Isolate*, std::pair<v8::Isolate* const, std::queue<v8::Task*, std::deque<v8::Task*, std::allocator<v8::Task*> > > >, std::_Select1st<std::pair<v8::Isolate* const, std::queue<v8::Task*, std::deque<v8::Task*, std::allocator<v8::Task*> > > > >, std::less<v8::Isolate*>, std::allocator<std::pair<v8::Isolate* const, std::queue<v8::Task*, std::deque<v8::Task*, std::allocator<v8::Task*> > > > > >::_M_insert_unique(std::_Rb_tree_iterator<std::pair<v8::Isolate* const, std::queue<v8::Task*, std::deque<v8::Task*, std::allocator<v8::Task*> > > > >, std::pair<v8::Isolate* const, std::queue<v8::Task*, std::deque<v8::Task*, std::allocator<v8::Task*> > > > const&) in libv8_libplatform.a(default-platform.o)
[...]
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Note that this is against v8 installed from v8-4.1.0.27.yosemite.bottle.tar.gz.

As far as I can tell this is due to the version of v8 installed by homebrew having been built with g++, and gjstest compiling with clang. Supposedly you can work around this by setting -stdlib=libstdc++, but this doesn't seem to work for me due to C++11 features not being available that way.

Since g++ isn't around on most Macs these days, would it make sense to bottle v8 using clang instead? Or am I just misconfiguring something?

@jacknagel
Copy link
Contributor

The bottle is built with clang, but the deployment target is being set to 10.5 which forces it to link against libstdc++. I'm not sure if it's intentional on the part of the v8 developers, but I've seen this before with other gyp-based software.

@jacobsa
Copy link
Contributor Author

jacobsa commented Jun 25, 2015

That explains a lot. Where is that defined? And would it make sense for the homebrew formula to patch that?

@DomT4
Copy link
Member

DomT4 commented Jun 26, 2015

This problem also seems to be the cause of Node misbehaving in certain situations when built with icu4c support in Homebrew. I haven't looked into whether the problem exists in iojs yet.

Theoretically in V8 it's possible to set the MACOSX_DEPLOYMENT_TARGET for gyp at build time.

@jacobsa
Copy link
Contributor Author

jacobsa commented Jul 28, 2015

@jacknagel, @DomT4: Ping. Do you have recommendations for what to do here? (And could you give me details on how to configure this?)

@DomT4
Copy link
Member

DomT4 commented Jul 30, 2015

Does the error reproduce for you when you build v8 from source inside Homebrew? I'd presume so, but it'd be good to eliminate that easy fix before we dive into anything more fun.

@jacobsa
Copy link
Contributor Author

jacobsa commented Jul 30, 2015

It definitely did at the time I filed this issue. I haven't tried since then.

@jacobsa
Copy link
Contributor Author

jacobsa commented Aug 30, 2015

Ping. Can you offer any help with this?

@dunn
Copy link
Contributor

dunn commented Aug 30, 2015

Have you tried changing the deployment target, like @DomT4 suggested? This gets v8 to link against libc++ instead of libstdc++, although there ought to be a more elegant way:

�diff --git a/Library/Formula/v8.rb b/Library/Formula/v8.rb
index 3ed6484..556c9d3 100644
--- a/Library/Formula/v8.rb
+++ b/Library/Formula/v8.rb
@@ -49,6 +49,9 @@ class V8 < Formula
               "'OTHER_LDFLAGS': ['-dynamiclib', '-all_load']",
               "\\0, 'DYLIB_INSTALL_NAME_BASE': '#{opt_lib}'"

+    inreplace "build/standalone.gypi", "'mac_deployment_target%': '10.5'",
+                                       "'mac_deployment_target%': '#{MacOS.version}'"
+
     # Download gyp ourselves because running "make dependencies" pulls in ICU.
     (buildpath/"build/gyp").install resource("gyp")
     (buildpath/"testing/gmock").install resource("gmock")

I still can't get google-js-test to build, though: https://gist.github.com/dunn/d1143fe888a63011d4e9#file-01-make-L49

This is the formula I'm using:

class GoogleJsTest < Formula
  homepage "https://github.com/google/gjstest"
  url "https://github.com/google/gjstest/archive/v1.0.tar.gz"
  sha256 "085b7ea5a9233fdd6a8aee535bf925baff002e5b0ffb9c71d86824850639405e"

  head "https://github.com/google/gjstest.git"

  depends_on :macos => :snow_leopard
  depends_on "gflags"
  depends_on "glog"
  depends_on "protobuf"
  depends_on "re2"
  depends_on "v8"

  def install
    system "make", "PREFIX=#{prefix}", "install"
  end
end

@DomT4
Copy link
Member

DomT4 commented Aug 30, 2015

The whole V8 formula needs updating and rewriting from the ground up, to be honest. I wonder if the V8 built inside Node works against the gjstest.

@DomT4
Copy link
Member

DomT4 commented Aug 30, 2015

It gets further, but not quite: https://gist.github.com/anonymous/04b95ecb10dddab65615

@jacobsa
Copy link
Contributor Author

jacobsa commented Aug 31, 2015

@dunn: I didn't know how to do that, which is why I asked you how above. :-) But thanks for showing me; it totally worked for me at google/gjstest@3a92963. Can we get that into the official v8 formula, and then I'll update the gjstest formula accordingly?

@DomT4
Copy link
Member

DomT4 commented Aug 31, 2015

I'll file a V8 PR in a minute. I've spent the last two hours bullying/being bullied by GYP 😒

@DomT4
Copy link
Member

DomT4 commented Aug 31, 2015

@jacobsa Your tweak works against the upcoming V8 PR:

==> Cleaning
Fixing /usr/local/Cellar/google-js-test/HEAD/bin/gjstest permissions from 755 to 555
==> Finishing up
ln -s ../Cellar/google-js-test/HEAD/bin/gjstest gjstest
ln -s ../Cellar/google-js-test/HEAD/share/gjstest gjstest
==> Summary
🍺  /usr/local/Cellar/google-js-test/HEAD: 34 files, 428K, built in 18 seconds

👍

@DomT4 DomT4 mentioned this issue Aug 31, 2015
@jacobsa
Copy link
Contributor Author

jacobsa commented Aug 31, 2015

@DomT4: Awesome! Thanks for taking care of this.

@jacobsa
Copy link
Contributor Author

jacobsa commented Aug 31, 2015

(To be clear: I'm happy to fix the gjstest problem myself once the v8 change is in.)

@DomT4
Copy link
Member

DomT4 commented Aug 31, 2015

We track Chrome Stable in terms of V8 releases & updates, if that's at all useful knowledge for future. It'd fallen out of sync for the last few months because of various build issues.

@DomT4 DomT4 closed this as completed in 9dae089 Aug 31, 2015
jacobsa added a commit to google/gjstest that referenced this issue Aug 31, 2015
For the longest time I couldn't reproduce these because I couldn't begin
to build, due to the ancient and messed up version of v8 in Homebrew
(see Homebrew/legacy-homebrew#41091). As of Homebrew/legacy-homebrew@9dae089 we now
have v8 4.4.63.31 to work with, and after this commit we build and our
tests pass with the following dependencies installed by homebrew:

    gflags
    glog
    libxml2
    protobuf
    re2
    v8
ybogdanov pushed a commit to ybogdanov/homebrew that referenced this issue Sep 1, 2015
Closes Homebrew#41091.

Closes Homebrew#43428.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants