Commit 4938c587 authored by Piotr Sikora's avatar Piotr Sikora Committed by V8 LUCI CQ

[bazel] Add support for building on riscv64.

Signed-off-by: 's avatarPiotr Sikora <piotrsikora@google.com>
Change-Id: I880b06d9b4fe37d242869ab4f18c15c28b48fb8a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3375470Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78533}
parent 2a7f1602
......@@ -297,6 +297,11 @@ v8_config(
"V8_TARGET_ARCH_S390",
"V8_TARGET_ARCH_S390X",
],
"@v8//bazel/config:v8_target_riscv64": [
# NOTE: Bazel rules for riscv64 weren't tested on a real system.
"V8_TARGET_ARCH_RISCV64",
"CAN_USE_FPU_INSTRUCTIONS",
],
},
no_match_error = "Please specify a target cpu supported by v8",
) + select({
......@@ -2230,6 +2235,34 @@ filegroup(
"src/regexp/s390/regexp-macro-assembler-s390.h",
"src/wasm/baseline/s390/liftoff-assembler-s390.h",
],
"@v8//bazel/config:v8_target_riscv64": [
"src/baseline/riscv64/baseline-assembler-riscv64-inl.h",
"src/baseline/riscv64/baseline-compiler-riscv64-inl.h",
"src/codegen/riscv64/assembler-riscv64.cc",
"src/codegen/riscv64/assembler-riscv64.h",
"src/codegen/riscv64/assembler-riscv64-inl.h",
"src/codegen/riscv64/constants-riscv64.cc",
"src/codegen/riscv64/constants-riscv64.h",
"src/codegen/riscv64/cpu-riscv64.cc",
"src/codegen/riscv64/interface-descriptors-riscv64-inl.h",
"src/codegen/riscv64/macro-assembler-riscv64.cc",
"src/codegen/riscv64/macro-assembler-riscv64.h",
"src/codegen/riscv64/register-riscv64.h",
"src/compiler/backend/riscv64/code-generator-riscv64.cc",
"src/compiler/backend/riscv64/instruction-codes-riscv64.h",
"src/compiler/backend/riscv64/instruction-scheduler-riscv64.cc",
"src/compiler/backend/riscv64/instruction-selector-riscv64.cc",
"src/deoptimizer/riscv64/deoptimizer-riscv64.cc",
"src/diagnostics/riscv64/disasm-riscv64.cc",
"src/diagnostics/riscv64/unwinder-riscv64.cc",
"src/execution/riscv64/frame-constants-riscv64.cc",
"src/execution/riscv64/frame-constants-riscv64.h",
"src/execution/riscv64/simulator-riscv64.cc",
"src/execution/riscv64/simulator-riscv64.h",
"src/regexp/riscv64/regexp-macro-assembler-riscv64.cc",
"src/regexp/riscv64/regexp-macro-assembler-riscv64.h",
"src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h",
],
}) + select({
# Only for x64 builds and for arm64 with x64 host simulator.
"@v8//bazel/config:is_posix_x64": [
......@@ -2744,6 +2777,7 @@ filegroup(
"@v8//bazel/config:v8_target_arm": ["src/builtins/arm/builtins-arm.cc"],
"@v8//bazel/config:v8_target_arm64": ["src/builtins/arm64/builtins-arm64.cc"],
"@v8//bazel/config:v8_target_s390x": ["src/builtins/s390/builtins-s390.cc"],
"@v8//bazel/config:v8_target_riscv64": ["src/builtins/riscv64/builtins-riscv64.cc"],
}) + select({
":is_v8_enable_webassembly": [
"src/builtins/builtins-wasm-gen.cc",
......@@ -2865,6 +2899,7 @@ filegroup(
"@v8//bazel/config:is_inline_asm_arm": ["src/heap/base/asm/arm/push_registers_asm.cc"],
"@v8//bazel/config:is_inline_asm_arm64": ["src/heap/base/asm/arm64/push_registers_asm.cc"],
"@v8//bazel/config:is_inline_asm_s390x": ["src/heap/base/asm/s390/push_registers_asm.cc"],
"@v8//bazel/config:is_inline_asm_riscv64": ["src/heap/base/asm/riscv64/push_registers_asm.cc"],
"@v8//bazel/config:is_msvc_asm_ia32": ["src/heap/base/asm/ia32/push_registers_masm.S"],
"@v8//bazel/config:is_msvc_asm_x64": ["src/heap/base/asm/x64/push_registers_masm.S"],
"@v8//bazel/config:is_msvc_asm_arm64": ["src/heap/base/asm/arm64/push_registers_masm.S"],
......
......@@ -54,6 +54,11 @@ config_setting(
constraint_values = ["@platforms//cpu:s390x"],
)
config_setting(
name = "platform_cpu_riscv64",
constraint_values = ["@platforms//cpu:riscv64"],
)
v8_target_cpu(
name = "v8_target_cpu",
build_setting_default = "none",
......@@ -91,6 +96,11 @@ v8_configure_target_cpu(
matching_configs = [":platform_cpu_s390x"],
)
v8_configure_target_cpu(
name = "riscv64",
matching_configs = [":platform_cpu_riscv64"],
)
selects.config_setting_group(
name = "v8_target_is_32_bits",
match_any = [
......@@ -135,6 +145,7 @@ selects.config_setting_group(
":is_x64",
":is_arm64",
":is_s390x",
":is_riscv64",
],
)
......@@ -188,6 +199,11 @@ selects.config_setting_group(
match_all = [":is_posix", ":is_s390x"],
)
selects.config_setting_group(
name = "is_inline_asm_riscv64",
match_all = [":is_posix", ":is_riscv64"],
)
selects.config_setting_group(
name = "is_msvc_asm_x64",
match_all = [":is_windows", ":is_x64"],
......
......@@ -14,7 +14,7 @@ V8CpuTypeInfo = provider(
)
def _host_target_cpu_impl(ctx):
allowed_values = ["arm", "arm64", "ia32", "s390x", "x64", "none"]
allowed_values = ["arm", "arm64", "ia32", "riscv64", "s390x", "x64", "none"]
cpu_type = ctx.build_setting_value
if cpu_type in allowed_values:
return V8CpuTypeInfo(value = cpu_type)
......
......@@ -384,6 +384,7 @@ def _v8_target_cpu_transition_impl(settings, attr):
"arm": "arm64",
"armeabi-v7a": "arm32",
"s390x": "s390x",
"riscv64": "riscv64",
}
v8_target_cpu = mapping[settings["//command_line_option:cpu"]]
return {"@v8//bazel/config:v8_target_cpu": v8_target_cpu}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment