Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

113
deps/v8/bazel/BUILD.icu vendored Normal file
View File

@ -0,0 +1,113 @@
# 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.
filegroup(
name = "icudata",
srcs = ["common/icudtl.dat"],
visibility = ["//visibility:public"],
)
cc_library(
name = "icuuc",
srcs = glob([
"source/common/**/*.h",
"source/common/**/*.cpp",
]),
copts = select({
"@platforms//os:windows": [
"/wd4005", # Macro redefinition.
"/wd4068", # Unknown pragmas.
"/wd4267", # Conversion from size_t on 64-bits.
"/utf-8", # ICU source files are in UTF-8.
],
"//conditions:default": [
"-Wno-deprecated-declarations",
],
}),
data = [":icudata"],
defines = [
"HAVE_DLOPEN=0",
"UCONFIG_ONLY_HTML_CONVERSION=1",
"U_CHARSET_IS_UTF8=1",
"U_USING_ICU_NAMESPACE=0",
"U_ENABLE_DYLOAD=0",
"USE_CHROMIUM_ICU=1",
"U_ENABLE_TRACING=1",
"U_ENABLE_RESOURCE_TRACING=0",
"UNISTR_FROM_STRING_EXPLICIT=",
"UNISTR_FROM_CHAR_EXPLICIT=",
] + select({
"@platforms//os:windows": [
"U_STATIC_IMPLEMENTATION",
"UNICODE",
"_UNICODE",
],
"//conditions:default": [],
}),
includes = [
"source/common",
"source/i18n",
],
local_defines = [
"U_COMMON_IMPLEMENTATION",
"U_ICUDATAENTRY_IN_COMMON",
],
tags = ["requires-rtti"],
alwayslink = 1,
)
cc_library(
name = "icui18n",
srcs = glob([
"source/i18n/**/*.h",
"source/i18n/**/*.cpp",
]),
copts = select({
"@platforms//os:windows": [
"/wd4005", # Macro redefinition.
"/wd4068", # Unknown pragmas.
"/wd4267", # Conversion from size_t on 64-bits.
"/utf-8", # ICU source files are in UTF-8.
],
"//conditions:default": [
"-Wno-deprecated-declarations",
],
}),
local_defines = [
"U_I18N_IMPLEMENTATION",
],
deps = [":icuuc"],
alwayslink = 1,
)
cc_library(
name = "icu",
srcs = [
"source/stubdata/stubdata.cpp",
"source/stubdata/stubdata.h",
],
hdrs = glob([
"source/common/unicode/*.h",
"source/i18n/unicode/*.h",
]),
copts = select({
"@platforms//os:windows": [
"/wd4005", # Macro redefinition.
"/wd4068", # Unknown pragmas.
"/wd4267", # Conversion from size_t on 64-bits.
"/utf-8", # ICU source files are in UTF-8.
],
"//conditions:default": [],
}),
include_prefix = "third_party/icu",
local_defines = [
"U_COMMON_IMPLEMENTATION",
],
visibility = ["//visibility:public"],
deps = [
":icui18n",
":icuuc",
],
alwayslink = 1,
)

15
deps/v8/bazel/BUILD.ittapi vendored Normal file
View File

@ -0,0 +1,15 @@
cc_library(
name = "lib_ittapi",
srcs = [
"third_party/ittapi/include/ittnotify.h",
"third_party/ittapi/include/jitprofiling.h",
"third_party/ittapi/src/ittnotify/ittnotify_config.h",
"third_party/ittapi/src/ittnotify/jitprofiling.c",
],
hdrs = [
"third_party/ittapi/include/ittnotify.h",
"third_party/ittapi/src/ittnotify/ittnotify_types.h",
],
copts = ["-Iexternal/intel_ittapi/third_party/ittapi/include"],
visibility = ["//visibility:public"],
)

4
deps/v8/bazel/OWNERS vendored Normal file
View File

