2021-06-15 14:09:17 +00:00
|
|
|
# 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.
|
|
|
|
|
|
|
|
FlagInfo = provider(fields = ["value"])
|
|
|
|
|
|
|
|
def _options_impl(ctx):
|
|
|
|
return FlagInfo(value = ctx.build_setting_value)
|
|
|
|
|
|
|
|
_create_option_flag = rule(
|
|
|
|
implementation = _options_impl,
|
|
|
|
build_setting = config.bool(flag = True),
|
|
|
|
)
|
|
|
|
|
|
|
|
_create_option_string = rule(
|
|
|
|
implementation = _options_impl,
|
|
|
|
build_setting = config.string(flag = True),
|
|
|
|
)
|
|
|
|
|
|
|
|
_create_option_int = rule(
|
|
|
|
implementation = _options_impl,
|
|
|
|
build_setting = config.int(flag = True),
|
|
|
|
)
|
|
|
|
|
|
|
|
def v8_flag(name, default = False):
|
|
|
|
_create_option_flag(name = name, build_setting_default = default)
|
|
|
|
native.config_setting(name = "is_" + name, flag_values = {name: "True"})
|
2021-07-12 09:56:02 +00:00
|
|
|
native.config_setting(name = "is_not_" + name, flag_values = {name: "False"})
|
2021-06-15 14:09:17 +00:00
|
|
|
|
|
|
|
def v8_string(name, default = ""):
|
|
|
|
_create_option_string(name = name, build_setting_default = default)
|
|
|
|
|
|
|
|
def v8_int(name, default = 0):
|
|
|
|
_create_option_int(name = name, build_setting_default = default)
|
|
|
|
|
|
|
|
def _custom_config_impl(ctx):
|
|
|
|
defs = []
|
|
|
|
defs.append("V8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=" +
|
2021-10-28 14:33:16 +00:00
|
|
|
str(ctx.attr._v8_typed_array_max_size_in_heap[FlagInfo].value))
|
2021-06-15 14:09:17 +00:00
|
|
|
context = cc_common.create_compilation_context(defines = depset(defs))
|
|
|
|
return [CcInfo(compilation_context = context)]
|
|
|
|
|
|
|
|
v8_custom_config = rule(
|
|
|
|
implementation = _custom_config_impl,
|
|
|
|
attrs = {
|
2021-10-28 14:33:16 +00:00
|
|
|
"_v8_typed_array_max_size_in_heap": attr.label(default = ":v8_typed_array_max_size_in_heap"),
|
|
|
|
},
|
2021-06-15 14:09:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def _config_impl(ctx):
|
|
|
|
hdrs = []
|
2021-10-28 14:33:16 +00:00
|
|
|
|
2021-06-15 14:09:17 +00:00
|
|
|
# Add headers
|
|
|
|
for h in ctx.attr.hdrs:
|
|
|
|
hdrs += h[DefaultInfo].files.to_list()
|
|
|
|
defs = []
|
2021-10-28 14:33:16 +00:00
|
|
|
|
2021-06-15 14:09:17 +00:00
|
|
|
# Add conditional_defines
|
|
|
|
for f, d in ctx.attr.conditional_defines.items():
|
|
|
|
if f[FlagInfo].value:
|
|
|
|
defs.append(d)
|
2021-10-28 14:33:16 +00:00
|
|
|
|
2021-06-15 14:09:17 +00:00
|
|
|
# Add defines
|
|
|
|
for d in ctx.attr.defines:
|
|
|
|
defs.append(d)
|
|
|
|
context = cc_common.create_compilation_context(
|
|
|
|
defines = depset(
|
|
|
|
defs,
|
|
|
|
transitive = [dep[CcInfo].compilation_context.defines for dep in ctx.attr.deps],
|
|
|
|
),
|
|
|
|
headers = depset(
|
|
|
|
hdrs,
|
|
|
|
transitive = [dep[CcInfo].compilation_context.headers for dep in ctx.attr.deps],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
return [CcInfo(compilation_context = context)]
|
|
|
|
|
|
|
|
v8_config = rule(
|
|
|
|
implementation = _config_impl,
|
|
|
|
attrs = {
|
|
|
|
"conditional_defines": attr.label_keyed_string_dict(),
|
|
|
|
"defines": attr.string_list(),
|
|
|
|
"deps": attr.label_list(),
|
|
|
|
"hdrs": attr.label_list(allow_files = True),
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-10-28 14:33:16 +00:00
|
|
|
def _default_args():
|
2021-06-15 14:09:17 +00:00
|
|
|
return struct(
|
2021-10-28 14:33:16 +00:00
|
|
|
deps = [":define_flags"],
|
2021-11-08 15:57:55 +00:00
|
|
|
defines = select({
|
2021-12-11 01:23:17 +00:00
|
|
|
"@v8//bazel/config:is_windows": [
|
2021-11-08 15:57:55 +00:00
|
|
|
"UNICODE",
|
|
|
|
"_UNICODE",
|
|
|
|
"_CRT_RAND_S",
|
2022-01-10 21:23:25 +00:00
|
|
|
"_WIN32_WINNT=0x0602", # Override bazel default to Windows 8
|
2021-11-08 15:57:55 +00:00
|
|
|
],
|
|
|
|
"//conditions:default": [],
|
|
|
|
}),
|
|
|
|
copts = select({
|
2021-12-11 01:23:17 +00:00
|
|
|
"@v8//bazel/config:is_posix": [
|
2021-11-08 15:57:55 +00:00
|
|
|
"-fPIC",
|
2022-01-04 23:22:07 +00:00
|
|
|
"-fno-strict-aliasing",
|
2021-11-08 15:57:55 +00:00
|
|
|
"-Werror",
|
|
|
|
"-Wextra",
|
2022-01-04 23:22:07 +00:00
|
|
|
"-Wno-unknown-warning-option",
|
2021-11-08 15:57:55 +00:00
|
|
|
"-Wno-bitwise-instead-of-logical",
|
|
|
|
"-Wno-builtin-assume-aligned-alignment",
|
|
|
|
"-Wno-unused-parameter",
|
|
|
|
"-Wno-implicit-int-float-conversion",
|
|
|
|
"-Wno-deprecated-copy",
|
|
|
|
"-Wno-non-virtual-dtor",
|
|
|
|
"-isystem .",
|
|
|
|
],
|
|
|
|
"//conditions:default": [],
|
2022-01-04 23:22:07 +00:00
|
|
|
}) + select({
|
|
|
|
"@v8//bazel/config:is_clang": [
|
|
|
|
"-Wno-invalid-offsetof",
|
|
|
|
"-std=c++17",
|
|
|
|
],
|
|
|
|
"@v8//bazel/config:is_gcc": [
|
|
|
|
"-Wno-extra",
|
2022-01-06 04:20:15 +00:00
|
|
|
"-Wno-array-bounds",
|
|
|
|
"-Wno-class-memaccess",
|
2022-01-04 23:22:07 +00:00
|
|
|
"-Wno-comments",
|
|
|
|
"-Wno-deprecated-declarations",
|
|
|
|
"-Wno-implicit-fallthrough",
|
2022-01-06 04:20:15 +00:00
|
|
|
"-Wno-int-in-bool-context",
|
2022-01-04 23:22:07 +00:00
|
|
|
"-Wno-maybe-uninitialized",
|
|
|
|
"-Wno-mismatched-new-delete",
|
|
|
|
"-Wno-redundant-move",
|
|
|
|
"-Wno-return-type",
|
2022-01-06 04:20:15 +00:00
|
|
|
"-Wno-stringop-overflow",
|
2022-01-04 23:22:07 +00:00
|
|
|
# Use GNU dialect, because GCC doesn't allow using
|
|
|
|
# ##__VA_ARGS__ when in standards-conforming mode.
|
|
|
|
"-std=gnu++17",
|
|
|
|
],
|
|
|
|
"@v8//bazel/config:is_windows": [
|
|
|
|
"/std:c++17",
|
|
|
|
],
|
|
|
|
"//conditions:default": [],
|
|
|
|
}) + select({
|
|
|
|
"@v8//bazel/config:is_gcc_fastbuild": [
|
|
|
|
# Non-debug builds without optimizations fail because
|
|
|
|
# of recursive inlining of "always_inline" functions.
|
|
|
|
"-O1",
|
|
|
|
],
|
|
|
|
"//conditions:default": [],
|
2022-01-09 04:24:18 +00:00
|
|
|
}) + select({
|
|
|
|
"@v8//bazel/config:is_clang_s390x": [
|
|
|
|
"-fno-integrated-as",
|
|
|
|
],
|
|
|
|
"//conditions:default": [],
|
2021-11-08 15:57:55 +00:00
|
|
|
}),
|
2021-06-15 14:09:17 +00:00
|
|
|
includes = ["include"],
|
2021-11-08 15:57:55 +00:00
|
|
|
linkopts = select({
|
2021-12-11 01:23:17 +00:00
|
|
|
"@v8//bazel/config:is_windows": [
|
2021-11-08 15:57:55 +00:00
|
|
|
"Winmm.lib",
|
|
|
|
"DbgHelp.lib",
|
|
|
|
"Advapi32.lib",
|
|
|
|
],
|
2021-12-11 01:23:17 +00:00
|
|
|
"@v8//bazel/config:is_macos": ["-pthread"],
|
2021-11-08 15:57:55 +00:00
|
|
|
"//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"],
|
2021-07-12 10:15:51 +00:00
|
|
|
}) + select({
|
2021-10-28 14:33:16 +00:00
|
|
|
":should_add_rdynamic": ["-rdynamic"],
|
2021-07-12 10:15:51 +00:00
|
|
|
"//conditions:default": [],
|
2021-06-24 17:46:11 +00:00
|
|
|
}),
|
2021-06-15 14:09:17 +00:00
|
|
|
)
|
|
|
|
|
2021-10-28 14:33:16 +00:00
|
|
|
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
|
2021-06-15 14:09:17 +00:00
|
|
|
def v8_binary(
|
|
|
|
name,
|
|
|
|
srcs,
|
|
|
|
deps = [],
|
|
|
|
includes = [],
|
|
|
|
copts = [],
|
|
|
|
linkopts = [],
|
2021-10-28 14:33:16 +00:00
|
|
|
noicu_srcs = [],
|
|
|
|
noicu_deps = [],
|
|
|
|
icu_srcs = [],
|
|
|
|
icu_deps = [],
|
2021-06-15 14:09:17 +00:00
|
|
|
**kwargs):
|
2021-10-28 14:33:16 +00:00
|
|
|
default = _default_args()
|
|
|
|
if _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, icu_srcs, icu_deps):
|
|
|
|
native.cc_binary(
|
|
|
|
name = "noicu/" + name,
|
|
|
|
srcs = srcs + noicu_srcs,
|
|
|
|
deps = deps + noicu_deps + default.deps,
|
|
|
|
includes = includes + default.includes,
|
|
|
|
copts = copts + default.copts,
|
|
|
|
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
|
|
|
|
)
|
2021-06-15 14:09:17 +00:00
|
|
|
|
2021-10-28 14:33:16 +00:00
|
|
|
# buildifier: disable=function-docstring
|
2021-06-15 14:09:17 +00:00
|
|
|
def v8_library(
|
|
|
|
name,
|
|
|
|
srcs,
|
|
|
|
deps = [],
|
|
|
|
includes = [],
|
|
|
|
copts = [],
|
|
|
|
linkopts = [],
|
2021-10-28 14:33:16 +00:00
|
|
|
noicu_srcs = [],
|
|
|
|
noicu_deps = [],
|
|
|
|
icu_srcs = [],
|
|
|
|
icu_deps = [],
|
2021-06-15 14:09:17 +00:00
|
|
|
**kwargs):
|
2021-10-28 14:33:16 +00:00
|
|
|
default = _default_args()
|
|
|
|
if _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, icu_srcs, icu_deps):
|
|
|
|
native.cc_library(
|
2021-11-08 15:57:55 +00:00
|
|
|
name = name + "_noicu",
|
2021-10-28 14:33:16 +00:00
|
|
|
srcs = srcs + noicu_srcs,
|
|
|
|
deps = deps + noicu_deps + default.deps,
|
|
|
|
includes = includes + default.includes,
|
|
|
|
copts = copts + default.copts,
|
|
|
|
linkopts = linkopts + default.linkopts,
|
|
|
|
alwayslink = 1,
|
2021-11-22 15:56:46 +00:00
|
|
|
linkstatic = 1,
|
2021-10-28 14:33:16 +00:00
|
|
|
**kwargs
|
|
|
|
)
|
2022-01-10 21:23:25 +00:00
|
|
|
|
2021-11-08 15:57:55 +00:00
|
|
|
# Alias target used because of cc_library bug in bazel on windows
|
|
|
|
# https://github.com/bazelbuild/bazel/issues/14237
|
|
|
|
# TODO(victorgomes): Remove alias once bug is fixed
|
|
|
|
native.alias(
|
|
|
|
name = "noicu/" + name,
|
|
|
|
actual = name + "_noicu",
|
|
|
|
)
|
2021-10-28 14:33:16 +00:00
|
|
|
native.cc_library(
|
2021-11-08 15:57:55 +00:00
|
|
|
name = name + "_icu",
|
2021-10-28 14:33:16 +00:00
|
|
|
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,
|
2021-11-22 15:56:46 +00:00
|
|
|
linkstatic = 1,
|
2021-10-28 14:33:16 +00:00
|
|
|
**kwargs
|
|
|
|
)
|
2022-01-10 21:23:25 +00:00
|
|
|
|
2021-11-08 15:57:55 +00:00
|
|
|
# Alias target used because of cc_library bug in bazel on windows
|
|
|
|
# https://github.com/bazelbuild/bazel/issues/14237
|
|
|
|
# TODO(victorgomes): Remove alias once bug is fixed
|
|
|
|
native.alias(
|
|
|
|
name = "icu/" + name,
|
|
|
|
actual = name + "_icu",
|
|
|
|
)
|
2021-10-28 14:33:16 +00:00
|
|
|
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,
|
2021-11-22 15:56:46 +00:00
|
|
|
linkstatic = 1,
|
2021-10-28 14:33:16 +00:00
|
|
|
**kwargs
|
|
|
|
)
|
2021-06-15 14:09:17 +00:00
|
|
|
|
|
|
|
def _torque_impl(ctx):
|
2022-01-05 10:32:12 +00:00
|
|
|
if ctx.workspace_name == "v8":
|
|
|
|
v8root = "."
|
|
|
|
else:
|
|
|
|
v8root = "external/v8"
|
2021-10-28 14:33:16 +00:00
|
|
|
|
2021-06-15 14:09:17 +00:00
|
|
|
# Arguments
|
|
|
|
args = []
|
2021-06-25 11:28:39 +00:00
|
|
|
args += ctx.attr.args
|
2021-06-15 14:09:17 +00:00
|
|
|
args.append("-o")
|
2021-10-28 14:33:16 +00:00
|
|
|
args.append(ctx.bin_dir.path + "/" + v8root + "/" + ctx.attr.prefix + "/torque-generated")
|
2021-06-25 11:28:39 +00:00
|
|
|
args.append("-strip-v8-root")
|
2021-06-15 14:09:17 +00:00
|
|
|
args.append("-v8-root")
|
2021-06-25 11:28:39 +00:00
|
|
|
args.append(v8root)
|
2021-10-28 14:33:16 +00:00
|
|
|
|
2021-06-15 14:09:17 +00:00
|
|
|
# Sources
|
|
|
|
args += [f.path for f in ctx.files.srcs]
|
2021-10-28 14:33:16 +00:00
|
|
|
|
2021-06-15 14:09:17 +00:00
|
|
|
# Generate/declare output files
|
|
|
|
outs = []
|
|
|
|
for src in ctx.files.srcs:
|
|
|
|
root, period, ext = src.path.rpartition(".")
|
2021-10-28 14:33:16 +00:00
|
|
|
|
2021-06-25 11:28:39 +00:00
|
|
|
# Strip v8root
|
|
|
|
if root[:len(v8root)] == v8root:
|
|
|
|
root = root[len(v8root):]
|
2021-10-28 14:33:16 +00:00
|
|
|
file = ctx.attr.prefix + "/torque-generated/" + root
|
2021-06-15 14:09:17 +00:00
|
|
|
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-inl.inc"))
|
|
|
|
outs.append(ctx.actions.declare_file(file + "-tq.inc"))
|
|
|
|
outs.append(ctx.actions.declare_file(file + "-tq.cc"))
|
2021-10-28 14:33:16 +00:00
|
|
|
outs += [ctx.actions.declare_file(ctx.attr.prefix + "/torque-generated/" + f) for f in ctx.attr.extras]
|
2021-06-15 14:09:17 +00:00
|
|
|
ctx.actions.run(
|
|
|
|
outputs = outs,
|
|
|
|
inputs = ctx.files.srcs,
|
|
|
|
arguments = args,
|
|
|
|
executable = ctx.executable.tool,
|
2021-10-28 14:33:16 +00:00
|
|
|
mnemonic = "GenTorque",
|
2021-06-15 14:09:17 +00:00
|
|
|
progress_message = "Generating Torque files",
|
|
|
|
)
|
|
|
|
return [DefaultInfo(files = depset(outs))]
|
|
|
|
|
2021-10-28 14:33:16 +00:00
|
|
|
_v8_torque = rule(
|
2021-06-15 14:09:17 +00:00
|
|
|
implementation = _torque_impl,
|
2021-10-28 14:33:16 +00:00
|
|
|
# cfg = v8_target_cpu_transition,
|
2021-06-15 14:09:17 +00:00
|
|
|
attrs = {
|
2021-10-28 14:33:16 +00:00
|
|
|
"prefix": attr.string(mandatory = True),
|
2021-06-15 14:09:17 +00:00
|
|
|
"srcs": attr.label_list(allow_files = True, mandatory = True),
|
|
|
|
"extras": attr.string_list(),
|
|
|
|
"tool": attr.label(
|
|
|
|
allow_files = True,
|
|
|
|
executable = True,
|
2021-10-28 14:33:16 +00:00
|
|
|
cfg = "exec",
|
2021-06-15 14:09:17 +00:00
|
|
|
),
|
2021-06-25 11:28:39 +00:00
|
|
|
"args": attr.string_list(),
|
2021-06-15 14:09:17 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2021-10-28 14:33:16 +00:00
|
|
|
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({
|
2021-12-11 01:23:17 +00:00
|
|
|
"@v8//bazel/config:v8_target_is_32_bits": ":torque_non_pointer_compression",
|
2021-10-28 14:33:16 +00:00
|
|
|
"//conditions:default": ":torque",
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
_v8_torque(
|
|
|
|
name = "icu/" + name,
|
|
|
|
prefix = "icu",
|
|
|
|
srcs = icu_srcs,
|
|
|
|
args = args,
|
|
|
|
extras = extras,
|
|
|
|
tool = select({
|
2021-12-11 01:23:17 +00:00
|
|
|
"@v8//bazel/config:v8_target_is_32_bits": ":torque_non_pointer_compression",
|
2021-10-28 14:33:16 +00:00
|
|
|
"//conditions:default": ":torque",
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
|
2021-12-01 10:28:47 +00:00
|
|
|
def _v8_target_cpu_transition_impl(settings, attr):
|
|
|
|
mapping = {
|
|
|
|
"haswell": "x64",
|
|
|
|
"k8": "x64",
|
|
|
|
"x86_64": "x64",
|
2022-01-03 05:16:36 +00:00
|
|
|
"darwin": "x64",
|
2021-12-01 10:28:47 +00:00
|
|
|
"darwin_x86_64": "x64",
|
2022-01-06 04:41:06 +00:00
|
|
|
"x64_windows": "x64",
|
2021-12-01 10:28:47 +00:00
|
|
|
"x86": "ia32",
|
2022-01-06 04:39:54 +00:00
|
|
|
"aarch64": "arm64",
|
2021-12-01 10:28:47 +00:00
|
|
|
"arm64-v8a": "arm64",
|
|
|
|
"arm": "arm64",
|
|
|
|
"armeabi-v7a": "arm32",
|
2022-01-09 04:24:18 +00:00
|
|
|
"s390x": "s390x",
|
2022-01-10 09:10:05 +00:00
|
|
|
"riscv64": "riscv64",
|
2022-01-10 11:29:37 +00:00
|
|
|
"ppc": "ppc64le",
|
2021-12-01 10:28:47 +00:00
|
|
|
}
|
|
|
|
v8_target_cpu = mapping[settings["//command_line_option:cpu"]]
|
2021-12-11 01:23:17 +00:00
|
|
|
return {"@v8//bazel/config:v8_target_cpu": v8_target_cpu}
|
2021-12-01 10:28:47 +00:00
|
|
|
|
|
|
|
# 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"],
|
2021-12-11 01:23:17 +00:00
|
|
|
outputs = ["@v8//bazel/config:v8_target_cpu"],
|
2021-12-01 10:28:47 +00:00
|
|
|
)
|
|
|
|
|
2021-06-15 14:09:17 +00:00
|
|
|
def _mksnapshot(ctx):
|
|
|
|
outs = [
|
2021-10-28 14:33:16 +00:00
|
|
|
ctx.actions.declare_file(ctx.attr.prefix + "/snapshot.cc"),
|
|
|
|
ctx.actions.declare_file(ctx.attr.prefix + "/embedded.S"),
|
2021-06-15 14:09:17 +00:00
|
|
|
]
|
|
|
|
ctx.actions.run(
|
|
|
|
outputs = outs,
|
|
|
|
inputs = [],
|
|
|
|
arguments = [
|
|
|
|
"--embedded_variant=Default",
|
2021-10-28 14:33:16 +00:00
|
|
|
"--startup_src",
|
|
|
|
outs[0].path,
|
|
|
|
"--embedded_src",
|
|
|
|
outs[1].path,
|
2021-07-12 09:56:02 +00:00
|
|
|
] + ctx.attr.args,
|
2021-06-15 14:09:17 +00:00
|
|
|
executable = ctx.executable.tool,
|
2021-10-28 14:33:16 +00:00
|
|
|
progress_message = "Running mksnapshot",
|
2021-06-15 14:09:17 +00:00
|
|
|
)
|
|
|
|
return [DefaultInfo(files = depset(outs))]
|
|
|
|
|
2021-10-28 14:33:16 +00:00
|
|
|
_v8_mksnapshot = rule(
|
2021-06-15 14:09:17 +00:00
|
|
|
implementation = _mksnapshot,
|
|
|
|
attrs = {
|
2021-07-12 09:56:02 +00:00
|
|
|
"args": attr.string_list(),
|
2021-06-15 14:09:17 +00:00
|
|
|
"tool": attr.label(
|
2021-10-28 14:33:16 +00:00
|
|
|
mandatory = True,
|
2021-06-15 14:09:17 +00:00
|
|
|
allow_files = True,
|
|
|
|
executable = True,
|
2021-10-28 14:33:16 +00:00
|
|
|
cfg = "exec",
|
2021-06-15 14:09:17 +00:00
|
|
|
),
|
2021-12-01 10:28:47 +00:00
|
|
|
"_allowlist_function_transition": attr.label(
|
|
|
|
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
|
|
|
|
),
|
2021-10-28 14:33:16 +00:00
|
|
|
"prefix": attr.string(mandatory = True),
|
|
|
|
},
|
2021-12-01 10:28:47 +00:00
|
|
|
cfg = v8_target_cpu_transition,
|
2021-06-15 14:09:17 +00:00
|
|
|
)
|
2021-08-09 14:08:51 +00:00
|
|
|
|
2021-10-28 14:33:16 +00:00
|
|
|
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",
|
|
|
|
)
|
|
|
|
|
2021-08-09 14:08:51 +00:00
|
|
|
def _quote(val):
|
|
|
|
if val[0] == '"' and val[-1] == '"':
|
|
|
|
fail("String", val, "already quoted")
|
|
|
|
return '"' + val + '"'
|
|
|
|
|
|
|
|
def _kv_bool_pair(k, v):
|
|
|
|
return _quote(k) + ": " + v
|
|
|
|
|
|
|
|
def _json(kv_pairs):
|
|
|
|
content = "{"
|
|
|
|
for (k, v) in kv_pairs[:-1]:
|
|
|
|
content += _kv_bool_pair(k, v) + ", "
|
|
|
|
(k, v) = kv_pairs[-1]
|
|
|
|
content += _kv_bool_pair(k, v)
|
|
|
|
content += "}\n"
|
|
|
|
return content
|
|
|
|
|
2021-10-28 14:33:16 +00:00
|
|
|
def build_config_content(cpu, icu):
|
|
|
|
return _json([
|
2021-08-09 14:08:51 +00:00
|
|
|
("current_cpu", cpu),
|
|
|
|
("dcheck_always_on", "false"),
|
|
|
|
("is_android", "false"),
|
|
|
|
("is_asan", "false"),
|
|
|
|
("is_cfi", "false"),
|
|
|
|
("is_clang", "true"),
|
|
|
|
("is_component_build", "false"),
|
|
|
|
("is_debug", "false"),
|
|
|
|
("is_full_debug", "false"),
|
|
|
|
("is_gcov_coverage", "false"),
|
|
|
|
("is_msan", "false"),
|
|
|
|
("is_tsan", "false"),
|
|
|
|
("is_ubsan_vptr", "false"),
|
|
|
|
("target_cpu", cpu),
|
|
|
|
("v8_current_cpu", cpu),
|
2021-10-28 14:33:16 +00:00
|
|
|
("v8_dict_property_const_tracking", "false"),
|
2021-08-09 14:08:51 +00:00
|
|
|
("v8_enable_atomic_marking_state", "false"),
|
|
|
|
("v8_enable_atomic_object_field_writes", "false"),
|
|
|
|
("v8_enable_concurrent_marking", "false"),
|
2021-10-28 14:33:16 +00:00
|
|
|
("v8_enable_i18n_support", icu),
|
2021-08-09 14:08:51 +00:00
|
|
|
("v8_enable_verify_predictable", "false"),
|
|
|
|
("v8_enable_verify_csa", "false"),
|
|
|
|
("v8_enable_lite_mode", "false"),
|
|
|
|
("v8_enable_runtime_call_stats", "false"),
|
|
|
|
("v8_enable_pointer_compression", "true"),
|
|
|
|
("v8_enable_pointer_compression_shared_cage", "false"),
|
|
|
|
("v8_enable_third_party_heap", "false"),
|
|
|
|
("v8_enable_webassembly", "false"),
|
|
|
|
("v8_control_flow_integrity", "false"),
|
|
|
|
("v8_enable_single_generation", "false"),
|
V8 Sandbox rebranding
This CL renames a number of things related to the V8 sandbox.
Mainly, what used to be under V8_HEAP_SANDBOX is now under
V8_SANDBOXED_EXTERNAL_POINTERS, while the previous V8 VirtualMemoryCage
is now simply the V8 Sandbox:
V8_VIRTUAL_MEMORY_CAGE => V8_SANDBOX
V8_HEAP_SANDBOX => V8_SANDBOXED_EXTERNAL_POINTERS
V8_CAGED_POINTERS => V8_SANDBOXED_POINTERS
V8VirtualMemoryCage => Sandbox
CagedPointer => SandboxedPointer
fake cage => partially reserved sandbox
src/security => src/sandbox
This naming scheme should simplify things: the sandbox is now the large
region of virtual address space inside which V8 mainly operates and
which should be considered untrusted. Mechanisms like sandboxed pointers
are then used to attempt to prevent escapes from the sandbox (i.e.
corruption of memory outside of it). Furthermore, the new naming scheme
avoids the confusion with the various other "cages" in V8, in
particular, the VirtualMemoryCage class, by dropping that name entirely.
Future sandbox features are developed under their own V8_SANDBOX_X flag,
and will, once final, be merged into V8_SANDBOX. Current future features
are sandboxed external pointers (using the external pointer table), and
sandboxed pointers (pointers guaranteed to point into the sandbox, e.g.
because they are encoded as offsets). This CL then also introduces a new
build flag, v8_enable_sandbox_future, which enables all future features.
Bug: v8:10391
Change-Id: I5174ea8f5ab40fb96a04af10853da735ad775c96
Cq-Include-Trybots: luci.v8.try:v8_linux64_heap_sandbox_dbg_ng,v8_linux_arm64_sim_heap_sandbox_dbg_ng
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3322981
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Samuel Groß <saelo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78384}
2021-12-15 13:39:15 +00:00
|
|
|
("v8_enable_sandbox", "false"),
|
2021-08-09 14:08:51 +00:00
|
|
|
("v8_target_cpu", cpu),
|
|
|
|
])
|
2021-10-28 14:33:16 +00:00
|
|
|
|
|
|
|
# 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(
|
|
|
|
name = "noicu/" + name,
|
|
|
|
outs = ["noicu/" + name + ".json"],
|
|
|
|
cmd = "echo '" + build_config_content(cpu, "false") + "' > \"$@\"",
|
|
|
|
)
|
2021-08-09 14:08:51 +00:00
|
|
|
native.genrule(
|
2021-10-28 14:33:16 +00:00
|
|
|
name = "icu/" + name,
|
|
|
|
outs = ["icu/" + name + ".json"],
|
|
|
|
cmd = "echo '" + build_config_content(cpu, "true") + "' > \"$@\"",
|
2021-08-09 14:08:51 +00:00
|
|
|
)
|