v8: Explicitly set v8_snapshot_toolchain to host_toolchain when host_cpu == target_cpu

For x64 hosts, this already implicitly happened. For x64 hosts, this
doesn't change behavior, but it changes where in the gni file this
happens.

Now it also happens for arm64. The motivation is to be able to
cross-build chrome/win/arm64 on an arm64 mac host.

Bug: chromium:1382256
Change-Id: If995cdd3b21825e522a45fec5d273f9666509ee6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4013561
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84134}
This commit is contained in:
Nico Weber 2022-11-08 09:38:16 -05:00 committed by V8 LUCI CQ
parent d045209c4d
commit 58f7f33a8e

View File

@ -65,15 +65,21 @@ if (v8_snapshot_toolchain == "") {
# therefore snapshots will need to be built using native mksnapshot
# in combination with qemu
v8_snapshot_toolchain = current_toolchain
} else if (host_cpu == current_cpu) {
# Cross-build from same ISA on one OS to another. For example:
# * targeting win/x64 on a linux/x64 host
# * targeting win/arm64 on a mac/arm64 host
v8_snapshot_toolchain = host_toolchain
} else if (host_cpu == "arm64" && current_cpu == "x64") {
# Cross-build from arm64 to intel (likely on an Apple Silicon mac).
v8_snapshot_toolchain =
"//build/toolchain/${host_os}:clang_arm64_v8_$v8_current_cpu"
} else if (host_cpu == "x64") {
# This is a cross-compile from an x64 host to either a non-Intel target
# cpu or a different target OS.
# cpu or to 32-bit x86 on a different target OS.
if (v8_current_cpu == "x64" || v8_current_cpu == "x86") {
assert(v8_current_cpu != "x64", "handled by host_cpu == current_cpu branch")
if (v8_current_cpu == "x86") {
_cpus = v8_current_cpu
} else if (v8_current_cpu == "arm64" || v8_current_cpu == "mips64el" ||
v8_current_cpu == "riscv64" || v8_current_cpu == "loong64") {