Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 views
in Technique[技术] by (71.8m points)

Cross Compile V8 using Buildroot toolchain

Is anyone able to offer advice on cross-compiling V8 using a Buildroot toolchain?

I need to embed the V8 monolith lib into a C++ app currently using CMake. Under Buildroot cmake packages are automagically provided with a toolchain.cmake file to ensure to correct compiler, sysroot and C++ libs are used etc.

I'm able to set sysroot using gn args and understand there is a custom_toolchain arg I can set to a path for a toolchain definition file of some description?

Documentation seems a little lacking. Does anyone have experience compiling V8 for a builroot based project or in defining a "custom toolchain" ?

question from:https://stackoverflow.com/questions/65682118/cross-compile-v8-using-buildroot-toolchain

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...