如何在 Linux ARM64 上构建 Chrome V8?

问题描述 投票:0回答:1

我正在尝试在 Ubuntu 22.04 ARM64 上构建 V8。我尝试过通过方便的脚本进行构建,即

tools/dev/gm.py arm64.release
以及
tools/dev/v8gen.py arm64.release
但没有成功(clang 错误),例如以下多个:

FAILED: obj/cppgc_base/free-list.o 
/usr/bin/clang++ -MMD -MF obj/cppgc_base/free-list.o.d -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -DCR_LIBCXX_REVISION=0c90b8212cbb8a4c6dc78537813118fceea8265d -DCR_SYSROOT_KEY=20230611T210420Z-2 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DENABLE_DISASSEMBLER -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64 -DOBJECT_PRINT -DVERIFY_HEAP -DV8_INTL_SUPPORT -DV8_USE_EXTERNAL_STARTUP_DATA -DV8_ATOMIC_OBJECT_FIELD_WRITES -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_SHARED_RO_HEAP -DV8_WIN64_UNWINDING_INFO -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_ENABLE_CONTROL_FLOW_INTEGRITY -DV8_ENABLE_FUZZTEST -DV8_SHORT_BUILTIN_CALLS -DV8_EXTERNAL_CODE_SPACE -DV8_ENABLE_SPARKPLUG -DV8_ENABLE_MAGLEV -DV8_ENABLE_TURBOFAN -DV8_ENABLE_WEBASSEMBLY -DV8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA -DV8_ALLOCATION_FOLDING -DV8_ALLOCATION_SITE_TRACKING -DV8_ADVANCED_BIGINT_ALGORITHMS -DV8_STATIC_ROOTS -DV8_USE_ZLIB -DV8_USE_LIBM_TRIG_FUNCTIONS -DV8_ENABLE_MAGLEV_GRAPH_PRINTER -DV8_ENABLE_EXTENSIBLE_RO_SNAPSHOT -DV8_COMPRESS_POINTERS -DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_SANDBOX -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DCPPGC_CAGED_HEAP -DCPPGC_YOUNG_GENERATION -DCPPGC_POINTER_COMPRESSION -DCPPGC_SLIM_WRITE_BARRIER -DV8_TARGET_ARCH_ARM64 -DV8_HAVE_TARGET_OS -DV8_TARGET_OS_LINUX -DV8_RUNTIME_CALL_STATS -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../include -Wall -Wextra -Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-cast-function-type -Wno-ignored-pragma-optimize -Wno-deprecated-builtins -Wno-bitfield-constant-conversion -Wno-deprecated-this-capture -Wno-invalid-offsetof -Wno-vla-extension -Wno-thread-safety-reference-return -Wshadow -Werror -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing -fstack-protector -funwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -mllvm -split-threshold-for-reg-with-hint=0 -ffp-contract=off -fcomplete-member-pointers -mbranch-protection=standard --target=aarch64-linux-gnu -mno-outline -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes -fno-omit-frame-pointer -g0 -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wunreachable-code -Wno-shadow -Wctad-maybe-unsupported -Wno-invalid-offsetof -Wshorten-64-to-32 -Wmissing-field-initializers -O3 -fdata-sections -ffunction-sections -fno-unique-section-names -fno-math-errno -fvisibility=default -Wexit-time-destructors -Wenum-compare-conditional -Wno-c++11-narrowing-const-reference -std=c++20 -Wno-trigraphs -gsimple-template-names -fno-exceptions -fno-rtti -nostdinc++ -isystem../../third_party/libc++/src/include -isystem../../third_party/libc++abi/src/include --sysroot=../../build/linux/debian_bullseye_arm64-sysroot -c ../../src/heap/cppgc/free-list.cc -o obj/cppgc_base/free-list.o
error: unknown warning option '-Wno-deprecated-builtins' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-thread-safety-reference-return'; did you mean '-Wno-thread-safety-reference'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-c++11-narrowing-const-reference'; did you mean '-Wno-uninitialized-const-reference'? [-Werror,-Wunknown-warning-option]
clang (LLVM option parsing): Unknown command line argument '-split-threshold-for-reg-with-hint=0'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--unroll-threshold-aggressive=0'?
ninja: build stopped: subcommand failed.

然后我尝试构建/使用与

fetch v8
捆绑在一起的上游 clang 构建,即使在
export VPYTHON_BYPASS="manually managed python not supported by chrome operations"
之后我也得到以下内容:

Building final compiler.
Traceback (most recent call last):
  File "/home/v8user/Desktop/v8/tools/clang/scripts/get_tensorflow.py", line 178, in <module>
    print(os.path.dirname(spec.origin))
