mirror of https://github.com/mongodb/mongo
SERVER-99213 Add flag to enable building dwp files (#35182)
GitOrigin-RevId: b0d5799813f8e65c868743edff8ea4a201de8d98
This commit is contained in:
parent
1587416858
commit
ba1a66200f
8
.bazelrc
8
.bazelrc
|
|
@ -65,7 +65,9 @@ common --strategy=StripDebuginfo=local
|
|||
common --strategy=ExtractDebuginfo=local
|
||||
common --strategy=TestRunner=local
|
||||
common --strategy=CoverageReport=local
|
||||
common --modify_execution_info=^(TestRunner|CppLink|CppArchive|SolibSymlink|ExtractDebuginfo|StripDebuginfo)$=+no-remote-cache
|
||||
common --strategy=CcGenerateIntermediateDwp=local
|
||||
common --strategy=CcGenerateDwp=local
|
||||
common --modify_execution_info=^(TestRunner|CppLink|CppArchive|SolibSymlink|ExtractDebuginfo|StripDebuginfo|CcGenerateIntermediateDwp|CcGenerateDwp)$=+no-remote-cache
|
||||
|
||||
# Aliases for config flags
|
||||
common --flag_alias=linkstatic=//bazel/config:linkstatic
|
||||
|
|
@ -123,6 +125,7 @@ common --flag_alias=ubsan=//bazel/config:ubsan
|
|||
common --flag_alias=dbg_level=//bazel/config:dbg_level
|
||||
common --flag_alias=mongo_toolchain_version=//bazel/config:mongo_toolchain_version
|
||||
common --flag_alias=simple_build_id=//bazel/config:simple_build_id
|
||||
common --flag_alias=create_dwp=//bazel/config:create_dwp
|
||||
|
||||
#############################################################################################################################
|
||||
# BUILD 'PROFILES' - this is the area to set up configurations of flags to be used by developers.
|
||||
|
|
@ -267,6 +270,7 @@ common:evg --config=opt
|
|||
common:evg --//bazel/config:opt=auto
|
||||
common:evg --//bazel/config:separate_debug=True
|
||||
common:evg --fission=no
|
||||
common:evg --enable_platform_specific_config=true
|
||||
|
||||
--config=evg_crypt
|
||||
common:evg_crypt --config=evg
|
||||
|
|
@ -339,8 +343,10 @@ common:windows --features=-dynamic_link_msvcrt
|
|||
|
||||
# Only use fission and debug compression on Linux
|
||||
common:windows --fission=no
|
||||
common:windows --//bazel/config:create_dwp=False
|
||||
common:windows --//bazel/config:compress_debug_compile=False
|
||||
common:macos --fission=no
|
||||
common:macos --//bazel/config:create_dwp=False
|
||||
common:macos --//bazel/config:compress_debug_compile=False
|
||||
|
||||
# Dynamic linking on Windows (DLL generation) is currently not supported.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ load(
|
|||
"build_otel",
|
||||
"compiler_type",
|
||||
"compress_debug_compile",
|
||||
"create_dwp",
|
||||
"dbg",
|
||||
"dbg_level",
|
||||
"debug_symbols",
|
||||
|
|
@ -2593,6 +2594,19 @@ config_setting(
|
|||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "linux_clang_fission",
|
||||
constraint_values = [
|
||||
"@platforms//os:linux",
|
||||
],
|
||||
flag_values = {
|
||||
"//bazel/config:compiler_type": "clang",
|
||||
},
|
||||
values = {
|
||||
"fission": "yes",
|
||||
},
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "linux_gcc_fission_x86_64",
|
||||
match_all = [
|
||||
|
|
@ -2609,6 +2623,54 @@ selects.config_setting_group(
|
|||
],
|
||||
)
|
||||
|
||||
# --------------------------------------
|
||||
# create_dwp
|
||||
# --------------------------------------
|
||||
|
||||
bool_flag(
|
||||
name = "create_dwp",
|
||||
build_setting_default = False,
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "create_dwp_enabled",
|
||||
flag_values = {
|
||||
"//bazel/config:create_dwp": "True",
|
||||
},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "create_dwp_disabled",
|
||||
flag_values = {
|
||||
"//bazel/config:create_dwp": "False",
|
||||
},
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "dwp_supported",
|
||||
match_any = [
|
||||
":clang_dwp_supported",
|
||||
":gcc_dwp_supported",
|
||||
],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "gcc_dwp_supported",
|
||||
match_all = [
|
||||
":linux_gcc_fission",
|
||||
":dwarf_version_4",
|
||||
":create_dwp_enabled",
|
||||
],
|
||||
)
|
||||
|
||||
selects.config_setting_group(
|
||||
name = "clang_dwp_supported",
|
||||
match_all = [
|
||||
":linux_clang_fission",
|
||||
":create_dwp_enabled",
|
||||
],
|
||||
)
|
||||
|
||||
# --------------------------------------
|
||||
# compress_debug_compile
|
||||
# --------------------------------------
|
||||
|
|
|
|||
|
|
@ -706,3 +706,17 @@ server_js = rule(
|
|||
implementation = lambda ctx: server_js_provider(enabled = ctx.build_setting_value),
|
||||
build_setting = config.bool(flag = True),
|
||||
)
|
||||
|
||||
# =========
|
||||
# create_dwp
|
||||
# =========
|
||||
|
||||
create_dwp_provider = provider(
|
||||
doc = "Create dwp files when using install targets",
|
||||
fields = ["enabled"],
|
||||
)
|
||||
|
||||
create_dwp = rule(
|
||||
implementation = lambda ctx: create_dwp_provider(enabled = ctx.build_setting_value),
|
||||
build_setting = config.bool(flag = True),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ load("//bazel:mongo_src_rules.bzl", "SANITIZER_DATA", "SANITIZER_ENV")
|
|||
load("//bazel:separate_debug.bzl", "TagInfo")
|
||||
load("//bazel/install_rules:pretty_printer_tests.bzl", "mongo_pretty_printer_test")
|
||||
load("//bazel/install_rules:providers.bzl", "TestBinaryInfo")
|
||||
load("//bazel/toolchains/cc:mongo_errors.bzl", "DWP_ERROR_MESSAGE")
|
||||
|
||||
# Used to skip rules on certain OS architectures
|
||||
def _empty_rule_impl(ctx):
|
||||
|
|
@ -139,7 +140,7 @@ def is_debug_file(ctx, basename):
|
|||
"""
|
||||
linux_constraint, macos_constraint, windows_constraint = get_constraints(ctx)
|
||||
if ctx.target_platform_has_constraint(linux_constraint):
|
||||
return basename.endswith(".debug")
|
||||
return basename.endswith(".debug") or basename.endswith(".dwp")
|
||||
elif ctx.target_platform_has_constraint(macos_constraint):
|
||||
return basename.endswith(".dSYM")
|
||||
elif ctx.target_platform_has_constraint(windows_constraint):
|
||||
|
|
@ -178,6 +179,11 @@ def sort_file(ctx, file, install_dir, file_map, is_directory):
|
|||
_, macos_constraint, _ = get_constraints(ctx)
|
||||
basename = paths.basename(file)
|
||||
bin_install = install_dir + "/bin/" + basename
|
||||
if bin_install.endswith(".dwp"):
|
||||
# Due to us creating our binaries using the _with_debug name
|
||||
# the dwp files also contain it. Strip the _with_debug from the name
|
||||
bin_install = bin_install.replace("_with_debug.dwp", ".dwp")
|
||||
|
||||
lib_install = install_dir + "/lib/" + basename
|
||||
|
||||
if is_binary_file(ctx, basename) or basename.endswith(".py"):
|
||||
|
|
@ -215,10 +221,15 @@ def mongo_install_rule_impl(ctx):
|
|||
}
|
||||
test_files = []
|
||||
outputs = []
|
||||
dwps = []
|
||||
install_dir = ctx.label.name
|
||||
|
||||
# sort direct sources
|
||||
for input_bin in ctx.attr.srcs:
|
||||
if DebugPackageInfo in input_bin and ctx.attr.create_dwp and ctx.attr.debug != "stripped":
|
||||
bin = input_bin[DebugPackageInfo].dwp_file
|
||||
dwps.append(bin)
|
||||
sort_file(ctx, bin.path, install_dir, file_map, bin.is_directory)
|
||||
test_files.extend(input_bin[TestBinaryInfo].test_binaries.to_list())
|
||||
for bin in input_bin.files.to_list():
|
||||
sort_file(ctx, bin.path, install_dir, file_map, bin.is_directory)
|
||||
|
|
@ -240,6 +251,10 @@ def mongo_install_rule_impl(ctx):
|
|||
files.extend(src_map[key])
|
||||
for file in files:
|
||||
filename = file.split("/")[-1]
|
||||
|
||||
# Due to us creating our binaries using the _with_debug name
|
||||
# the dwp files also contain it. Strip the _with_debug from the name
|
||||
filename = filename.replace("_with_debug.dwp", ".dwp")
|
||||
sort_file(ctx, file, install_dir, file_map, file_directory_map[filename])
|
||||
for file, folder in src_map["roots"].items():
|
||||
filename = file.split("/")[-1]
|
||||
|
|
@ -337,7 +352,7 @@ def mongo_install_rule_impl(ctx):
|
|||
inputs = depset(direct = input_deps, transitive = [
|
||||
ctx.attr._install_script.files,
|
||||
python.files,
|
||||
] + [f.files for f in ctx.attr.srcs] + [r.files for r in ctx.attr.root_files.keys()] + [dep[MongoInstallInfo].deps_files for dep in ctx.attr.deps] + [dep[DefaultInfo].files for dep in ctx.attr.deps])
|
||||
] + [f.files for f in ctx.attr.srcs] + [r.files for r in ctx.attr.root_files.keys()] + [dep[MongoInstallInfo].deps_files for dep in ctx.attr.deps] + [dep[DefaultInfo].files for dep in ctx.attr.deps] + [depset(dwps)])
|
||||
|
||||
if outputs:
|
||||
ctx.actions.run(
|
||||
|
|
@ -391,6 +406,7 @@ mongo_install_rule = rule(
|
|||
"debug": attr.string(),
|
||||
"root_files": attr.label_keyed_string_dict(allow_files = True),
|
||||
"publish_debug_in_stripped": attr.bool(),
|
||||
"create_dwp": attr.bool(),
|
||||
"_install_script": attr.label(allow_single_file = True, default = "//bazel/install_rules:install_rules.py"),
|
||||
"_linux_constraint": attr.label(default = "@platforms//os:linux"),
|
||||
"_macos_constraint": attr.label(default = "@platforms//os:macos"),
|
||||
|
|
@ -498,6 +514,10 @@ def mongo_install(
|
|||
srcs = modified_srcs,
|
||||
root_files = root_files,
|
||||
debug = debug,
|
||||
create_dwp = select({
|
||||
"//bazel/config:dwp_supported": True,
|
||||
"//bazel/config:create_dwp_disabled": False,
|
||||
}, no_match_error = DWP_ERROR_MESSAGE),
|
||||
deps = select({
|
||||
"//bazel/config:build_enterprise_enabled": dep_targets,
|
||||
"//conditions:default": community_dep_targets,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ os.makedirs(install_link, exist_ok=True)
|
|||
def install(src, install_type):
|
||||
install_dst = os.path.join(args.install_dir, install_type, os.path.basename(src))
|
||||
link_dst = os.path.join(install_link, install_type, os.path.basename(src))
|
||||
if src.endswith(".dwp"):
|
||||
# Due to us creating our binaries using the _with_debug name
|
||||
# the dwp files also contain it. Strip the _with_debug from the name
|
||||
install_dst = install_dst.replace("_with_debug.dwp", ".dwp")
|
||||
link_dst = link_dst.replace("_with_debug.dwp", ".dwp")
|
||||
|
||||
for dst in [install_dst, link_dst]:
|
||||
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
||||
|
|
|
|||
|
|
@ -365,6 +365,7 @@ def linux_extraction(ctx, cc_toolchain, inputs):
|
|||
inherited_environment = ctx.attr.binary_with_debug[RunEnvironmentInfo].inherited_environment,
|
||||
),
|
||||
]
|
||||
provided_info += [ctx.attr.binary_with_debug[DebugPackageInfo]]
|
||||
|
||||
if ctx.attr.cc_shared_library != None:
|
||||
provided_info.append(
|
||||
|
|
|
|||
|
|
@ -62,3 +62,16 @@ Error:
|
|||
|
||||
python buildscripts/install_bazel.py
|
||||
"""
|
||||
|
||||
DWP_ERROR_MESSAGE = """
|
||||
Error:
|
||||
to create dwp files you must use one of these configurations:
|
||||
--compiler_type=clang
|
||||
--fission=yes
|
||||
--create_dwp=True
|
||||
[OR]
|
||||
--compiler_type=gcc
|
||||
--fission=yes
|
||||
--dwarf_version=4
|
||||
--create_dwp=True
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ mongo_linux_cc_toolchain_config(
|
|||
"nm": "{version}/bin/nm",
|
||||
"ld": "{version}/bin/ld",
|
||||
"as": "{version}/bin/as",
|
||||
"dwp": "{version}/bin/dwp",
|
||||
"dwp": "{version}/bin/llvm-dwp",
|
||||
"objcopy": "{version}/bin/llvm-objcopy",
|
||||
"objdump": "{version}/bin/objdump",
|
||||
"strip": "{version}/bin/strip",
|
||||
|
|
|
|||
|
|
@ -69,6 +69,13 @@ while read -r core_file; do
|
|||
cp "$debug_file" "$unittest_bin_dir"
|
||||
fi
|
||||
|
||||
# Include any dwp symbol files to go with the .debug files
|
||||
dwp_file=$binary_file_location.dwp
|
||||
if [ -f "$dwp_file" ]; then
|
||||
echo "dwp Copy $dwp_file to $unittest_bin_dir"
|
||||
cp "$dwp_file" "$unittest_bin_dir"
|
||||
fi
|
||||
|
||||
# On macOS, these are called .dSYM and they are directories
|
||||
dsym_dir=$binary_file_location.dSYM
|
||||
if [ -d "$dsym_dir" ]; then
|
||||
|
|
|
|||
|
|
@ -316,10 +316,10 @@ mongo_cc_library(
|
|||
"socket_exception.h",
|
||||
"socket_utils.cpp",
|
||||
"socket_utils.h",
|
||||
":hostandport_gen",
|
||||
"//src/mongo/util/concurrency:value.h",
|
||||
],
|
||||
deps = [
|
||||
":hostandport_impl",
|
||||
"//src/mongo/db:server_base",
|
||||
"//src/mongo/util:winutil",
|
||||
"//src/mongo/util/concurrency:spin_lock",
|
||||
|
|
|
|||
Loading…
Reference in New Issue