v8のソースコードダウンロード用の環境整備
v8
のソースコードはgit
で管理されているが、git
コマンドを利用してソースコード取得するのではなく、依存するライブラリ一式含めて用意してくれうgclient
コマンドを利用してソースコードを取得する。
そこでまずは gclient をオリジナルのドキュメントを参照して用意する
リファレンス
v8オリジナルドキュメントはx86を前提
Arm64でClangでv8をコンパイルした記録
Arm64はGccでコンパイルしたほうが良いという記録
ビルド環境
PC | M1 MacBook Pro 2021 (Apple M1 Pro) |
VM | UTM v3.0.4 |
OS | Ubuntu20.04 |
ソースコードをダウンロード
$ mkdir ~work/v8
$ cd ~work/v8
$ fetch v8
$ gclient sync
ARM用向け変更一覧
-
gn
をx64
からarm64
に置き換え(DEPS
ファイル書き換えしてgclient sync
) - システム側の
clang
を利用 (gn
の引数に渡す) -
clang
のchromeプラグイン
を利用しない設定に変更 (gn
の引数に渡す) -
target_cpu
,v8_target_cpu
を"arm64"
に設定 (gn
の引数に渡す)
"$ git diff DEPS
diff --git a/DEPS b/DEPS
index 0ae8dd94f2..9d76ef568d 100644
--- a/DEPS
+++ b/DEPS
@@ -91,7 +91,7 @@ deps = {
'buildtools/linux64': {
'packages': [
{
- 'package': 'gn/gn/linux-amd64',
+ 'package': 'gn/gn/linux-arm64',
'version': Var('gn_version'),
}
],
$ gclient sync
$ cd v8
$ gn gen out/Default --args='is_debug=false target_cpu="arm64" v8_target_cpu="arm64" clang_base_path="/lib/llvm-14" clang_use_chrome_plugins=false'
コンパイル
$ cat out/Default/args.gn
is_debug = false
target_cpu = "arm64"
v8_target_cpu = "arm64"
clang_base_path = "/lib/llvm-14"
clang_use_chrome_plugins = false
$ ninja -C out/Default
ninja: Entering directory `out/Default/'
[3156/3156] STAMP obj/test/v8_optimize_for_size.stamp
$ tools/run-tests.py --outdir out/Default/
Build found: /home/rai/work/v8/v8/out/Default/
>>> Autodetected:
pointer_compression
pointer_compression_shared_cage
webassembly
>>> Running tests for arm64.release
>>> Running with test processors
[02:08|% 94|+ 19324|- 0]: Done
>>> 20488 base tests produced 19324 (94%) non-filtered tests
>>> 19324 tests ran
v8 のテスト
Testing the V8 JavaScript Engine
テストの種類
- benchmarks — Standard performance tuning benchmarks.
- test262 — Conformance tests against the ECMAScript specification.
- mjsunit — Unit tests written in JavaScript.
- cctest/u nittests— C++ unit tests for internal V8 classes.
- fuzzer — Input fuzzer tests providing invalid input, possibly crashing V8.
- intl — Tests for Internationalization features of ECMAScript.
- message — Validates error messages produced by invalid JavaScript code.
- webkit — Test cases borrowed from the WebKit JavaScript Engine.
- mozilla —Test cases borrowed from the Mozilla JavaScript Engine.
- wasm-js — Validation of WebAssembly, using the JavaScript API.
- wasm-api-tests — Validation of WebAssembly, using the C++ API.
- wasm-spec-tests — Conformance to the WebAssembly specification.
- inspector — Validates the V8 inspector interface (for debugging)
- debugger — Validates the built-in debugger command.
Conformanceテストの実行
エラー発生なし
$ tools/run-tests.py --outdir out/Default test262
Build found: /home/rai/work/v8/v8/out/Default
>>> Autodetected:
pointer_compression
pointer_compression_shared_cage
webassembly
>>> Running tests for arm64.release
>>> Running with test processors
[07:30|% 161|+ 86442|- 0]: Done
>>> 53646 base tests produced 86442 (161%) non-filtered tests
>>> 86442 tests ran
ベンチマークテストの実行
エラー発生なし
$ tools/run-tests.py --outdir out/Default benchmarks
Build found: /home/rai/work/v8/v8/out/Default
>>> Autodetected:
pointer_compression
pointer_compression_shared_cage
webassembly
>>> Running tests for arm64.release
>>> Running with test processors
[00:06|% 100|+ 55|- 0]: Done
>>> 55 base tests produced 55 (100%) non-filtered tests
>>> 55 tests ran