@ -0,0 +1,4 @@
# Google3 V8 owners
ahaas@chromium.org
cbruni@chromium.org
victorgomes@chromium.org

359
deps/v8/bazel/config/BUILD.bazel vendored Normal file
View File

@ -0,0 +1,359 @@
# 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 = "is_fastbuild",
values = {
"compilation_mode": "fastbuild",
},
)
config_setting(
name = "is_opt",
values = {
"compilation_mode": "opt",
},
)
config_setting(
name = "is_debug",
values = {
"compilation_mode": "dbg",
},
)
selects.config_setting_group(
name = "is_opt_android",
match_all = [
":is_opt",
":is_android",
],
)
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:aarch64"],
)
config_setting(
name = "platform_cpu_arm",
constraint_values = ["@platforms//cpu:arm"],
)
config_setting(
name = "platform_cpu_s390x",
constraint_values = ["@platforms//cpu:s390x"],
)
config_setting(
name = "platform_cpu_riscv64",
constraint_values = ["@platforms//cpu:riscv64"],
)
config_setting(
name = "platform_cpu_ppc64le",
constraint_values = ["@platforms//cpu:ppc"],
)
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 = "arm64",
matching_configs = [":platform_cpu_arm64"],
)
v8_configure_target_cpu(
name = "arm",
matching_configs = [":platform_cpu_arm"],
)
v8_configure_target_cpu(
name = "s390x",
matching_configs = [":platform_cpu_s390x"],
)
v8_configure_target_cpu(
name = "riscv64",
matching_configs = [":platform_cpu_riscv64"],
)
v8_configure_target_cpu(
name = "ppc64le",
matching_configs = [":platform_cpu_ppc64le"],
)
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"],
)
config_setting(
name = "is_windows",
constraint_values = ["@platforms//os:windows"],
)
selects.config_setting_group(
name = "is_64bit",
match_any = [
":v8_target_arm64",
":is_x64",
":is_arm64",
":is_s390x",
":is_riscv64",
":is_ppc64le",
],
)
selects.config_setting_group(
name = "is_windows_64bit",
match_all = [
":is_64bit",
":is_windows",
],
)
selects.config_setting_group(
name = "is_posix",
match_any = [
":is_linux",
":is_android",
":is_macos",
],
)
selects.config_setting_group(
name = "is_not_android",
match_any = [
":is_windows",
":is_linux",
":is_macos",
]
)
selects.config_setting_group(
name = "is_posix_x64",
match_all = [
":is_posix",
":is_x64",
],
)
selects.config_setting_group(
name = "is_inline_asm_x64",
match_all = [
":is_posix",
":is_x64",
],
)
selects.config_setting_group(
name = "is_inline_asm_ia32",
match_all = [
":is_posix",
":is_ia32",
],
)
selects.config_setting_group(
name = "is_inline_asm_arm64",
match_all = [
":is_posix",
":is_arm64",
],
)
selects.config_setting_group(
name = "is_inline_asm_arm",
match_all = [
":is_posix",
":is_arm",
],
)
selects.config_setting_group(
name = "is_inline_asm_s390x",
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_inline_asm_ppc64le",
match_all = [
":is_posix",
":is_ppc64le",
],
)
selects.config_setting_group(
name = "is_msvc_asm_x64",
match_all = [
":is_windows",
":is_x64",
],
)
selects.config_setting_group(
name = "is_msvc_asm_ia32",
match_all = [
":is_windows",
":is_ia32",
],
)
selects.config_setting_group(
name = "is_msvc_asm_arm64",
match_all = [
":is_windows",
":is_arm64",
],
)
config_setting(
name = "is_compiler_default",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "compiler",
},
)
selects.config_setting_group(
name = "is_compiler_default_on_linux",
match_all = [
":is_compiler_default",
":is_linux",
],
)
selects.config_setting_group(
name = "is_compiler_default_on_macos",
match_all = [
":is_compiler_default",
":is_macos",
],
)
config_setting(
name = "is_compiler_clang",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "clang",
},
)
selects.config_setting_group(
name = "is_clang",
match_any = [
":is_compiler_default_on_macos",
":is_compiler_clang",
],
)
selects.config_setting_group(
name = "is_clang_s390x",
match_all = [
":is_clang",
":is_s390x",
],
)
config_setting(
name = "is_compiler_gcc",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "gcc",
},
)
selects.config_setting_group(
name = "is_gcc",
match_any = [
":is_compiler_default_on_linux",
":is_compiler_gcc",
],
)
selects.config_setting_group(
name = "is_gcc_fastbuild",
match_all = [
":is_gcc",
":is_fastbuild",
],
)

