[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")
|
||||
bazel_skylib_workspace()
|
||||
|
||||
new_local_repository(
|
||||
name = "config",
|
||||
path = "bazel/config",
|
||||
build_file = "bazel/config/BUILD.bazel",
|
||||
)
|
||||
|
||||
new_local_repository(
|
||||
name = "zlib",
|
||||
path = "third_party/zlib",
|
||||
|
@ -26,7 +26,6 @@ cc_library(
|
||||
"U_ENABLE_RESOURCE_TRACING=0",
|
||||
"UNISTR_FROM_STRING_EXPLICIT=",
|
||||
"UNISTR_FROM_CHAR_EXPLICIT=",
|
||||
"ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
|
||||
],
|
||||
copts = [
|
||||
"-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),
|
||||
)
|
||||
|
||||
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):
|
||||
_create_option_flag(name = name, build_setting_default = default)
|
||||
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):
|
||||
defs = []
|
||||
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))
|
||||
return [CcInfo(compilation_context = context)]
|
||||
|
||||
v8_custom_config = rule(
|
||||
implementation = _custom_config_impl,
|
||||
attrs = {
|
||||
"_v8_typed_array_max_size_in_heap":
|
||||
attr.label(default = ":v8_typed_array_max_size_in_heap"),
|
||||
}
|
||||
"_v8_typed_array_max_size_in_heap": attr.label(default = ":v8_typed_array_max_size_in_heap"),
|
||||
},
|
||||
)
|
||||
|
||||
def _config_impl(ctx):
|
||||
hdrs = []
|
||||
|
||||
# Add headers
|
||||
for h in ctx.attr.hdrs:
|
||||
hdrs += h[DefaultInfo].files.to_list()
|
||||
defs = []
|
||||
|
||||
# Add conditional_defines
|
||||
for f, d in ctx.attr.conditional_defines.items():
|
||||
if f[FlagInfo].value:
|
||||
defs.append(d)
|
||||
|
||||
# Add defines
|
||||
for d in ctx.attr.defines:
|
||||
defs.append(d)
|
||||
@ -87,9 +85,9 @@ v8_config = rule(
|
||||
},
|
||||
)
|
||||
|
||||
def _default_args(configs):
|
||||
def _default_args():
|
||||
return struct(
|
||||
deps = configs + [":define_flags"],
|
||||
deps = [":define_flags"],
|
||||
copts = [
|
||||
"-fPIC",
|
||||
"-Werror",
|
||||
@ -105,140 +103,248 @@ def _default_args(configs):
|
||||
],
|
||||
includes = ["include"],
|
||||
linkopts = [
|
||||
"-pthread"
|
||||
"-pthread",
|
||||
] + select({
|
||||
":is_macos": [],
|
||||
"//conditions:default": [ "-Wl,--no-as-needed -ldl" ],
|
||||
"@v8//bazel/config:is_macos": [],
|
||||
"//conditions:default": ["-Wl,--no-as-needed -ldl"],
|
||||
}) + select({
|
||||
":should_add_rdynamic": [ "-rdynamic" ],
|
||||
":should_add_rdynamic": ["-rdynamic"],
|
||||
"//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(
|
||||
name,
|
||||
srcs,
|
||||
configs = [],
|
||||
deps = [],
|
||||
includes = [],
|
||||
copts = [],
|
||||
linkopts = [],
|
||||
noicu_srcs = [],
|
||||
noicu_deps = [],
|
||||
icu_srcs = [],
|
||||
icu_deps = [],
|
||||
**kwargs):
|
||||
default = _default_args(configs)
|
||||
native.cc_binary(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
deps = deps + default.deps,
|
||||
includes = includes + default.includes,
|
||||
copts = copts + default.copts,
|
||||
linkopts = linkopts + default.linkopts,
|
||||
**kwargs
|
||||
)
|
||||
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
|
||||
)
|
||||
|
||||
# buildifier: disable=function-docstring
|
||||
def v8_library(
|
||||
name,
|
||||
srcs,
|
||||
configs = [],
|
||||
deps = [],
|
||||
includes = [],
|
||||
copts = [],
|
||||
linkopts = [],
|
||||
noicu_srcs = [],
|
||||
noicu_deps = [],
|
||||
icu_srcs = [],
|
||||
icu_deps = [],
|
||||
**kwargs):
|
||||
default = _default_args(configs)
|
||||
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
|
||||
)
|
||||
default = _default_args()
|
||||
if _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, icu_srcs, icu_deps):
|
||||
native.cc_library(
|
||||
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,
|
||||
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):
|
||||
v8root = ctx.attr.v8root[FlagInfo].value
|
||||
v8root = "."
|
||||
prefix = ctx.attr.prefix
|
||||
|
||||
# Arguments
|
||||
args = []
|
||||
args += ctx.attr.args
|
||||
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("-v8-root")
|
||||
args.append(v8root)
|
||||
|
||||
# Sources
|
||||
args += [f.path for f in ctx.files.srcs]
|
||||
|
||||
# Generate/declare output files
|
||||
outs = []
|
||||
for src in ctx.files.srcs:
|
||||
root, period, ext = src.path.rpartition(".")
|
||||
|
||||
# Strip v8root
|
||||
if root[:len(v8root)] == 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.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"))
|
||||
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(
|
||||
outputs = outs,
|
||||
inputs = ctx.files.srcs,
|
||||
arguments = args,
|
||||
executable = ctx.executable.tool,
|
||||
mnemonic = "GenTorque",
|
||||
progress_message = "Generating Torque files",
|
||||
)
|
||||
return [DefaultInfo(files = depset(outs))]
|
||||
|
||||
v8_torque = rule(
|
||||
_v8_torque = rule(
|
||||
implementation = _torque_impl,
|
||||
# cfg = v8_target_cpu_transition,
|
||||
attrs = {
|
||||
"prefix": attr.string(mandatory = True),
|
||||
"srcs": attr.label_list(allow_files = True, mandatory = True),
|
||||
"extras": attr.string_list(),
|
||||
"tool": attr.label(
|
||||
default = ":torque",
|
||||
allow_files = True,
|
||||
executable = True,
|
||||
cfg = "host",
|
||||
cfg = "exec",
|
||||
),
|
||||
"args": attr.string_list(),
|
||||
"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):
|
||||
outs = [
|
||||
ctx.actions.declare_file("snapshot.cc"),
|
||||
ctx.actions.declare_file("embedded.S"),
|
||||
ctx.actions.declare_file(ctx.attr.prefix + "/snapshot.cc"),
|
||||
ctx.actions.declare_file(ctx.attr.prefix + "/embedded.S"),
|
||||
]
|
||||
ctx.actions.run(
|
||||
outputs = outs,
|
||||
inputs = [],
|
||||
arguments = [
|
||||
"--embedded_variant=Default",
|
||||
"--startup_src", outs[0].path,
|
||||
"--embedded_src", outs[1].path,
|
||||
"--startup_src",
|
||||
outs[0].path,
|
||||
"--embedded_src",
|
||||
outs[1].path,
|
||||
] + ctx.attr.args,
|
||||
executable = ctx.executable.tool,
|
||||
progress_message = "Running mksnapshot"
|
||||
progress_message = "Running mksnapshot",
|
||||
)
|
||||
return [DefaultInfo(files = depset(outs))]
|
||||
|
||||
|
||||
v8_mksnapshot = rule(
|
||||
_v8_mksnapshot = rule(
|
||||
implementation = _mksnapshot,
|
||||
attrs = {
|
||||
"args": attr.string_list(),
|
||||
"tool": attr.label(
|
||||
default = ":mksnapshot",
|
||||
mandatory = True,
|
||||
allow_files = 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):
|
||||
if val[0] == '"' and val[-1] == '"':
|
||||
fail("String", val, "already quoted")
|
||||
@ -256,11 +362,8 @@ def _json(kv_pairs):
|
||||
content += "}\n"
|
||||
return content
|
||||
|
||||
# TODO(victorgomes): Create a rule (instead of a macro), that can
|
||||
# dynamically populate the build config.
|
||||
def v8_build_config(name):
|
||||
cpu = _quote("x64")
|
||||
content = _json([
|
||||
def build_config_content(cpu, icu):
|
||||
return _json([
|
||||
("current_cpu", cpu),
|
||||
("dcheck_always_on", "false"),
|
||||
("is_android", "false"),
|
||||
@ -276,10 +379,11 @@ def v8_build_config(name):
|
||||
("is_ubsan_vptr", "false"),
|
||||
("target_cpu", cpu),
|
||||
("v8_current_cpu", cpu),
|
||||
("v8_dict_property_const_tracking", "false"),
|
||||
("v8_enable_atomic_marking_state", "false"),
|
||||
("v8_enable_atomic_object_field_writes", "false"),
|
||||
("v8_enable_concurrent_marking", "false"),
|
||||
("v8_enable_i18n_support", "true"),
|
||||
("v8_enable_i18n_support", icu),
|
||||
("v8_enable_verify_predictable", "false"),
|
||||
("v8_enable_verify_csa", "false"),
|
||||
("v8_enable_lite_mode", "false"),
|
||||
@ -290,10 +394,21 @@ def v8_build_config(name):
|
||||
("v8_enable_webassembly", "false"),
|
||||
("v8_control_flow_integrity", "false"),
|
||||
("v8_enable_single_generation", "false"),
|
||||
("v8_enable_virtual_memory_cage", "false"),
|
||||
("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(
|
||||
name = name,
|
||||
outs = [name + ".json"],
|
||||
cmd = "echo '" + content + "' > \"$@\"",
|
||||
name = "noicu/" + name,
|
||||
outs = ["noicu/" + name + ".json"],
|
||||
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