AttributeError: 'NoneType' object has no attribute 'origin'
Traceback (most recent call last):
  File "/home/v8user/Desktop/v8/tools/clang/scripts/build.py", line 1539, in <module>
    sys.exit(main())
  File "/home/v8user/Desktop/v8/tools/clang/scripts/build.py", line 1379, in main
    tf_path = subprocess.check_output(
  File "/usr/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['vpython3', '/home/v8user/Desktop/v8/tools/clang/scripts/get_tensorflow.py']' returned non-zero exit status 1.

然后我尝试了以下最近的方法:

克隆 V8 存储库: 使用 Git 克隆 V8 存储库:

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/home/v8user/Desktop/depot_tools
fetch v8

绕过VPYTHON:通过设置环境变量绕过

vpython

export VPYTHON_BYPASS="manually managed python not supported by chrome operations"

设置 GN 参数: 为所需配置手动设置 GN 参数:

gn args out.gn/arm64.release

在打开的编辑器中,我粘贴以下内容以进行发布版本:

is_debug=false
target_cpu="arm64" 
v8_target_cpu="arm64"
is_clang=false
treat_warnings_as_errors=false
use_custom_libcxx=false
use_custom_libcxx_for_host=false

随后:

ninja -C out.gn/arm64.release

这至少开始构建,但是构建以以下方式终止:

ninja: Entering directory `out.gn/arm64.release'
[1084/3863] CXX obj/test/cctest/cctest_sources/test-code-stub-assembler.o
FAILED: obj/test/cctest/cctest_sources/test-code-stub-assembler.o 
aarch64-linux-gnu-g++ -MMD -MF obj/test/cctest/cctest_sources/test-code-stub-assembler.o.d -DV8_INTL_SUPPORT -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_OZONE=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -D_GLIBCXX_ASSERTIONS=1 -DCR_SYSROOT_KEY=20230611T210420Z-2 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64 -DV8_USE_EXTERNAL_STARTUP_DATA -DV8_ATOMIC_OBJECT_FIELD_WRITES -DV8_ENABLE_LAZY_SOURCE_POSITIONS -DV8_SHARED_RO_HEAP -DV8_WIN64_UNWINDING_INFO -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_ENABLE_CONTROL_FLOW_INTEGRITY -DV8_SHORT_BUILTIN_CALLS -DV8_EXTERNAL_CODE_SPACE -DV8_ENABLE_SPARKPLUG -DV8_ENABLE_MAGLEV -DV8_ENABLE_TURBOFAN -DV8_ENABLE_WEBASSEMBLY -DV8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA -DV8_ALLOCATION_FOLDING -DV8_ALLOCATION_SITE_TRACKING -DV8_ADVANCED_BIGINT_ALGORITHMS -DV8_STATIC_ROOTS -DV8_USE_ZLIB -DV8_ENABLE_MAGLEV_GRAPH_PRINTER -DV8_ENABLE_EXTENSIBLE_RO_SNAPSHOT -DV8_COMPRESS_POINTERS -DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_SANDBOX -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS -DCPPGC_CAGED_HEAP -DCPPGC_YOUNG_GENERATION -DCPPGC_POINTER_COMPRESSION -DCPPGC_SLIM_WRITE_BARRIER -DV8_TARGET_ARCH_ARM64 -DV8_HAVE_TARGET_OS -DV8_TARGET_OS_LINUX -DV8_RUNTIME_CALL_STATS -DABSL_ALLOCATOR_NOTHROW=1 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../.. -Igen -I../../include -I../../third_party/abseil-cpp -Igen/include -I../../third_party/icu/source/common -I../../third_party/icu/source/i18n -I../../third_party/fp16/src/include -ffp-contract=off -Wall -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wno-deprecated-declarations -Wno-comments -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -fno-ident -fno-strict-aliasing -fstack-protector -funwind-tables -fPIC -pipe -pthread -mbranch-protection=standard -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fno-omit-frame-pointer -g0 -fvisibility=hidden -Wno-invalid-offsetof -Wno-strict-overflow -Wno-return-type -Wno-int-in-bool-context -Wno-deprecated -Wno-stringop-overflow -Wno-stringop-overread -Wno-restrict -Wno-array-bounds -Wno-nonnull -Wno-dangling-pointer -O3 -fdata-sections -ffunction-sections -fno-math-errno -Wno-narrowing -Wno-class-memaccess -std=gnu++2a -fno-exceptions -fno-rtti --sysroot=../../build/linux/debian_bullseye_arm64-sysroot -fvisibility-inlines-hidden -c ../../test/cctest/test-code-stub-assembler.cc -o obj/test/cctest/cctest_sources/test-code-stub-assembler.o
{standard input}: Assembler messages:
{standard input}:117: Error: invalid addressing mode at operand 2 -- `str x16,x0'
[1089/3863] CXX obj/test/cctest/cctest_sources/test-assembler-arm64.o
ninja: build stopped: subcommand failed.

请有人协助我如何在这里构建 V8,我在

x86_64
Linux 和 Mac 上构建没有任何问题,类似地,我可以按照
ARM64
Mac (M3 Max) 进行构建。尽管出于某种原因,我在 ARM64 Linux 上构建起来确实很困难。 我感谢这里的任何帮助。感谢您的帮助并期待将其启动并运行! :)

google-chrome v8
1个回答
0
投票
https://docs.google.com/document/d/1u-HAFfjWIH3WY3xajuGxGii-lWi1rpf16hVmB-mRdTA/edit

有些部分现在几乎肯定已经过时了,例如 python2 要求。但用系统安装的 ninja/clang/... 替换捆绑工具的关键思想可能仍然适用。

您可以向该文档添加注释以了解任何需要更新的步骤。或者您可以制作一份副本,根据需要进行更新,然后将其发布到此处,以便其他人追随您的脚步。

另请注意顶部的摘要:交叉编译可能更实用(除非您的arm64设备比Raspberry Pi更强大)。

© www.soinside.com 2019 - 2024. All rights reserved.