LoginSignup
1
0

More than 1 year has passed since last update.

ARM版Ubuntuでv8をコンパイルする

Posted at

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用向け変更一覧

  • gnx64からarm64に置き換え(DEPSファイル書き換えして gclient sync)
  • システム側のclangを利用 (gnの引数に渡す)
  • clangchromeプラグインを利用しない設定に変更 (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
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0