V8--building on macOS

JavaScript Engine

V8 is Google’s open source JavaScript engine.
V8 implements ECMAScript as specified in ECMA-262.
V8 is written in C++ and is used in Google Chrome, the open source browser from Google.
V8 can run standalone, or can be embedded into any C++ application.
V8 Project page: https://v8.dev/docs

Proxy

replace 127.0.0.1:1087 with your http proxy host:port

1
2
3
4
5
echo '\nproxy=127.0.0.1:1087\nset_proxy() {\n    export http_proxy=http://$proxy\n    export https_proxy=http://$proxy\n}\n\nunset_proxy() {\n    unset http_proxy\n    unset https_proxy\n}\n\nset_git_proxy() {\n    git config --global http.proxy $proxy\n    git config --global https.proxy $proxy\n}\n\nunset_git_proxy() {\n    git config --unset --global http.proxy\n    git config --unset --global https.proxy\n}\n\nNO_AUTH_BOTO_CONFIG=~/.boto' >> ~/.zshrc
echo '[Boto]\nproxy = 127.0.0.1\nproxy_port = 1087' >> ~/.boto
source ~/.zshrc
set_proxy
set_git_proxy

Depot tools

1
2
3
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
# Add depot_tools to the front of your PATH (you will probably want to put this in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools to /path/to/depot_tools:
export PATH=/path/to/depot_tools:$PATH

Get v8 and building

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# https://v8.dev/docs/build
# https://chromium.googlesource.com/v8/v8.git or
fetch v8
cd v8
gclient sync
tools/dev/gm.py x64.release

# output
smileorigin@Galaxy-MacBook-Pro v8 % tools/dev/gm.py x64.release
# gn gen out/x64.release
Done. Made 153 targets from 88 files in 685ms
# autoninja -C out/x64.release d8
ninja: Entering directory `out/x64.release`
[1502/1502] LINK ./d8
Done! - V8 compilation finished successfully.

# recommand adding these to your ~/.bashrc or ~/.zshrc
V8_HOME='/path/to/v8'
alias d8=$V8_HOME/out/x64.release/d8
alias tick-processor=$V8_HOME/tools/mac-tick-processor
export D8_PATH=$V8_HOME/repo/out/x64.release

Questions

Failed to fetch file gs://chromium-gn/

1
2
3
4
5
6
7
# log
Failed to fetch file gs://chromium-gn/a68b194afb05d6a6357cf2e2464136ed7723c305 for src/buildtools/mac/gn.
...
Error: Command 'download_from_google_storage --no_resume --platform=darwin --no_auth --bucket chromium-gn -s src/buildtools/mac/gn.sha1' returned non-zero exit status ...

# https://idom.me/articles/843.html
# wget --no-check-certificate https://storage.googleapis.com/chromium-gn/a68b194afb05d6a6357cf2e2464136ed7723c305 -O src/buildtools/mac/gn

failed to send request: Post https://chrome-infra-packages.appspot.co

https://github.com/termux/termux-app/issues/698

SSL: CERTIFICATE_VERIFY_FAILED

1
2
3
4
5
6
7
8
# log
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)>

# 若是使用 python2.7 的版本,则会遇到该问题,在有该问题的 python 脚本代码开始前添加禁用 ssl 校验代码即可
# v8/tools/clang/scripts/update.py 下载 clang 的脚本则需要手动执行下 python v8/tools/clang/scripts/update.py
# 然后在继续 gclient sync
import ssl
ssl._create_default_https_context = ssl._create_unverified_context

xcodebuild

1
2
3
4
# log
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Reference

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×