[bazel] Upstream BUILD and create config pkg
- Upstream changes made by BUILD and defs.bzl - Creates a new config package, since configurations targets are different between bazel and blaze - Runs buildifier in all files No-Try: true Change-Id: I65a1bc94a76b79eb26a348baf11eef4249be9552 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3250637 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Victor Gomes <victorgomes@chromium.org> Auto-Submit: Victor Gomes <victorgomes@chromium.org> Cr-Commit-Position: refs/heads/main@{#77597}
This commit is contained in:
parent
392078fb83
commit
715d5a3a46
830
BUILD.bazel
830
BUILD.bazel
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,12 @@ http_archive(
|
|||||||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||||
bazel_skylib_workspace()
|
bazel_skylib_workspace()
|
||||||
|
|
||||||
|
new_local_repository(
|
||||||
|
name = "config",
|
||||||
|
path = "bazel/config",
|
||||||
|
build_file = "bazel/config/BUILD.bazel",
|
||||||
|
)
|
||||||
|
|
||||||
new_local_repository(
|
new_local_repository(
|
||||||
name = "zlib",
|
name = "zlib",
|
||||||
path = "third_party/zlib",
|
path = "third_party/zlib",
|
||||||
|
@ -26,7 +26,6 @@ cc_library(
|
|||||||
"U_ENABLE_RESOURCE_TRACING=0",
|
"U_ENABLE_RESOURCE_TRACING=0",
|
||||||
"UNISTR_FROM_STRING_EXPLICIT=",
|
"UNISTR_FROM_STRING_EXPLICIT=",
|
||||||
"UNISTR_FROM_CHAR_EXPLICIT=",
|
"UNISTR_FROM_CHAR_EXPLICIT=",
|
||||||
"ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
|
|
||||||
],
|
],
|
||||||
copts = [
|
copts = [
|
||||||
"-Wno-unused-function",
|
"-Wno-unused-function",
|
||||||
|
109
bazel/config/BUILD.bazel
Normal file
109
bazel/config/BUILD.bazel
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
# Copyright 2021 the V8 project authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||||
|
load(
|
||||||
|
":v8-target-cpu.bzl",
|
||||||
|
"v8_configure_target_cpu",
|
||||||
|
"v8_target_cpu",
|
||||||
|
)
|
||||||
|
|
||||||
|
package(
|
||||||
|
default_visibility = [
|
||||||
|
"//visibility:public",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "platform_cpu_x64",
|
||||||
|
constraint_values = ["@platforms//cpu:x86_64"],
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "platform_cpu_ia32",
|
||||||
|
constraint_values = ["@platforms//cpu:x86_32"],
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "platform_cpu_arm64",
|
||||||
|
constraint_values = ["@platforms//cpu:arm"],
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "platform_cpu_arm",
|
||||||
|
constraint_values = ["@platforms//cpu:arm"],
|
||||||
|
)
|
||||||
|
|
||||||
|
v8_target_cpu(
|
||||||
|
name = "v8_target_cpu",
|
||||||
|
build_setting_default = "none",
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "v8_host_target_is_none",
|
||||||
|
flag_values = {
|
||||||
|
":v8_target_cpu": "none",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
v8_configure_target_cpu(
|
||||||
|
name = "x64",
|
||||||
|
matching_configs = [":platform_cpu_x64"],
|
||||||
|
)
|
||||||
|
|
||||||
|
v8_configure_target_cpu(
|
||||||
|
name = "ia32",
|
||||||
|
matching_configs = [":platform_cpu_ia32"],
|
||||||
|
)
|
||||||
|
|
||||||
|
v8_configure_target_cpu(
|
||||||
|
name = "arm",
|
||||||
|
matching_configs = [":platform_cpu_arm64"],
|
||||||
|
)
|
||||||
|
|
||||||
|
v8_configure_target_cpu(
|
||||||
|
name = "arm64",
|
||||||
|
matching_configs = [":platform_cpu_arm"],
|
||||||
|
)
|
||||||
|
|
||||||
|
selects.config_setting_group(
|
||||||
|
name = "v8_target_is_32_bits",
|
||||||
|
match_any = [
|
||||||
|
":v8_target_ia32",
|
||||||
|
":v8_target_arm",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Running arm64 simulator on x64 host.
|
||||||
|
selects.config_setting_group(
|
||||||
|
name = "v8_arm64_simulator",
|
||||||
|
match_all = [
|
||||||
|
":v8_target_arm64",
|
||||||
|
":is_x64",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "is_linux",
|
||||||
|
constraint_values = ["@platforms//os:linux"],
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "is_android",
|
||||||
|
constraint_values = ["@platforms//os:android"],
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "is_macos",
|
||||||
|
constraint_values = ["@platforms//os:macos"],
|
||||||
|
)
|
||||||
|
|
||||||
|
selects.config_setting_group(
|
||||||
|
name = "is_posix",
|
||||||
|
match_any = [
|
||||||
|
":is_linux",
|
||||||
|
":is_android",
|
||||||
|
":is_macos",
|
||||||
|
],
|
||||||
|
)
|
61
bazel/config/v8-target-cpu.bzl
Normal file
61
bazel/config/v8-target-cpu.bzl
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# Copyright 2021 the V8 project authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
"""Build rules to choose the v8 target architecture."""
|
||||||
|
|
||||||
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||||
|
|
||||||
|
V8CpuTypeInfo = provider(
|
||||||
|
doc = "A singleton provider that specifies the V8 target CPU type",
|
||||||
|
fields = {
|
||||||
|
"value": "The V8 Target CPU selected.",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
def _host_target_cpu_impl(ctx):
|
||||||
|
allowed_values = ["arm", "arm64", "ia32", "x64", "none"]
|
||||||
|
cpu_type = ctx.build_setting_value
|
||||||
|
if cpu_type in allowed_values:
|
||||||
|
return V8CpuTypeInfo(value = cpu_type)
|
||||||
|
else:
|
||||||
|
fail("Error setting " + str(ctx.label) + ": invalid v8 target cpu '" +
|
||||||
|
cpu_type + "'. Allowed values are " + str(allowed_values))
|
||||||
|
|
||||||
|
v8_target_cpu = rule(
|
||||||
|
implementation = _host_target_cpu_impl,
|
||||||
|
build_setting = config.string(flag = True),
|
||||||
|
doc = "CPU that V8 will generate code for.",
|
||||||
|
)
|
||||||
|
|
||||||
|
def v8_configure_target_cpu(name, matching_configs):
|
||||||
|
selects.config_setting_group(
|
||||||
|
name = "is_" + name,
|
||||||
|
match_any = matching_configs,
|
||||||
|
)
|
||||||
|
|
||||||
|
# If v8_target_cpu flag is set to 'name'
|
||||||
|
native.config_setting(
|
||||||
|
name = "v8_host_target_is_" + name,
|
||||||
|
flag_values = {
|
||||||
|
":v8_target_cpu": name,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
# Default target if no v8_host_target flag is set.
|
||||||
|
selects.config_setting_group(
|
||||||
|
name = "v8_target_is_" + name,
|
||||||
|
match_all = [
|
||||||
|
":v8_host_target_is_none",
|
||||||
|
":is_" + name,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Select either the default target or the flag.
|
||||||
|
selects.config_setting_group(
|
||||||
|
name = "v8_target_" + name,
|
||||||
|
match_any = [
|
||||||
|
":v8_host_target_is_" + name,
|
||||||
|
":v8_target_is_" + name,
|
||||||
|
],
|
||||||
|
)
|
241
bazel/defs.bzl
241
bazel/defs.bzl
@ -22,10 +22,6 @@ _create_option_int = rule(
|
|||||||
build_setting = config.int(flag = True),
|
build_setting = config.int(flag = True),
|
||||||
)
|
)
|
||||||
|
|
||||||
def v8_raw_flag(name, default = False):
|
|
||||||
_create_option_flag(name = name, build_setting_default = default)
|
|
||||||
native.config_setting(name = "raw_" + name, flag_values = {name: "True"})
|
|
||||||
|
|
||||||
def v8_flag(name, default = False):
|
def v8_flag(name, default = False):
|
||||||
_create_option_flag(name = name, build_setting_default = default)
|
_create_option_flag(name = name, build_setting_default = default)
|
||||||
native.config_setting(name = "is_" + name, flag_values = {name: "True"})
|
native.config_setting(name = "is_" + name, flag_values = {name: "True"})
|
||||||
@ -40,28 +36,30 @@ def v8_int(name, default = 0):
|
|||||||
def _custom_config_impl(ctx):
|
def _custom_config_impl(ctx):
|
||||||
defs = []
|
defs = []
|
||||||
defs.append("V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=" +
|
defs.append("V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=" +
|
||||||
str(ctx.attr._v8_typed_array_max_size_in_heap[FlagInfo].value))
|
str(ctx.attr._v8_typed_array_max_size_in_heap[FlagInfo].value))
|
||||||
context = cc_common.create_compilation_context(defines = depset(defs))
|
context = cc_common.create_compilation_context(defines = depset(defs))
|
||||||
return [CcInfo(compilation_context = context)]
|
return [CcInfo(compilation_context = context)]
|
||||||
|
|
||||||
v8_custom_config = rule(
|
v8_custom_config = rule(
|
||||||
implementation = _custom_config_impl,
|
implementation = _custom_config_impl,
|
||||||
attrs = {
|
attrs = {
|
||||||
"_v8_typed_array_max_size_in_heap":
|
"_v8_typed_array_max_size_in_heap": attr.label(default = ":v8_typed_array_max_size_in_heap"),
|
||||||
attr.label(default = ":v8_typed_array_max_size_in_heap"),
|
},
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _config_impl(ctx):
|
def _config_impl(ctx):
|
||||||
hdrs = []
|
hdrs = []
|
||||||
|
|
||||||
# Add headers
|
# Add headers
|
||||||
for h in ctx.attr.hdrs:
|
for h in ctx.attr.hdrs:
|
||||||
hdrs += h[DefaultInfo].files.to_list()
|
hdrs += h[DefaultInfo].files.to_list()
|
||||||
defs = []
|
defs = []
|
||||||
|
|
||||||
# Add conditional_defines
|
# Add conditional_defines
|
||||||
for f, d in ctx.attr.conditional_defines.items():
|
for f, d in ctx.attr.conditional_defines.items():
|
||||||
if f[FlagInfo].value:
|
if f[FlagInfo].value:
|
||||||
defs.append(d)
|
defs.append(d)
|
||||||
|
|
||||||
# Add defines
|
# Add defines
|
||||||
for d in ctx.attr.defines:
|
for d in ctx.attr.defines:
|
||||||
defs.append(d)
|
defs.append(d)
|
||||||
@ -87,9 +85,9 @@ v8_config = rule(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
def _default_args(configs):
|
def _default_args():
|
||||||
return struct(
|
return struct(
|
||||||
deps = configs + [":define_flags"],
|
deps = [":define_flags"],
|
||||||
copts = [
|
copts = [
|
||||||
"-fPIC",
|
"-fPIC",
|
||||||
"-Werror",
|
"-Werror",
|
||||||
@ -105,140 +103,248 @@ def _default_args(configs):
|
|||||||
],
|
],
|
||||||
includes = ["include"],
|
includes = ["include"],
|
||||||
linkopts = [
|
linkopts = [
|
||||||
"-pthread"
|
"-pthread",
|
||||||
] + select({
|
] + select({
|
||||||
":is_macos": [],
|
"@v8//bazel/config:is_macos": [],
|
||||||
"//conditions:default": [ "-Wl,--no-as-needed -ldl" ],
|
"//conditions:default": ["-Wl,--no-as-needed -ldl"],
|
||||||
}) + select({
|
}) + select({
|
||||||
":should_add_rdynamic": [ "-rdynamic" ],
|
":should_add_rdynamic": ["-rdynamic"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ENABLE_I18N_SUPPORT_DEFINES = [
|
||||||
|
"-DV8_INTL_SUPPORT",
|
||||||
|
"-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC",
|
||||||
|
# src/regexp/regexp-compiler-tonode.cc uses an unsafe ICU method and
|
||||||
|
# access a character implicitly.
|
||||||
|
"-DUNISTR_FROM_CHAR_EXPLICIT=",
|
||||||
|
]
|
||||||
|
|
||||||
|
def _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, icu_srcs, icu_deps):
|
||||||
|
return noicu_srcs != [] or noicu_deps != [] or icu_srcs != [] or icu_deps != []
|
||||||
|
|
||||||
|
# buildifier: disable=function-docstring
|
||||||
def v8_binary(
|
def v8_binary(
|
||||||
name,
|
name,
|
||||||
srcs,
|
srcs,
|
||||||
configs = [],
|
|
||||||
deps = [],
|
deps = [],
|
||||||
includes = [],
|
includes = [],
|
||||||
copts = [],
|
copts = [],
|
||||||
linkopts = [],
|
linkopts = [],
|
||||||
|
noicu_srcs = [],
|
||||||
|
noicu_deps = [],
|
||||||
|
icu_srcs = [],
|
||||||
|
icu_deps = [],
|
||||||
**kwargs):
|
**kwargs):
|
||||||
default = _default_args(configs)
|
default = _default_args()
|
||||||
native.cc_binary(
|
if _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, icu_srcs, icu_deps):
|
||||||
name = name,
|
native.cc_binary(
|
||||||
srcs = srcs,
|
name = "noicu/" + name,
|
||||||
deps = deps + default.deps,
|
srcs = srcs + noicu_srcs,
|
||||||
includes = includes + default.includes,
|
deps = deps + noicu_deps + default.deps,
|
||||||
copts = copts + default.copts,
|
includes = includes + default.includes,
|
||||||
linkopts = linkopts + default.linkopts,
|
copts = copts + default.copts,
|
||||||
**kwargs
|
linkopts = linkopts + default.linkopts,
|
||||||
)
|
**kwargs
|
||||||
|
)
|
||||||
|
native.cc_binary(
|
||||||
|
name = "icu/" + name,
|
||||||
|
srcs = srcs + icu_srcs,
|
||||||
|
deps = deps + icu_deps + default.deps,
|
||||||
|
includes = includes + default.includes,
|
||||||
|
copts = copts + default.copts + ENABLE_I18N_SUPPORT_DEFINES,
|
||||||
|
linkopts = linkopts + default.linkopts,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
native.cc_binary(
|
||||||
|
name = name,
|
||||||
|
srcs = srcs,
|
||||||
|
deps = deps + default.deps,
|
||||||
|
includes = includes + default.includes,
|
||||||
|
copts = copts + default.copts,
|
||||||
|
linkopts = linkopts + default.linkopts,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
# buildifier: disable=function-docstring
|
||||||
def v8_library(
|
def v8_library(
|
||||||
name,
|
name,
|
||||||
srcs,
|
srcs,
|
||||||
configs = [],
|
|
||||||
deps = [],
|
deps = [],
|
||||||
includes = [],
|
includes = [],
|
||||||
copts = [],
|
copts = [],
|
||||||
linkopts = [],
|
linkopts = [],
|
||||||
|
noicu_srcs = [],
|
||||||
|
noicu_deps = [],
|
||||||
|
icu_srcs = [],
|
||||||
|
icu_deps = [],
|
||||||
**kwargs):
|
**kwargs):
|
||||||
default = _default_args(configs)
|
default = _default_args()
|
||||||
native.cc_library(
|
if _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, icu_srcs, icu_deps):
|
||||||
name = name,
|
native.cc_library(
|
||||||
srcs = srcs,
|
name = "noicu/" + name,
|
||||||
deps = deps + default.deps,
|
srcs = srcs + noicu_srcs,
|
||||||
includes = includes + default.includes,
|
deps = deps + noicu_deps + default.deps,
|
||||||
copts = copts + default.copts,
|
includes = includes + default.includes,
|
||||||
linkopts = linkopts + default.linkopts,
|
copts = copts + default.copts,
|
||||||
alwayslink = 1,
|
linkopts = linkopts + default.linkopts,
|
||||||
**kwargs
|
alwayslink = 1,
|
||||||
)
|
**kwargs
|
||||||
|
)
|
||||||
|
native.cc_library(
|
||||||
|
name = "icu/" + name,
|
||||||
|
srcs = srcs + icu_srcs,
|
||||||
|
deps = deps + icu_deps + default.deps,
|
||||||
|
includes = includes + default.includes,
|
||||||
|
copts = copts + default.copts + ENABLE_I18N_SUPPORT_DEFINES,
|
||||||
|
linkopts = linkopts + default.linkopts,
|
||||||
|
alwayslink = 1,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
native.cc_library(
|
||||||
|
name = name,
|
||||||
|
srcs = srcs,
|
||||||
|
deps = deps + default.deps,
|
||||||
|
includes = includes + default.includes,
|
||||||
|
copts = copts + default.copts,
|
||||||
|
linkopts = linkopts + default.linkopts,
|
||||||
|
alwayslink = 1,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
||||||
def _torque_impl(ctx):
|
def _torque_impl(ctx):
|
||||||
v8root = ctx.attr.v8root[FlagInfo].value
|
v8root = "."
|
||||||
|
prefix = ctx.attr.prefix
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
args = []
|
args = []
|
||||||
args += ctx.attr.args
|
args += ctx.attr.args
|
||||||
args.append("-o")
|
args.append("-o")
|
||||||
args.append(ctx.bin_dir.path + "/torque-generated")
|
args.append(ctx.bin_dir.path + "/" + v8root + "/" + ctx.attr.prefix + "/torque-generated")
|
||||||
args.append("-strip-v8-root")
|
args.append("-strip-v8-root")
|
||||||
args.append("-v8-root")
|
args.append("-v8-root")
|
||||||
args.append(v8root)
|
args.append(v8root)
|
||||||
|
|
||||||
# Sources
|
# Sources
|
||||||
args += [f.path for f in ctx.files.srcs]
|
args += [f.path for f in ctx.files.srcs]
|
||||||
|
|
||||||
# Generate/declare output files
|
# Generate/declare output files
|
||||||
outs = []
|
outs = []
|
||||||
for src in ctx.files.srcs:
|
for src in ctx.files.srcs:
|
||||||
root, period, ext = src.path.rpartition(".")
|
root, period, ext = src.path.rpartition(".")
|
||||||
|
|
||||||
# Strip v8root
|
# Strip v8root
|
||||||
if root[:len(v8root)] == v8root:
|
if root[:len(v8root)] == v8root:
|
||||||
root = root[len(v8root):]
|
root = root[len(v8root):]
|
||||||
file = "torque-generated/" + root
|
file = ctx.attr.prefix + "/torque-generated/" + root
|
||||||
outs.append(ctx.actions.declare_file(file + "-tq-csa.cc"))
|
outs.append(ctx.actions.declare_file(file + "-tq-csa.cc"))
|
||||||
outs.append(ctx.actions.declare_file(file + "-tq-csa.h"))
|
outs.append(ctx.actions.declare_file(file + "-tq-csa.h"))
|
||||||
outs.append(ctx.actions.declare_file(file + "-tq-inl.inc"))
|
outs.append(ctx.actions.declare_file(file + "-tq-inl.inc"))
|
||||||
outs.append(ctx.actions.declare_file(file + "-tq.inc"))
|
outs.append(ctx.actions.declare_file(file + "-tq.inc"))
|
||||||
outs.append(ctx.actions.declare_file(file + "-tq.cc"))
|
outs.append(ctx.actions.declare_file(file + "-tq.cc"))
|
||||||
outs += [ctx.actions.declare_file("torque-generated/" + f) for f in ctx.attr.extras]
|
outs += [ctx.actions.declare_file(ctx.attr.prefix + "/torque-generated/" + f) for f in ctx.attr.extras]
|
||||||
ctx.actions.run(
|
ctx.actions.run(
|
||||||
outputs = outs,
|
outputs = outs,
|
||||||
inputs = ctx.files.srcs,
|
inputs = ctx.files.srcs,
|
||||||
arguments = args,
|
arguments = args,
|
||||||
executable = ctx.executable.tool,
|
executable = ctx.executable.tool,
|
||||||
|
mnemonic = "GenTorque",
|
||||||
progress_message = "Generating Torque files",
|
progress_message = "Generating Torque files",
|
||||||
)
|
)
|
||||||
return [DefaultInfo(files = depset(outs))]
|
return [DefaultInfo(files = depset(outs))]
|
||||||
|
|
||||||
v8_torque = rule(
|
_v8_torque = rule(
|
||||||
implementation = _torque_impl,
|
implementation = _torque_impl,
|
||||||
|
# cfg = v8_target_cpu_transition,
|
||||||
attrs = {
|
attrs = {
|
||||||
|
"prefix": attr.string(mandatory = True),
|
||||||
"srcs": attr.label_list(allow_files = True, mandatory = True),
|
"srcs": attr.label_list(allow_files = True, mandatory = True),
|
||||||
"extras": attr.string_list(),
|
"extras": attr.string_list(),
|
||||||
"tool": attr.label(
|
"tool": attr.label(
|
||||||
default = ":torque",
|
|
||||||
allow_files = True,
|
allow_files = True,
|
||||||
executable = True,
|
executable = True,
|
||||||
cfg = "host",
|
cfg = "exec",
|
||||||
),
|
),
|
||||||
"args": attr.string_list(),
|
"args": attr.string_list(),
|
||||||
"v8root": attr.label(default = ":v8_root"),
|
"v8root": attr.label(default = ":v8_root"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def v8_torque(name, noicu_srcs, icu_srcs, args, extras):
|
||||||
|
_v8_torque(
|
||||||
|
name = "noicu/" + name,
|
||||||
|
prefix = "noicu",
|
||||||
|
srcs = noicu_srcs,
|
||||||
|
args = args,
|
||||||
|
extras = extras,
|
||||||
|
tool = select({
|
||||||
|
"@config//:v8_target_is_32_bits": ":torque_non_pointer_compression",
|
||||||
|
"//conditions:default": ":torque",
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
_v8_torque(
|
||||||
|
name = "icu/" + name,
|
||||||
|
prefix = "icu",
|
||||||
|
srcs = icu_srcs,
|
||||||
|
args = args,
|
||||||
|
extras = extras,
|
||||||
|
tool = select({
|
||||||
|
"@config//:v8_target_is_32_bits": ":torque_non_pointer_compression",
|
||||||
|
"//conditions:default": ":torque",
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
def _mksnapshot(ctx):
|
def _mksnapshot(ctx):
|
||||||
outs = [
|
outs = [
|
||||||
ctx.actions.declare_file("snapshot.cc"),
|
ctx.actions.declare_file(ctx.attr.prefix + "/snapshot.cc"),
|
||||||
ctx.actions.declare_file("embedded.S"),
|
ctx.actions.declare_file(ctx.attr.prefix + "/embedded.S"),
|
||||||
]
|
]
|
||||||
ctx.actions.run(
|
ctx.actions.run(
|
||||||
outputs = outs,
|
outputs = outs,
|
||||||
inputs = [],
|
inputs = [],
|
||||||
arguments = [
|
arguments = [
|
||||||
"--embedded_variant=Default",
|
"--embedded_variant=Default",
|
||||||
"--startup_src", outs[0].path,
|
"--startup_src",
|
||||||
"--embedded_src", outs[1].path,
|
outs[0].path,
|
||||||
|
"--embedded_src",
|
||||||
|
outs[1].path,
|
||||||
] + ctx.attr.args,
|
] + ctx.attr.args,
|
||||||
executable = ctx.executable.tool,
|
executable = ctx.executable.tool,
|
||||||
progress_message = "Running mksnapshot"
|
progress_message = "Running mksnapshot",
|
||||||
)
|
)
|
||||||
return [DefaultInfo(files = depset(outs))]
|
return [DefaultInfo(files = depset(outs))]
|
||||||
|
|
||||||
|
_v8_mksnapshot = rule(
|
||||||
v8_mksnapshot = rule(
|
|
||||||
implementation = _mksnapshot,
|
implementation = _mksnapshot,
|
||||||
attrs = {
|
attrs = {
|
||||||
"args": attr.string_list(),
|
"args": attr.string_list(),
|
||||||
"tool": attr.label(
|
"tool": attr.label(
|
||||||
default = ":mksnapshot",
|
mandatory = True,
|
||||||
allow_files = True,
|
allow_files = True,
|
||||||
executable = True,
|
executable = True,
|
||||||
cfg = "host",
|
cfg = "exec",
|
||||||
),
|
),
|
||||||
}
|
"prefix": attr.string(mandatory = True),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def v8_mksnapshot(name, args):
|
||||||
|
_v8_mksnapshot(
|
||||||
|
name = "noicu/" + name,
|
||||||
|
args = args,
|
||||||
|
prefix = "noicu",
|
||||||
|
tool = ":noicu/mksnapshot",
|
||||||
|
)
|
||||||
|
_v8_mksnapshot(
|
||||||
|
name = "icu/" + name,
|
||||||
|
args = args,
|
||||||
|
prefix = "icu",
|
||||||
|
tool = ":icu/mksnapshot",
|
||||||
|
)
|
||||||
|
|
||||||
def _quote(val):
|
def _quote(val):
|
||||||
if val[0] == '"' and val[-1] == '"':
|
if val[0] == '"' and val[-1] == '"':
|
||||||
fail("String", val, "already quoted")
|
fail("String", val, "already quoted")
|
||||||
@ -256,11 +362,8 @@ def _json(kv_pairs):
|
|||||||
content += "}\n"
|
content += "}\n"
|
||||||
return content
|
return content
|
||||||
|
|
||||||
# TODO(victorgomes): Create a rule (instead of a macro), that can
|
def build_config_content(cpu, icu):
|
||||||
# dynamically populate the build config.
|
return _json([
|
||||||
def v8_build_config(name):
|
|
||||||
cpu = _quote("x64")
|
|
||||||
content = _json([
|
|
||||||
("current_cpu", cpu),
|
("current_cpu", cpu),
|
||||||
("dcheck_always_on", "false"),
|
("dcheck_always_on", "false"),
|
||||||
("is_android", "false"),
|
("is_android", "false"),
|
||||||
@ -276,10 +379,11 @@ def v8_build_config(name):
|
|||||||
("is_ubsan_vptr", "false"),
|
("is_ubsan_vptr", "false"),
|
||||||
("target_cpu", cpu),
|
("target_cpu", cpu),
|
||||||
("v8_current_cpu", cpu),
|
("v8_current_cpu", cpu),
|
||||||
|
("v8_dict_property_const_tracking", "false"),
|
||||||
("v8_enable_atomic_marking_state", "false"),
|
("v8_enable_atomic_marking_state", "false"),
|
||||||
("v8_enable_atomic_object_field_writes", "false"),
|
("v8_enable_atomic_object_field_writes", "false"),
|
||||||
("v8_enable_concurrent_marking", "false"),
|
("v8_enable_concurrent_marking", "false"),
|
||||||
("v8_enable_i18n_support", "true"),
|
("v8_enable_i18n_support", icu),
|
||||||
("v8_enable_verify_predictable", "false"),
|
("v8_enable_verify_predictable", "false"),
|
||||||
("v8_enable_verify_csa", "false"),
|
("v8_enable_verify_csa", "false"),
|
||||||
("v8_enable_lite_mode", "false"),
|
("v8_enable_lite_mode", "false"),
|
||||||
@ -290,10 +394,21 @@ def v8_build_config(name):
|
|||||||
("v8_enable_webassembly", "false"),
|
("v8_enable_webassembly", "false"),
|
||||||
("v8_control_flow_integrity", "false"),
|
("v8_control_flow_integrity", "false"),
|
||||||
("v8_enable_single_generation", "false"),
|
("v8_enable_single_generation", "false"),
|
||||||
|
("v8_enable_virtual_memory_cage", "false"),
|
||||||
("v8_target_cpu", cpu),
|
("v8_target_cpu", cpu),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# TODO(victorgomes): Create a rule (instead of a macro), that can
|
||||||
|
# dynamically populate the build config.
|
||||||
|
def v8_build_config(name):
|
||||||
|
cpu = _quote("x64")
|
||||||
native.genrule(
|
native.genrule(
|
||||||
name = name,
|
name = "noicu/" + name,
|
||||||
outs = [name + ".json"],
|
outs = ["noicu/" + name + ".json"],
|
||||||
cmd = "echo '" + content + "' > \"$@\"",
|
cmd = "echo '" + build_config_content(cpu, "false") + "' > \"$@\"",
|
||||||
|
)
|
||||||
|
native.genrule(
|
||||||
|
name = "icu/" + name,
|
||||||
|
outs = ["icu/" + name + ".json"],
|
||||||
|
cmd = "echo '" + build_config_content(cpu, "true") + "' > \"$@\"",
|
||||||
)
|
)
|
||||||
|
59
bazel/v8-non-pointer-compression.bzl
Normal file
59
bazel/v8-non-pointer-compression.bzl
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
def _v8_disable_pointer_compression(settings, attr):
|
||||||
|
return {
|
||||||
|
"//third_party/v8/HEAD:v8_enable_pointer_compression": "False",
|
||||||
|
}
|
||||||
|
|
||||||
|
v8_disable_pointer_compression = transition(
|
||||||
|
implementation = _v8_disable_pointer_compression,
|
||||||
|
inputs = [],
|
||||||
|
outputs = ["//third_party/v8/HEAD:v8_enable_pointer_compression"],
|
||||||
|
)
|
||||||
|
|
||||||
|
# The implementation of transition_rule: all this does is copy the
|
||||||
|
# cc_binary's output to its own output and propagate its runfiles
|
||||||
|
# and executable to use for "$ bazel run".
|
||||||
|
#
|
||||||
|
# This makes transition_rule as close to a pure wrapper of cc_binary
|
||||||
|
# as possible.
|
||||||
|
def _v8_binary_non_pointer_compression(ctx):
|
||||||
|
binary = ctx.attr.binary[0]
|
||||||
|
outfile = ctx.actions.declare_file(ctx.label.name)
|
||||||
|
cc_binary_outfile = binary[DefaultInfo].files.to_list()[0]
|
||||||
|
|
||||||
|
ctx.actions.run_shell(
|
||||||
|
inputs = [cc_binary_outfile],
|
||||||
|
outputs = [outfile],
|
||||||
|
command = "cp %s %s" % (cc_binary_outfile.path, outfile.path),
|
||||||
|
)
|
||||||
|
return [
|
||||||
|
DefaultInfo(
|
||||||
|
executable = outfile,
|
||||||
|
data_runfiles = binary[DefaultInfo].data_runfiles,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
# The purpose of this rule is to transition to a config where v8_target_cpu is
|
||||||
|
# set to the appropriate architecture, which will remain in place through exec
|
||||||
|
# transitions, so mksnapshot can for instance build on x64 but for arm64.
|
||||||
|
v8_binary_non_pointer_compression = rule(
|
||||||
|
implementation = _v8_binary_non_pointer_compression,
|
||||||
|
attrs = {
|
||||||
|
# This is the cc_binary whose deps will select() on that feature.
|
||||||
|
# Note specificaly how it's configured with v8_target_cpu_transition, which
|
||||||
|
# ensures that setting propagates down the graph.
|
||||||
|
"binary": attr.label(cfg = v8_disable_pointer_compression),
|
||||||
|
# This is a stock Bazel requirement for any rule that uses Starlark
|
||||||
|
# transitions. It's okay to copy the below verbatim for all such rules.
|
||||||
|
#
|
||||||
|
# The purpose of this requirement is to give the ability to restrict
|
||||||
|
# which packages can invoke these rules, since Starlark transitions
|
||||||
|
# make much larger graphs possible that can have memory and performance
|
||||||
|
# consequences for your build. The whitelist defaults to "everything".
|
||||||
|
# But you can redefine it more strictly if you feel that's prudent.
|
||||||
|
"_allowlist_function_transition": attr.label(
|
||||||
|
default = "//tools/allowlists/function_transition_allowlist",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
# Making this executable means it works with "$ bazel run".
|
||||||
|
executable = True,
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user