Skip to content

Can't install v8js on macOS Catalina #457

@Jiri-Mihal

Description

@Jiri-Mihal

I can't install V8Js on macOS Catalina, PHP 7.4.13. I tried two ways of installation:

  1. First Way: Install the latest version of V8 with brew and then compile v8js.
  2. Second Way: Compile the older version of v8 from the source and then compile v8js.

Both ways without success. Any ideas?

First Way Steps

Installation of the latest version of v8 with Brew:

brew install php
php -v
PHP 7.4.13 (cli) (built: Nov 26 2020 04:59:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies
brew install v8
🍺  /usr/local/Cellar/v8/8.7.220.25: 74 files, 40.4MB

Compilation of v8js:

cd ~
git clone https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure CXXFLAGS="-Wno-c++11-narrowing" --with-v8js="/usr/local/Cellar/v8/8.7.220.25/libexec" --with-php-config="/usr/local/Cellar/php/7.4.13/bin/php-config"

Here I get this error:

checking for libv8_libplatform... found
checking for V8 version... NONE
configure: error: could not determine libv8 version

I also tried to copy v8 files to default path with: cp -r /usr/local/Cellar/v8/8.7.220.25/libexec/include/* /usr/local/include, cp /usr/local/Cellar/v8/8.7.220.25/libexec/lib*.dylib /usr/local/lib/. Then I tried some different configurations: ./configure CXXFLAGS="-Wno-c++11-narrowing", ./configure CXXFLAGS="-Wno-c++11-narrowing" LDFLAGS="-lstdc++", and ./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++" CPPFLAGS="-DV8_COMPRESS_POINTERS". No luck:/

Second Way Steps

Compiling older version v8:

mkdir ~/tmp & cd ~/tmp
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
fetch v8
cd v8
git checkout 7.4.288.25
gclient sync
nano build/mac/find_sdk.py

Here I update regex to accept newer version of SDK. macOS Catalina comes with version 11. ^MacOSX(\10\.\d+)\.sdk$ to ^MacOSX(\d+\.\d+)\.sdk$.

tools/dev/v8gen.py -vv x64.release -- is_component_build=true use_custom_libcxx=false
ninja -C out.gn/x64.release
cp -r include/* /usr/local/include
cp lib*.dylib /usr/local/lib/

Compilation of v8js:

cd ~/tmp
git clone https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure CXXFLAGS="-Wno-c++11-narrowing" LDFLAGS="-lstdc++"
make

Here I get bunch of warnings.

/Users/jirimihal/tmp/v8js/v8js_array_access.cc:213:25: warning: 'GetEnteredContext' is deprecated: Use
      GetEnteredOrMicrotaskContext(). [-Wdeprecated-declarations]
                        result->Set(isolate->GetEnteredContext(), i ++, V8JS_INT(j));
                                             ^
/usr/local/include/v8.h:7921:3: note: 'GetEnteredContext' has been explicitly marked deprecated here
  V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().",
  ^
/usr/local/include/v8config.h:307:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
/Users/jirimihal/tmp/v8js/v8js_array_access.cc:213:4: warning: ignoring return value of function
      declared with 'warn_unused_result' attribute [-Wunused-result]
                        result->Set(isolate->GetEnteredContext(), i ++, V8JS_INT(j));
...and so on...
4 warnings generated.
warning: no debug symbols in executable (-arch x86_64)
----------------------------------------------------------------------
Libraries have been installed in:
   /Users/jirimihal/tmp/v8js/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.
make test

Almost all tests fail.

=====================================================================
PHP         : /usr/local/Cellar/php/7.4.13/bin/php 
PHP_SAPI    : cli
PHP_VERSION : 7.4.13
ZEND_VERSION: 3.4.0
PHP_OS      : Darwin - Darwin Jiris-MacBook-Pro.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
INI actual  : /Users/jirimihal/tmp/v8js/tmp-php.ini
More .INIs  :   
---------------------------------------------------------------------
PHP         : /usr/local/Cellar/php/7.4.13/bin/phpdbg 
PHP_SAPI    : phpdbg
PHP_VERSION : 7.4.13
ZEND_VERSION: 3.4.0
PHP_OS      : Darwin - Darwin Jiris-MacBook-Pro.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
INI actual  : /Users/jirimihal/tmp/v8js/tmp-php.ini
More .INIs  : 
---------------------------------------------------------------------
CWD         : /Users/jirimihal/tmp/v8js
Extra dirs  : 
VALGRIND    : Not used
=====================================================================
TIME START 2020-11-27 17:22:33
=====================================================================
FAIL Test V8::executeString() : Check ArrayAccess interface wrapping [tests/array_access.phpt] 
FAIL Test V8::executeString() : Check ArrayAccess live binding [tests/array_access_001.phpt] 
FAIL Test V8::executeString() : Use ArrayAccess with JavaScript native push method [tests/array_access_002.phpt] 
FAIL Test V8::executeString() : Export PHP methods on ArrayAccess objects [tests/array_access_003.phpt] 
FAIL Test V8::executeString() : Export PHP properties on ArrayAccess objects [tests/array_access_004.phpt] 
...and so on...
=====================================================================
TIME END 2020-11-27 17:22:52

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   65
---------------------------------------------------------------------

Number of tests :  177               175
Tests skipped   :    2 (  1.1%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :  172 ( 97.2%) ( 98.3%)
Tests passed    :    3 (  1.7%) (  1.7%)
---------------------------------------------------------------------
Time taken      :   19 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test V8::executeString() : Check ArrayAccess interface wrapping [tests/array_access.phpt]
Test V8::executeString() : Check ArrayAccess live binding [tests/array_access_001.phpt]
Test V8::executeString() : Use ArrayAccess with JavaScript native push method [tests/array_access_002.phpt]
Test V8::executeString() : Export PHP methods on ArrayAccess objects [tests/array_access_003.phpt]
Test V8::executeString() : Export PHP properties on ArrayAccess objects [tests/array_access_004.phpt]
...and so on...
=====================================================================

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.	You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]: n
make: *** [test] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions