I was able to cross compile V8 as follows.
In tools/toolchain/BUILD.gn I added:
gcc_toolchain("arm64-buildroot") {
toolprefix = "/path/to/buildroot/output/host/bin/aarch64-linux-"
cc = "${toolprefix}gcc"
cxx = "${toolprefix}g++"
readelf = "${toolprefix}readelf"
nm = "${toolprefix}nm"
ar = "${toolprefix}ar"
ld = cxx
toolchain_args = {
current_cpu = "arm64"
current_os = "linux"
is_clang = false
}
}
Ran gn gen out/arm64
and set the build arguments with gn args out/arm64
:
custom_toolchain = "//tools/toolchain:arm64-buildroot"
target_cpu = "arm64"
target_os = "linux"
target_sysroot = "/path/to/buildroot/output/host/aarch64-buildroot-linux-gnu/sysroot"
is_clang = false
use_gold = false
is_component_build = false
v8_monolithic = true
v8_use_external_startup_data = false
Then to build the library:
ninja -C out/arm64 v8_monolith
For more information see:
https://gn.googlesource.com/gn/+/master/docs/reference.md#example-of-defining-a-toolchain
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…