有人可以提供有关使用 Buildroot 工具链交叉编译 V8 的建议吗?
我需要将 V8 整体库嵌入到当前使用 CMake 的 C++ 应用程序中。在 Buildroot 下,cmake 包自动提供了一个 toolchain.cmake 文件,以确保正确的编译器,使用 sysroot 和 C++ 库等。
我可以使用 sysroot
设置 gn args
并理解有一个 custom_toolchain
参数我可以设置为某个描述的工具链定义文件的路径?
文档似乎有点缺乏。有没有人有为基于 builroot 的项目编译 V8 或定义“自定义工具链”的经验?
答案 0 :(得分:1)
我能够按如下方式交叉编译 V8。
在 tools/toolchain/BUILD.gn 中,我添加了:
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
}
}
运行 gn gen out/arm64
并使用 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
然后构建库:
ninja -C out/arm64 v8_monolith
有关更多信息,请参阅: https://gn.googlesource.com/gn/+/master/docs/reference.md#example-of-defining-a-toolchain