SERVER-113557 Bolt binary before we split off symbols (#53518)
GitOrigin-RevId: 069728752853014198cebeeb28d972538d2c8c5a
This commit is contained in:
parent
b7fbac8dd4
commit
88fbe993b7
25
BUILD.bazel
25
BUILD.bazel
@ -8,7 +8,7 @@ load("@rules_pkg//:pkg.bzl", "pkg_tar")
|
|||||||
load("@rules_python//python:defs.bzl", "py_binary")
|
load("@rules_python//python:defs.bzl", "py_binary")
|
||||||
load("//bazel:mongo_js_rules.bzl", "mongo_js_library")
|
load("//bazel:mongo_js_rules.bzl", "mongo_js_library")
|
||||||
load("//bazel/config:render_template.bzl", "render_template")
|
load("//bazel/config:render_template.bzl", "render_template")
|
||||||
load("//bazel/install_rules:bolt.bzl", "bolt_instrument", "bolt_optimize")
|
load("//bazel/install_rules:bolt.bzl", "bolt_instrument")
|
||||||
load("//bazel/install_rules:install_rules.bzl", "TEST_TAGS", "mongo_install")
|
load("//bazel/install_rules:install_rules.bzl", "TEST_TAGS", "mongo_install")
|
||||||
load("//bazel/toolchains/cc/mongo_linux:mongo_gdb.bzl", "setup_gdb_toolchain_aliases")
|
load("//bazel/toolchains/cc/mongo_linux:mongo_gdb.bzl", "setup_gdb_toolchain_aliases")
|
||||||
load("//bazel/toolchains/cc/mongo_linux:mongo_toolchain.bzl", "setup_mongo_toolchain_aliases")
|
load("//bazel/toolchains/cc/mongo_linux:mongo_toolchain.bzl", "setup_mongo_toolchain_aliases")
|
||||||
@ -241,14 +241,12 @@ mongo_install(
|
|||||||
mongo_install(
|
mongo_install(
|
||||||
name = "dist",
|
name = "dist",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
"//src/mongo/db:mongod",
|
||||||
"//src/mongo/installer/compass:compass_files",
|
"//src/mongo/installer/compass:compass_files",
|
||||||
"//src/mongo/s:mongos",
|
"//src/mongo/s:mongos",
|
||||||
] + select({
|
] + select({
|
||||||
"@platforms//os:windows": ["@local_windows_msvc//:vc_redist_x64"],
|
"@platforms//os:windows": ["@local_windows_msvc//:vc_redist_x64"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}) + select({
|
|
||||||
"//bazel/config:bolt_profile_use_enabled": ["//:bolt_optimized_mongod"],
|
|
||||||
"//conditions:default": ["//src/mongo/db:mongod"],
|
|
||||||
}),
|
}),
|
||||||
include_files = select({
|
include_files = select({
|
||||||
"//bazel/config:al2023_x86_64": {
|
"//bazel/config:al2023_x86_64": {
|
||||||
@ -331,6 +329,7 @@ copy_to_directory(
|
|||||||
mongo_install(
|
mongo_install(
|
||||||
name = "dist-test",
|
name = "dist-test",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
"//src/mongo/db:mongod",
|
||||||
"//src/mongo/db:mongotrafficreader",
|
"//src/mongo/db:mongotrafficreader",
|
||||||
"//src/mongo/db/query/query_tester:mongotest",
|
"//src/mongo/db/query/query_tester:mongotest",
|
||||||
"//src/mongo/db/query/search/mongotmock",
|
"//src/mongo/db/query/search/mongotmock",
|
||||||
@ -352,9 +351,6 @@ mongo_install(
|
|||||||
}) + select({
|
}) + select({
|
||||||
"//bazel/config:include_mongot_enabled": ["//:mongot_folder"],
|
"//bazel/config:include_mongot_enabled": ["//:mongot_folder"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}) + select({
|
|
||||||
"//bazel/config:bolt_profile_use_enabled": ["//:bolt_optimized_mongod"],
|
|
||||||
"//conditions:default": ["//src/mongo/db:mongod"],
|
|
||||||
}),
|
}),
|
||||||
include_files = select({
|
include_files = select({
|
||||||
"//bazel/config:al2023_x86_64": {
|
"//bazel/config:al2023_x86_64": {
|
||||||
@ -618,21 +614,6 @@ bolt_instrument(
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
bolt_optimize(
|
|
||||||
name = "bolt_optimized_mongod",
|
|
||||||
binary_to_optimize = "//src/mongo/db:mongod",
|
|
||||||
exec_properties = {
|
|
||||||
"no-cache": "1",
|
|
||||||
"no-remote": "1",
|
|
||||||
"local": "1",
|
|
||||||
},
|
|
||||||
perf_data = "@bolt_data//:bolt_fdata",
|
|
||||||
target_compatible_with = select({
|
|
||||||
"//bazel/config:bolt_profile_use_enabled": [],
|
|
||||||
"//conditions:default": ["@platforms//:incompatible"],
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "clang_tidy_config_files",
|
name = "clang_tidy_config_files",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
|||||||
@ -2543,8 +2543,13 @@ bool_flag(
|
|||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "bolt_profile_use_enabled",
|
name = "bolt_profile_use_enabled",
|
||||||
|
constraint_values = [
|
||||||
|
"@platforms//os:linux",
|
||||||
|
"@platforms//cpu:aarch64",
|
||||||
|
],
|
||||||
flag_values = {
|
flag_values = {
|
||||||
"//bazel/config:bolt_profile_use": "True",
|
"//bazel/config:bolt_profile_use": "True",
|
||||||
|
"//bazel/config:compiler_type": "clang",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -35,17 +35,17 @@ bolt_instrument = rule(
|
|||||||
attrs = {
|
attrs = {
|
||||||
"binary_to_instrument": attr.label(allow_files = True),
|
"binary_to_instrument": attr.label(allow_files = True),
|
||||||
"instrumentation_output_file": attr.string(),
|
"instrumentation_output_file": attr.string(),
|
||||||
"_bolt_binary": attr.label(allow_single_file = True, default = "@bolt_binaries//:bolt", executable = True, cfg = "host"),
|
"_bolt_binary": attr.label(allow_single_file = True, default = "@bolt_binaries//:bolt", executable = True, cfg = "exec"),
|
||||||
"_bolt_needed_lib": attr.label(allow_single_file = True, default = "@bolt_binaries//:libbolt_rt_instr"),
|
"_bolt_needed_lib": attr.label(allow_single_file = True, default = "@bolt_binaries//:libbolt_rt_instr"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
def _bolt_optimize_impl(ctx):
|
def _bolt_optimize_impl(ctx):
|
||||||
input_binary = ctx.files.binary_to_optimize[0]
|
input_binary = ctx.files.binary_to_optimize[0]
|
||||||
output_binary = ctx.actions.declare_file(ctx.files.binary_to_optimize[0].basename)
|
output_binary = ctx.actions.declare_file(ctx.label.name + "/" + input_binary.basename)
|
||||||
functions_to_skip = ",".join(SKIP_FUNCTIONS)
|
functions_to_skip = ",".join(SKIP_FUNCTIONS)
|
||||||
ctx.actions.run(
|
ctx.actions.run(
|
||||||
inputs = [input_binary],
|
inputs = [input_binary, ctx.files.perf_data[0]],
|
||||||
outputs = [output_binary],
|
outputs = [output_binary],
|
||||||
executable = ctx.executable._bolt_binary,
|
executable = ctx.executable._bolt_binary,
|
||||||
arguments = [
|
arguments = [
|
||||||
@ -62,17 +62,36 @@ def _bolt_optimize_impl(ctx):
|
|||||||
"-dyno-stats",
|
"-dyno-stats",
|
||||||
"--lite",
|
"--lite",
|
||||||
"--update-debug-sections",
|
"--update-debug-sections",
|
||||||
|
# objcopy will leave bad data like program headers in the .debug file without this
|
||||||
|
"--use-gnu-stack",
|
||||||
"-skip-funcs=" + functions_to_skip,
|
"-skip-funcs=" + functions_to_skip,
|
||||||
],
|
],
|
||||||
mnemonic = "BoltOptimize",
|
mnemonic = "BoltOptimize",
|
||||||
|
execution_requirements = {
|
||||||
|
"no-cache": "1",
|
||||||
|
"no-sandbox": "1",
|
||||||
|
"no-remote": "1",
|
||||||
|
"local": "1",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
return DefaultInfo(files = depset([output_binary]))
|
|
||||||
|
return [
|
||||||
|
DefaultInfo(files = depset([output_binary]), executable = output_binary),
|
||||||
|
ctx.attr.binary_to_optimize[CcInfo],
|
||||||
|
ctx.attr.binary_to_optimize[DebugPackageInfo],
|
||||||
|
RunEnvironmentInfo(
|
||||||
|
environment = ctx.attr.binary_to_optimize[RunEnvironmentInfo].environment,
|
||||||
|
inherited_environment = ctx.attr.binary_to_optimize[RunEnvironmentInfo].inherited_environment,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
bolt_optimize = rule(
|
bolt_optimize = rule(
|
||||||
implementation = _bolt_optimize_impl,
|
implementation = _bolt_optimize_impl,
|
||||||
attrs = {
|
attrs = {
|
||||||
"binary_to_optimize": attr.label(allow_files = True),
|
"binary_to_optimize": attr.label(allow_files = True, providers = [CcInfo]),
|
||||||
"perf_data": attr.label(allow_single_file = True),
|
"perf_data": attr.label(allow_single_file = True),
|
||||||
"_bolt_binary": attr.label(allow_single_file = True, default = "@bolt_binaries//:bolt", executable = True, cfg = "host"),
|
"_bolt_binary": attr.label(allow_single_file = True, default = "@bolt_binaries//:bolt", executable = True, cfg = "exec"),
|
||||||
},
|
},
|
||||||
|
executable = True,
|
||||||
|
provides = [CcInfo, DefaultInfo],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ load(
|
|||||||
)
|
)
|
||||||
load("@bazel_skylib//lib:selects.bzl", "selects")
|
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
|
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
|
||||||
|
load("//bazel/install_rules:bolt.bzl", "bolt_optimize")
|
||||||
load("@com_github_grpc_grpc//bazel:generate_cc.bzl", "generate_cc")
|
load("@com_github_grpc_grpc//bazel:generate_cc.bzl", "generate_cc")
|
||||||
load("@poetry//:dependencies.bzl", "dependency")
|
load("@poetry//:dependencies.bzl", "dependency")
|
||||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_shared_library")
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_shared_library")
|
||||||
@ -545,6 +546,7 @@ def _mongo_cc_binary_and_test(
|
|||||||
skip_global_deps = [],
|
skip_global_deps = [],
|
||||||
env = {},
|
env = {},
|
||||||
_program_type = "",
|
_program_type = "",
|
||||||
|
bolt_profile = None,
|
||||||
skip_windows_crt_flags = False,
|
skip_windows_crt_flags = False,
|
||||||
auto_header = True,
|
auto_header = True,
|
||||||
srcs_select = None,
|
srcs_select = None,
|
||||||
@ -720,9 +722,24 @@ def _mongo_cc_binary_and_test(
|
|||||||
|
|
||||||
if _program_type == "binary":
|
if _program_type == "binary":
|
||||||
cc_binary(**args)
|
cc_binary(**args)
|
||||||
|
|
||||||
|
if bolt_profile != None:
|
||||||
|
bolt_optimize(
|
||||||
|
name = name + "_bolt",
|
||||||
|
binary_to_optimize = ":" + name + WITH_DEBUG_SUFFIX,
|
||||||
|
perf_data = bolt_profile,
|
||||||
|
target_compatible_with = select({
|
||||||
|
"//bazel/config:bolt_profile_use_enabled": [],
|
||||||
|
"//conditions:default": ["@platforms//:incompatible"],
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
extract_debuginfo_binary(
|
extract_debuginfo_binary(
|
||||||
name = name,
|
name = name,
|
||||||
binary_with_debug = ":" + name + WITH_DEBUG_SUFFIX,
|
binary_with_debug = select({
|
||||||
|
"//bazel/config:bolt_profile_use_enabled": ":" + name + "_bolt",
|
||||||
|
"//conditions:default": ":" + name + WITH_DEBUG_SUFFIX,
|
||||||
|
}) if bolt_profile != None else ":" + name + WITH_DEBUG_SUFFIX,
|
||||||
type = "program",
|
type = "program",
|
||||||
tags = original_tags + ["final_target"],
|
tags = original_tags + ["final_target"],
|
||||||
enabled = SEPARATE_DEBUG_ENABLED,
|
enabled = SEPARATE_DEBUG_ENABLED,
|
||||||
@ -766,6 +783,7 @@ def mongo_cc_binary(
|
|||||||
exec_properties = {},
|
exec_properties = {},
|
||||||
skip_global_deps = [],
|
skip_global_deps = [],
|
||||||
env = {},
|
env = {},
|
||||||
|
bolt_profile = None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""Wrapper around cc_binary.
|
"""Wrapper around cc_binary.
|
||||||
|
|
||||||
@ -818,6 +836,7 @@ def mongo_cc_binary(
|
|||||||
skip_global_deps,
|
skip_global_deps,
|
||||||
env,
|
env,
|
||||||
_program_type = "binary",
|
_program_type = "binary",
|
||||||
|
bolt_profile = bolt_profile,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -2858,6 +2858,7 @@ mongo_cc_binary(
|
|||||||
srcs = [
|
srcs = [
|
||||||
"mongod.cpp",
|
"mongod.cpp",
|
||||||
],
|
],
|
||||||
|
bolt_profile = "@bolt_data//:bolt_fdata",
|
||||||
cxxopts = select({
|
cxxopts = select({
|
||||||
"//bazel/config:pgo_profile_generate_clang_enabled": [
|
"//bazel/config:pgo_profile_generate_clang_enabled": [
|
||||||
"-fprofile-generate=mongod_perf",
|
"-fprofile-generate=mongod_perf",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user