Closed anhkhoi closed 8 years ago
Did you compile your V8 with external snapshot support? If so, then it should have created natives_blob.bin
file and V8Js can't find that file.
Otherwise it might be a general compilation error. Please consult config.log file for details.
If you need further assistance, please attach the config.log
file here, or put it somewhere on pastebin
@stesie I'm guessing v8 was installed via brew. Here's the formula: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/v8.rb
I'm not too familiar with V8, but is this relevant?
https://github.com/Homebrew/homebrew/blob/master/Library/Formula/v8.rb (line 70) https://bugs.chromium.org/p/v8/issues/detail?id=4511#c3
@stesie My config.log at here https://0bin.net/paste/SiPWlGLqcwl5Bwhe#WX3Bkyz9d7gIZ7xRJdlLOI6OR+r5Qbldgcry0jgP-7r Please take a look
@fterragna Yes, I used brew to install v8 and consult the setup guide at this page https://mathieuhays.co.uk/how-to-install-v8js-for-php-on-mac-os-x/
Here is homebrew recipe to install v8 with icu and snapshots without external blobs.
# Track Chrome stable.
# https://omahaproxy.appspot.com/
class V8 < Formula
desc "Google's JavaScript engine"
homepage "https://code.google.com/p/v8/"
url "https://chromium.googlesource.com/v8/v8.git/+archive/5.1.117.tar.gz"
sha256 "82735971991c5500688bdf32cda88917a72ba823d4e1992552b92e8644cfac05"
head "https://chromium.googlesource.com/v8/v8.git"
bottle do
cellar :any
end
option "with-readline", "Use readline instead of libedit"
# not building on Snow Leopard:
# https://github.com/Homebrew/homebrew/issues/21426
depends_on :macos => :lion
depends_on :python => :build # gyp doesn't run under 2.6 or lower
depends_on "readline" => :optional
depends_on "icu4c" => :recommended
needs :cxx11
# Update from "DEPS" file in tarball.
# resources definition, do not edit, autogenerated
resource "mozilla-tests" do
url "https://chromium.googlesource.com/v8/deps/third_party/mozilla-tests.git",
:revision => "f6c578a10ea707b1a8ab0b88943fe5115ce2b9be"
end
resource "buildtools" do
url "https://chromium.googlesource.com/chromium/buildtools.git",
:revision => "14288a03a92856fe1fc296d39e6a25c2d83cd6cf"
end
resource "ecmascript_simd" do
url "https://chromium.googlesource.com/external/github.com/tc39/ecmascript_simd.git",
:revision => "c8ef63c728283debc25891123eb00482fee4b8cd"
end
resource "googlemock" do
url "https://chromium.googlesource.com/external/googlemock.git",
:revision => "0421b6f358139f02e102c9c332ce19a33faf75be"
end
resource "clang" do
url "https://chromium.googlesource.com/chromium/src/tools/clang.git",
:revision => "96f43fa6c1232981bc401c0b6f2e2697a318356b"
end
resource "googletest" do
url "https://chromium.googlesource.com/external/github.com/google/googletest.git",
:revision => "6f8a66431cb592dad629028a50b3dd418a408c87"
end
resource "common" do
url "https://chromium.googlesource.com/chromium/src/base/trace_event/common.git",
:revision => "e40c41030f44cbd5b6f54081436620f43c3bb08a"
end
resource "benchmarks" do
url "https://chromium.googlesource.com/v8/deps/third_party/benchmarks.git",
:revision => "05d7188267b4560491ff9155c5ee13e207ecd65f"
end
resource "gyp" do
url "https://chromium.googlesource.com/external/gyp.git",
:revision => "61259d585ce99d9de8b35188cd0025bdbcb58411"
end
resource "test262" do
url "https://chromium.googlesource.com/external/github.com/tc39/test262.git",
:revision => "57d3e2216fa86ad63b6c0a54914ba9dcbff96003"
end
resource "swarming" do
url "https://chromium.googlesource.com/external/swarming.client.git",
:revision => "df6e95e7669883c8fe9ef956c69a544154701a49"
end
resource "icu" do
url "https://chromium.googlesource.com/chromium/deps/icu.git",
:revision => "e466f6ac8f60bb9697af4a91c6911c6fc4aec95f"
end
def install
# Bully GYP into correctly linking with c++11
ENV.cxx11
ENV["GYP_DEFINES"] = "clang=1 mac_deployment_target=#{MacOS.version}"
# https://code.google.com/p/v8/issues/detail?id=4511#c3
ENV.append "GYP_DEFINES", "v8_use_external_startup_data=0"
if build.with? "icu4c"
ENV.append "GYP_DEFINES", "use_system_icu=1"
i18nsupport = "i18nsupport=on"
else
i18nsupport = "i18nsupport=off"
end
# fix up libv8.dylib install_name
# https://github.com/Homebrew/homebrew/issues/36571
# https://code.google.com/p/v8/issues/detail?id=3871
inreplace "tools/gyp/v8.gyp",
"'OTHER_LDFLAGS': ['-dynamiclib', '-all_load']",
"\\0, 'DYLIB_INSTALL_NAME_BASE': '#{opt_lib}'"
# resources installation, do not edit, autogenerated
(buildpath/"test/mozilla/data").install resource("mozilla-tests")
(buildpath/"buildtools").install resource("buildtools")
(buildpath/"test/simdjs/data").install resource("ecmascript_simd")
(buildpath/"testing/gmock").install resource("googlemock")
(buildpath/"tools/clang").install resource("clang")
(buildpath/"testing/gtest").install resource("googletest")
(buildpath/"base/trace_event/common").install resource("common")
(buildpath/"test/benchmarks/data").install resource("benchmarks")
(buildpath/"build/gyp").install resource("gyp")
(buildpath/"test/test262/data").install resource("test262")
(buildpath/"tools/swarming_client").install resource("swarming")
(buildpath/"third_party/icu").install resource("icu")
system "make", "native", "library=shared", "snapshot=on",
"console=readline", i18nsupport,
"strictaliasing=off"
include.install Dir["include/*"]
cd "out/native" do
rm ["libgmock.a", "libgtest.a"]
lib.install Dir["lib*"]
bin.install "d8", "mksnapshot", "process", "shell" => "v8"
end
end
test do
assert_equal "Hello World!", pipe_output("#{bin}/v8 -e 'print(\"Hello World!\")'").chomp
end
end
I bumped into the same error on ubuntu15. Any hints on how to get it working?
@alextartan On ubuntu you can use my ppa - https://launchpad.net/~pinepain/+archive/ubuntu/libv8-5.1. It's mostly experimental but may do the job.
@pinepain Nope, no luck. (some context: I've built the latest v8, continued with your instructions and when i ran ./configure
, it gave me that error about natives blob:
checking for V8 version... 5.1.117
checking for libv8_libplatform.a... found in /usr
checking whether V8 requires startup data... yes
checking for natives_blob.bin... not found
configure: error: Please provide V8 native blob as needed
Note: I do have /opt/google/chrome/natives_blob.bin
(403KB). Is this what the script is looking for? Is it even the same file or just name coincidence? If it is the correct one, how can I point the script to it?
The point is that ./configure
now tries to "guess" whether V8 requires natives_blob.bin
file to run. Generally you can compile V8 with internal and external startup data (or no snapshot support at all).
./configure
simply tries to run V8 without startup data, if that doesn't work, then it assumes that those blobs are needed. If it can't find any, it bails out.
The problem however is, that if V8 doesn't work for whatever else reason then the error message is misleading.
As to config.log by @anhkhoi, the problem is
configure:5108: checking whether V8 requires startup data
configure:5155: g++ -o conftest -g -O2 -I/usr/local/include -std=c++11 -I/usr/local -L/usr/local/lib conftest.cpp -lv8 /usr/local/lib/libv8_libbase.a >&5
Undefined symbols for architecture x86_64:
"v8::platform::CreateDefaultPlatform(int)", referenced from:
_main in conftest-169e3d.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:5155: $? = 1
configure: program exited with status 1
... not that V8 itself compiles but complains about missing startup data. It doesn't even link, because the linker cannot resolve CreateDefaultPlatform
method.
@alextartan no, that's not the file it's looking for. Google Chrome ships its own version of V8 that obviously requires external startup data. But you don't linke against that V8 library, but the one by @pinepain. And as far as I know he doesn't compile with external startup data (but internal).
Please provide your config.log
file as well or have a look for the errors below "checking whether V8 requires startup data" yourself
@anhkhoi @fterragna I suppose there is an issue with config.m4
, which overwrites a variable it shouldn't (which only triggers on MacOS where it has to link against two extra files).
Please try patching your config.m4
files like this, then run phpize
and configure
again:
diff --git a/config.m4 b/config.m4
index f721165..63a86f4 100644
--- a/config.m4
+++ b/config.m4
@@ -145,6 +145,7 @@ int main ()
;;
esac
+ LDFLAGS_libplatform=""
for static_link_extra_file in $static_link_extra; do
AC_MSG_CHECKING([for $static_link_extra_file])
@@ -164,7 +165,7 @@ int main ()
AC_MSG_ERROR([Please provide $static_link_extra_file next to the libv8.so, see README.md for details])
fi
- LDFLAGS_libplatform="$static_link_dir/$static_link_extra_file"
+ LDFLAGS_libplatform="$LDFLAGS_libplatform $static_link_dir/$static_link_extra_file"
done
# modify flags for (possibly) succeeding V8 startup check
@stesie This is my config.log http://pastebin.com/1LkMqnSg (ran v8 make again just before the v8js) Both are, as indicate, located in /tmp.
I also have libv8-5.1
installed from the PPA
sudo apt-get install libv8-5.1*
libv8-5.1-d8 is already the newest version.
libv8-5.1-dbg is already the newest version.
libv8-5.1-dev is already the newest version.
libv8-5.1.117 is already the newest version.
@stesie Thank for your config.m4 patching. It's working for me.
@alextartan the critical part from the logfile is
configure:4952: checking whether V8 requires startup data
configure:4999: g++ -o conftest -g -O2 -I/usr/include -std=c++11 -I/usr -Wl,--rpath=/usr/lib -L/usr/lib conftest.cpp -lv8 /usr/lib/libv8_libplatform.a >&5
conftest.cpp: In function 'int main()':
conftest.cpp:38:27: error: 'struct v8::Isolate::CreateParams' has no member named 'array_buffer_allocator'
create_params.array_buffer_allocator = &array_buffer_allocator;
^
configure:4999: $? = 1
configure: program exited with status 1
So configure picks up V8 from /usr (as expected, which probably is @pinepain version), it even detects it is a 5.1 version line. Yet it has a v8.h header file that doesn't have array_buffer_allocator
declared (which @pinepain dev-package amd64 for Ubuntu wily has however).
Hence, please check /usr/include/v8.h
file, it should declare a struct CreateParams
which has a array_buffer_allocator
field.
struct CreateParams {
CreateParams()
: entry_hook(NULL),
code_event_handler(NULL),
snapshot_blob(NULL),
counter_lookup_callback(NULL),
create_histogram_callback(NULL),
add_histogram_sample_callback(NULL),
array_buffer_allocator(NULL) {}
if it doesn't you most probably have an old version lingering around, from whichever source
@anhkhoi thanks for the feedback, just merged it to master. Will push a release with the fix soon.
I had the same issue on macOS Sierra and PHP 5.6, installation without Homebrew. I just copied missing files and problem was solved.
cp /tmp/v8/out/native/natives_blob.bin /usr/local/lib/
cp /tmp/v8/out/native/snapshot_blob.bin /usr/local/lib/
I hope it will be helpful for somebody.
As report title, I'm trying to install php v8js on my mac os. The command as below:
cd ~
mkdir tmp && cd tmp
git clone -b master https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure CXXFLAGS="-Wno-c++11-narrowing"
make
make test
make install
But I'm doing at step
./configure
. The command throw errors.checking for natives_blob.bin... not found
configure: error: Please provide V8 native blob as needed
Any solution for me? Thanks.