61
deps/v8/bazel/config/v8-target-cpu.bzl vendored Normal file
View 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", "ppc64le", "riscv64", "s390x", "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,
],
)

617
deps/v8/bazel/defs.bzl vendored Normal file
View File

@ -0,0 +1,617 @@
# 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.
"""
This module contains helper functions to compile V8.
"""
FlagInfo = provider("The value of an option.",
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"})
native.config_setting(name = "is_not_" + name, flag_values = {name: "False"})
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=" +
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"),
},
)
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)
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),
},
)
def _default_args():
return struct(
deps = [":define_flags"],
defines = select({
"@v8//bazel/config:is_windows": [
"UNICODE",
"_UNICODE",
"_CRT_RAND_S",
"_WIN32_WINNT=0x0A00", # Override bazel default to Windows 10
],
"//conditions:default": [],
}),
copts = select({
"@v8//bazel/config:is_posix": [
"-fPIC",
"-fno-strict-aliasing",
"-Werror",
"-Wextra",
"-Wno-unneeded-internal-declaration",
"-Wno-unknown-warning-option", # b/330781959
"-Wno-cast-function-type-mismatch", # b/330781959
"-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": [],
}) + select({
"@v8//bazel/config:is_clang": [
"-Wno-invalid-offsetof",
"-Wno-deprecated-this-capture",
"-Wno-deprecated-declarations",
"-std=c++20",
],
"@v8//bazel/config:is_gcc": [
"-Wno-extra",
"-Wno-array-bounds",
"-Wno-class-memaccess",
"-Wno-comments",
"-Wno-deprecated-declarations",
"-Wno-implicit-fallthrough",
"-Wno-int-in-bool-context",
"-Wno-maybe-uninitialized",
"-Wno-mismatched-new-delete",
"-Wno-redundant-move",
"-Wno-return-type",
"-Wno-stringop-overflow",
"-Wno-deprecated-this-capture",
# Use GNU dialect, because GCC doesn't allow using
# ##__VA_ARGS__ when in standards-conforming mode.
"-std=gnu++2a",
],
"@v8//bazel/config:is_windows": [
"/std:c++20",
],
"//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": [],
}) + select({
"@v8//bazel/config:is_clang_s390x": [
"-fno-integrated-as",
],
"//conditions:default": [],
}) + select({
"@v8//bazel/config:is_opt_android": [
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
],
"//conditions:default": [
],
}),
includes = ["include"],
linkopts = select({
"@v8//bazel/config:is_windows": [
"Winmm.lib",
"DbgHelp.lib",
"Advapi32.lib",
],
"@v8//bazel/config:is_macos": ["-pthread"],
"//conditions:default": ["-Wl,--no-as-needed -ldl -latomic -pthread"],
}) + select({
":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, noicu_defines, icu_srcs, icu_deps, icu_defines):
return noicu_srcs != [] or noicu_deps != [] or noicu_defines != [] or icu_srcs != [] or icu_deps != [] or icu_defines != []
# buildifier: disable=function-docstring
def v8_binary(
name,
srcs,
deps = [],
defines = [],
includes = [],
copts = [],
linkopts = [],
noicu_srcs = [],
noicu_deps = [],
noicu_defines = [],
icu_srcs = [],
icu_deps = [],
icu_defines = [],
**kwargs):
default = _default_args()
if _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, noicu_defines, icu_srcs, icu_deps, icu_defines):
native.cc_binary(
name = "noicu/" + name,
srcs = srcs + noicu_srcs,
deps = deps + noicu_deps + default.deps,
defines = defines + noicu_defines + default.defines,
includes = includes + ["noicu/"] + 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 + ["icu/"] + default.includes,
defines = defines + icu_defines + default.defines,
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,
defines = defines + default.defines,
includes = includes + default.includes,
copts = copts + default.copts,
linkopts = linkopts + default.linkopts,
**kwargs
)
# buildifier: disable=function-docstring
def v8_library(
name,
srcs,
deps = [],
includes = [],
copts = [],
linkopts = [],
noicu_srcs = [],
noicu_deps = [],
noicu_defines = [],
icu_srcs = [],
icu_deps = [],
icu_defines = [],
**kwargs):
default = _default_args()
if _should_emit_noicu_and_icu(noicu_srcs, noicu_deps, noicu_defines, icu_srcs, icu_deps, icu_defines):
native.cc_library(
name = name + "_noicu",
srcs = srcs + noicu_srcs,
deps = deps + noicu_deps + default.deps,
includes = includes + ["noicu/"] + default.includes,
copts = copts + default.copts,
linkopts = linkopts + default.linkopts,
alwayslink = 1,
linkstatic = 1,
**kwargs
)
# 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",
)
native.cc_library(
name = name + "_icu",
srcs = srcs + icu_srcs,
deps = deps + icu_deps + default.deps,
includes = includes + ["icu/"] + default.includes,
copts = copts + default.copts + ENABLE_I18N_SUPPORT_DEFINES,
linkopts = linkopts + default.linkopts,
alwayslink = 1,
linkstatic = 1,
**kwargs
)
# 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",
)
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,
linkstatic = 1,
**kwargs
)
# Use a single generator target for torque definitions and initializers. We can
# split the set of outputs by using OutputGroupInfo, that way we do not need to
# run the torque generator twice.
def _torque_files_impl(ctx):
# Allow building V8 as a dependency: workspace_root points to external/v8
# when building V8 from a different repository and empty otherwise.
v8root = ctx.label.workspace_root
if v8root == "":
v8root = "."
# Arguments
args = []
args += ctx.attr.args
args.append("-o")
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
defs = []
inits = []
for src in ctx.files.srcs:
root, _period, _ext = src.path.rpartition(".")
# Strip v8root
if root[:len(v8root)] == v8root:
root = root[len(v8root):]
file = ctx.attr.prefix + "/torque-generated/" + root
defs.append(ctx.actions.declare_file(file + "-tq-inl.inc"))
defs.append(ctx.actions.declare_file(file + "-tq.inc"))
defs.append(ctx.actions.declare_file(file + "-tq.cc"))
inits.append(ctx.actions.declare_file(file + "-tq-csa.cc"))
inits.append(ctx.actions.declare_file(file + "-tq-csa.h"))
defs += [ctx.actions.declare_file(ctx.attr.prefix + "/torque-generated/" + f) for f in ctx.attr.definition_extras]
inits += [ctx.actions.declare_file(ctx.attr.prefix + "/torque-generated/" + f) for f in ctx.attr.initializer_extras]
outs = defs + inits
ctx.actions.run(
outputs = outs,
inputs = ctx.files.srcs,
arguments = args,
executable = ctx.executable.tool,
mnemonic = "GenTorqueFiles",
progress_message = "Generating Torque files",
)
return [
DefaultInfo(files = depset(outs)),
OutputGroupInfo(
initializers = depset(inits),
definitions = depset(defs),
),
]
_v8_torque_files = rule(
implementation = _torque_files_impl,
# cfg = v8_target_cpu_transition,
attrs = {
"prefix": attr.string(mandatory = True),
"srcs": attr.label_list(allow_files = True, mandatory = True),
"definition_extras": attr.string_list(),
"initializer_extras": attr.string_list(),
"tool": attr.label(
allow_files = True,
executable = True,
cfg = "exec",
),
"args": attr.string_list(),
},
)
def v8_torque_files(name, noicu_srcs, icu_srcs, args, definition_extras, initializer_extras):
_v8_torque_files(
name = "noicu/" + name,
prefix = "noicu",
srcs = noicu_srcs,
args = args,
definition_extras = definition_extras,
initializer_extras = initializer_extras,
tool = select({
"@v8//bazel/config:v8_target_is_32_bits": ":noicu/torque_non_pointer_compression",
"//conditions:default": ":noicu/torque",
}),
)
_v8_torque_files(
name = "icu/" + name,
prefix = "icu",
srcs = icu_srcs,
args = args,
definition_extras = definition_extras,
initializer_extras = initializer_extras,
tool = select({
"@v8//bazel/config:v8_target_is_32_bits": ":icu/torque_non_pointer_compression",
"//conditions:default": ":icu/torque",
}),
)
def _v8_target_cpu_transition_impl(settings,
attr, # @unused
):
# Check for an existing v8_target_cpu flag.
if "@v8//bazel/config:v8_target_cpu" in settings:
if settings["@v8//bazel/config:v8_target_cpu"] != "none":
return {}
# Auto-detect target architecture based on the --cpu flag.
mapping = {
"haswell": "x64",
"k8": "x64",
"x86_64": "x64",
"darwin": "x64",
"darwin_x86_64": "x64",
"x64_windows": "x64",
"x86": "ia32",
"aarch64": "arm64",
"arm64-v8a": "arm64",
"arm": "arm64",
"darwin_arm64": "arm64",
"armeabi-v7a": "arm32",
"s390x": "s390x",
"riscv64": "riscv64",
"ppc64": "ppc64le",
}
v8_target_cpu = mapping[settings["//command_line_option:cpu"]]
return {"@v8//bazel/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 = ["@v8//bazel/config:v8_target_cpu", "//command_line_option:cpu"],
outputs = ["@v8//bazel/config:v8_target_cpu"],
)
def _mksnapshot(ctx):
prefix = ctx.attr.prefix
suffix = ctx.attr.suffix
outs = [
ctx.actions.declare_file(prefix + "/snapshot" + suffix + ".cc"),
ctx.actions.declare_file(prefix + "/embedded" + suffix + ".S"),
]
ctx.actions.run(
outputs = outs,
inputs = [],
arguments = [
"--embedded_variant=Default",
"--target_os",
ctx.attr.target_os,
"--startup_src",
outs[0].path,
"--embedded_src",
outs[1].path,
] + ctx.attr.args,
executable = ctx.executable.tool,
progress_message = "Running mksnapshot",
)
return [DefaultInfo(files = depset(outs))]
_v8_mksnapshot = rule(
implementation = _mksnapshot,
attrs = {
"args": attr.string_list(),
"tool": attr.label(
mandatory = True,
allow_files = True,
executable = True,
cfg = "exec",
),
"target_os": attr.string(mandatory = True),
"prefix": attr.string(mandatory = True),
"suffix": attr.string(mandatory = True),
},
cfg = v8_target_cpu_transition,
)
def v8_mksnapshot(name, args, suffix = ""):
_v8_mksnapshot(
name = "noicu/" + name,
args = args,
prefix = "noicu",
tool = ":noicu/mksnapshot" + suffix,
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
"@v8//bazel/config:is_windows": "win",
"//conditions:default": "",
}),
)
_v8_mksnapshot(
name = "icu/" + name,
args = args,
prefix = "icu",
tool = ":icu/mksnapshot" + suffix,
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
"@v8//bazel/config:is_windows": "win",
"//conditions:default": "",
}),
)
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
def build_config_content(cpu, icu):
arch = cpu
if cpu == 'x86':
arch = 'ia32'
return _json([
("arch", arch),
("asan", "false"),
("atomic_object_field_writes", "false"),
("cet_shadow_stack", "false"),
("cfi", "false"),
("clang_coverage", "false"),
("clang", "true"),
("code_comments", "false"),
("component_build", "false"),
("concurrent_marking", "false"),
("conservative_stack_scanning", "false"),
("current_cpu", cpu),
("dcheck_always_on", "false"),
("debug_code", "false"),
("DEBUG_defined", "false"),
("debugging_features", "false"),
("dict_property_const_tracking", "false"),
("direct_handle", "false"),
("disassembler", "false"),
("full_debug", "false"),
("gdbjit", "false"),
("has_jitless", "false"),
("has_maglev", "true"),
("has_turbofan", "true"),
("has_webassembly", "false"),
("has_wasm_interpreter", "false"),
("i18n", icu),
("is_android", "false"),
("is_ios", "false"),
("js_shared_memory", "false"),
("leaptiering", "true"),
("lite_mode", "false"),
("local_off_stack_check", "false"),
("lower_limits_mode", "false"),
("memory_corruption_api", "false"),
("mips_arch_variant", '""'),
("mips_use_msa", "false"),
("msan", "false"),
("official_build", "false"),
("pointer_compression_shared_cage", "false"),
("pointer_compression", "true"),
("runtime_call_stats", "false"),
("sandbox", "false"),
("shared_ro_heap", "false"),
("simd_mips", "false"),
("simulator_run", "false"),
("single_generation", "false"),
("slow_dchecks", "false"),
("target_cpu", cpu),
("tsan", "false"),
("ubsan", "false"),
("use_sanitizer", "false"),
("v8_cfi", "false"),
("v8_current_cpu", cpu),
("v8_target_cpu", cpu),
("verify_csa", "false"),
("verify_heap", "false"),
("verify_predictable", "false"),
("wasm_random_fuzzers", "false"),
("write_barriers", "false"),
])
# TODO(victorgomes): Create a rule (instead of a macro), that can
# dynamically populate the build config.
def v8_build_config(name, arch):
cpu = '"' + arch + '"'
native.genrule(
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") + "' > \"$@\"",
)

