[bazel] Upstream arm64 fix

mksnapshot is compiled/ran in the host configuration (usually x64), we
need to propagate the flag (using bazel transitions) to tell mksnapshot
to generate code to a different architecture.

No-Try: true
Change-Id: I5923f5895872a8cbf2982925a545855a330c51fd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3306568
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78177}
This commit is contained in:
Victor Gomes 2021-12-01 11:28:47 +01:00 committed by V8 LUCI CQ
parent 427a67993c
commit 95a69c6bef

View File

@ -329,6 +329,29 @@ def v8_torque(name, noicu_srcs, icu_srcs, args, extras):
}), }),
) )
def _v8_target_cpu_transition_impl(settings, attr):
mapping = {
"haswell": "x64",
"k8": "x64",
"x86_64": "x64",
"darwin_x86_64": "x64",
"x86": "ia32",
"ppc": "ppc64",
"arm64-v8a": "arm64",
"arm": "arm64",
"armeabi-v7a": "arm32",
}
v8_target_cpu = mapping[settings["//command_line_option:cpu"]]
return {"@config//:v8_target_cpu": v8_target_cpu}
# Set the v8_target_cpu to be the correct architecture given the cpu specified
# on the command line.
v8_target_cpu_transition = transition(
implementation = _v8_target_cpu_transition_impl,
inputs = ["//command_line_option:cpu"],
outputs = ["@config//:v8_target_cpu"],
)
def _mksnapshot(ctx): def _mksnapshot(ctx):
outs = [ outs = [
ctx.actions.declare_file(ctx.attr.prefix + "/snapshot.cc"), ctx.actions.declare_file(ctx.attr.prefix + "/snapshot.cc"),
@ -359,8 +382,12 @@ _v8_mksnapshot = rule(
executable = True, executable = True,
cfg = "exec", cfg = "exec",
), ),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
"prefix": attr.string(mandatory = True), "prefix": attr.string(mandatory = True),
}, },
cfg = v8_target_cpu_transition,
) )
def v8_mksnapshot(name, args): def v8_mksnapshot(name, args):