1
deps/v8/bazel/requirements.in vendored Normal file
View File

@ -0,0 +1 @@
jinja2

81
deps/v8/bazel/requirements.txt vendored Normal file
View File

@ -0,0 +1,81 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --generate-hashes requirements.in
#
jinja2==3.0.3 \
--hash=sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8 \
--hash=sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7
# via -r requirements.in
markupsafe==2.0.1 \
--hash=sha256:01a9b8ea66f1658938f65b93a85ebe8bc016e6769611be228d797c9d998dd298 \
--hash=sha256:023cb26ec21ece8dc3907c0e8320058b2e0cb3c55cf9564da612bc325bed5e64 \
--hash=sha256:0446679737af14f45767963a1a9ef7620189912317d095f2d9ffa183a4d25d2b \
--hash=sha256:04635854b943835a6ea959e948d19dcd311762c5c0c6e1f0e16ee57022669194 \
--hash=sha256:0717a7390a68be14b8c793ba258e075c6f4ca819f15edfc2a3a027c823718567 \
--hash=sha256:0955295dd5eec6cb6cc2fe1698f4c6d84af2e92de33fbcac4111913cd100a6ff \
--hash=sha256:0d4b31cc67ab36e3392bbf3862cfbadac3db12bdd8b02a2731f509ed5b829724 \
--hash=sha256:10f82115e21dc0dfec9ab5c0223652f7197feb168c940f3ef61563fc2d6beb74 \
--hash=sha256:168cd0a3642de83558a5153c8bd34f175a9a6e7f6dc6384b9655d2697312a646 \
--hash=sha256:1d609f577dc6e1aa17d746f8bd3c31aa4d258f4070d61b2aa5c4166c1539de35 \
--hash=sha256:1f2ade76b9903f39aa442b4aadd2177decb66525062db244b35d71d0ee8599b6 \
--hash=sha256:20dca64a3ef2d6e4d5d615a3fd418ad3bde77a47ec8a23d984a12b5b4c74491a \
--hash=sha256:2a7d351cbd8cfeb19ca00de495e224dea7e7d919659c2841bbb7f420ad03e2d6 \
--hash=sha256:2d7d807855b419fc2ed3e631034685db6079889a1f01d5d9dac950f764da3dad \
--hash=sha256:2ef54abee730b502252bcdf31b10dacb0a416229b72c18b19e24a4509f273d26 \
--hash=sha256:36bc903cbb393720fad60fc28c10de6acf10dc6cc883f3e24ee4012371399a38 \
--hash=sha256:37205cac2a79194e3750b0af2a5720d95f786a55ce7df90c3af697bfa100eaac \
--hash=sha256:3c112550557578c26af18a1ccc9e090bfe03832ae994343cfdacd287db6a6ae7 \
--hash=sha256:3dd007d54ee88b46be476e293f48c85048603f5f516008bee124ddd891398ed6 \
--hash=sha256:4296f2b1ce8c86a6aea78613c34bb1a672ea0e3de9c6ba08a960efe0b0a09047 \
--hash=sha256:47ab1e7b91c098ab893b828deafa1203de86d0bc6ab587b160f78fe6c4011f75 \
--hash=sha256:49e3ceeabbfb9d66c3aef5af3a60cc43b85c33df25ce03d0031a608b0a8b2e3f \
--hash=sha256:4dc8f9fb58f7364b63fd9f85013b780ef83c11857ae79f2feda41e270468dd9b \
--hash=sha256:4efca8f86c54b22348a5467704e3fec767b2db12fc39c6d963168ab1d3fc9135 \
--hash=sha256:53edb4da6925ad13c07b6d26c2a852bd81e364f95301c66e930ab2aef5b5ddd8 \
--hash=sha256:5855f8438a7d1d458206a2466bf82b0f104a3724bf96a1c781ab731e4201731a \
--hash=sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a \
--hash=sha256:5b6d930f030f8ed98e3e6c98ffa0652bdb82601e7a016ec2ab5d7ff23baa78d1 \
--hash=sha256:5bb28c636d87e840583ee3adeb78172efc47c8b26127267f54a9c0ec251d41a9 \
--hash=sha256:60bf42e36abfaf9aff1f50f52644b336d4f0a3fd6d8a60ca0d054ac9f713a864 \
--hash=sha256:611d1ad9a4288cf3e3c16014564df047fe08410e628f89805e475368bd304914 \
--hash=sha256:6300b8454aa6930a24b9618fbb54b5a68135092bc666f7b06901f897fa5c2fee \
--hash=sha256:63f3268ba69ace99cab4e3e3b5840b03340efed0948ab8f78d2fd87ee5442a4f \
--hash=sha256:6557b31b5e2c9ddf0de32a691f2312a32f77cd7681d8af66c2692efdbef84c18 \
--hash=sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8 \
--hash=sha256:6a7fae0dd14cf60ad5ff42baa2e95727c3d81ded453457771d02b7d2b3f9c0c2 \
--hash=sha256:6c4ca60fa24e85fe25b912b01e62cb969d69a23a5d5867682dd3e80b5b02581d \
--hash=sha256:6fcf051089389abe060c9cd7caa212c707e58153afa2c649f00346ce6d260f1b \
--hash=sha256:7d91275b0245b1da4d4cfa07e0faedd5b0812efc15b702576d103293e252af1b \
--hash=sha256:89c687013cb1cd489a0f0ac24febe8c7a666e6e221b783e53ac50ebf68e45d86 \
--hash=sha256:8d206346619592c6200148b01a2142798c989edcb9c896f9ac9722a99d4e77e6 \
--hash=sha256:905fec760bd2fa1388bb5b489ee8ee5f7291d692638ea5f67982d968366bef9f \
--hash=sha256:97383d78eb34da7e1fa37dd273c20ad4320929af65d156e35a5e2d89566d9dfb \
--hash=sha256:984d76483eb32f1bcb536dc27e4ad56bba4baa70be32fa87152832cdd9db0833 \
--hash=sha256:99df47edb6bda1249d3e80fdabb1dab8c08ef3975f69aed437cb69d0a5de1e28 \
--hash=sha256:9f02365d4e99430a12647f09b6cc8bab61a6564363f313126f775eb4f6ef798e \
--hash=sha256:a30e67a65b53ea0a5e62fe23682cfe22712e01f453b95233b25502f7c61cb415 \
--hash=sha256:ab3ef638ace319fa26553db0624c4699e31a28bb2a835c5faca8f8acf6a5a902 \
--hash=sha256:aca6377c0cb8a8253e493c6b451565ac77e98c2951c45f913e0b52facdcff83f \
--hash=sha256:add36cb2dbb8b736611303cd3bfcee00afd96471b09cda130da3581cbdc56a6d \
--hash=sha256:b2f4bf27480f5e5e8ce285a8c8fd176c0b03e93dcc6646477d4630e83440c6a9 \
--hash=sha256:b7f2d075102dc8c794cbde1947378051c4e5180d52d276987b8d28a3bd58c17d \
--hash=sha256:baa1a4e8f868845af802979fcdbf0bb11f94f1cb7ced4c4b8a351bb60d108145 \
--hash=sha256:be98f628055368795d818ebf93da628541e10b75b41c559fdf36d104c5787066 \
--hash=sha256:bf5d821ffabf0ef3533c39c518f3357b171a1651c1ff6827325e4489b0e46c3c \
--hash=sha256:c47adbc92fc1bb2b3274c4b3a43ae0e4573d9fbff4f54cd484555edbf030baf1 \
--hash=sha256:cdfba22ea2f0029c9261a4bd07e830a8da012291fbe44dc794e488b6c9bb353a \
--hash=sha256:d6c7ebd4e944c85e2c3421e612a7057a2f48d478d79e61800d81468a8d842207 \
--hash=sha256:d7f9850398e85aba693bb640262d3611788b1f29a79f0c93c565694658f4071f \
--hash=sha256:d8446c54dc28c01e5a2dbac5a25f071f6653e6e40f3a8818e8b45d790fe6ef53 \
--hash=sha256:deb993cacb280823246a026e3b2d81c493c53de6acfd5e6bfe31ab3402bb37dd \
--hash=sha256:e0f138900af21926a02425cf736db95be9f4af72ba1bb21453432a07f6082134 \
--hash=sha256:e9936f0b261d4df76ad22f8fee3ae83b60d7c3e871292cd42f40b81b70afae85 \
--hash=sha256:f0567c4dc99f264f49fe27da5f735f414c4e7e7dd850cfd8e69f0862d7c74ea9 \
--hash=sha256:f5653a225f31e113b152e56f154ccbe59eeb1c7487b39b9d9f9cdb58e6c79dc5 \
--hash=sha256:f826e31d18b516f653fe296d967d700fddad5901ae07c622bb3705955e1faa94 \
--hash=sha256:f8ba0e8349a38d3001fae7eadded3f6606f0da5d748ee53cc1dab1d6527b9509 \
--hash=sha256:f9081981fe268bd86831e5c75f7de206ef275defcb82bc70740ae6dc507aee51 \
--hash=sha256:fa130dd50c57d53368c9d59395cb5526eda596d3ffe36666cd81a44d56e48872
# via jinja2

View File

@ -0,0 +1,53 @@
"""
Exposes the rule v8_binary_non_pointer_compression, which forces a label
to be compiled without pointer compression.
"""
def _v8_disable_pointer_compression(settings, attr):
return {
"//:v8_enable_pointer_compression": "False",
}
v8_disable_pointer_compression = transition(
implementation = _v8_disable_pointer_compression,
inputs = [],
outputs = ["//: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),
},
# Making this executable means it works with "$ bazel run".
executable = True,
)