SERVER-86472 port tcmalloc (google) to bazel build (#19621)

GitOrigin-RevId: 537c210cca33e1f18d54b43c5212e215037a4ac1
This commit is contained in:
Daniel Moody 2024-03-08 21:04:17 -06:00 committed by MongoDB Bot
parent 2c165f3194
commit 3aaeb68185
11 changed files with 632 additions and 49 deletions

View File

@ -37,6 +37,7 @@ build --experimental_remote_cache_compression=true
build --grpc_keepalive_time=30s
build --nolegacy_important_outputs
build --bes_keywords=repo:mongo
build --jobs=200
common --remote_upload_local_results=False
# if you don't have access to the remote execution cluster above, use the local config
@ -54,6 +55,8 @@ build:local --tls_client_key=
build:local --experimental_remote_cache_compression=false
build:local --grpc_keepalive_time=0s
build:local --legacy_important_outputs
build:local --//bazel/config:local_build=True
build:local --jobs=auto
# Disable remote execution and caching for public releases
--config=public-release

View File

@ -1808,7 +1808,7 @@ env.AddMethod(conf_error, 'ConfError')
# Normalize the VERBOSE Option, and make its value available as a
# function.
if env['VERBOSE'] == "auto":
env['VERBOSE'] = not sys.stdout.isatty()
env['VERBOSE'] = not sys.stdout.isatty() and env.get('__NINJA_NO') != "1"
else:
try:
env['VERBOSE'] = to_boolean(env['VERBOSE'])
@ -2138,12 +2138,7 @@ except (ValueError, IndexError):
if get_option('allocator') == "auto":
if env.TargetOSIs('linux') and env['TARGET_ARCH'] in ('x86_64', 'aarch64'):
# TODO SERVER-86472 make bazel support both tcmalloc implementations
if env.get("BAZEL_BUILD_ENABLED"):
env['MONGO_ALLOCATOR'] = "tcmalloc-gperf"
else:
env['MONGO_ALLOCATOR'] = "tcmalloc-google"
env['MONGO_ALLOCATOR'] = "tcmalloc-google"
# googles tcmalloc uses the membarrier() system call which was added in Linux 4.3,
# so fall back to gperf implementation for older kernels

View File

@ -12,6 +12,7 @@ load(
"libunwind",
"linker",
"linkstatic",
"local_build",
"lsan",
"msan",
"opt",
@ -576,46 +577,124 @@ allocator(
)
config_setting(
name = "auto_allocator_linux",
constraint_values = [
"@platforms//os:linux",
],
name = "_tcmalloc_google",
flag_values = {
"//bazel/config:allocator": "auto",
"//bazel/config:allocator": "tcmalloc-google",
},
)
config_setting(
name = "auto_allocator_windows",
constraint_values = [
"@platforms//os:windows",
],
name = "_tcmalloc_gperf",
flag_values = {
"//bazel/config:allocator": "auto",
"//bazel/config:allocator": "tcmalloc-gperf",
},
)
config_setting(
name = "auto_allocator",
flag_values = {
"//bazel/config:allocator": "auto",
},
)
config_setting(
name = "system_allocator",
name = "_system_allocator",
flag_values = {
"//bazel/config:allocator": "system",
},
)
config_setting(
name = "tcmalloc_allocator",
name = "_auto_allocator",
flag_values = {
"//bazel/config:allocator": "tcmalloc",
"//bazel/config:allocator": "auto",
},
)
selects.config_setting_group(
name = "_tcmalloc_google_supported_archs",
match_any = [
"@platforms//cpu:aarch64",
"@platforms//cpu:x86_64",
],
)
selects.config_setting_group(
name = "_tcmalloc_google_selected_by_auto",
match_all = [
":_auto_allocator",
"@platforms//os:linux",
":_tcmalloc_google_supported_archs",
],
)
selects.config_setting_group(
name = "_tcmalloc_gperf_auto_supported",
match_any = [
"@platforms//os:windows",
"@platforms//cpu:ppc64le",
"@platforms//cpu:s390x",
],
)
selects.config_setting_group(
name = "_tcmalloc_gperf_supported_os",
match_any = [
"@platforms//os:windows",
"@platforms//os:linux",
],
)
selects.config_setting_group(
name = "_tcmalloc_gperf_selected_by_auto",
match_all = [
":_auto_allocator",
":_tcmalloc_gperf_auto_supported",
],
)
selects.config_setting_group(
name = "_system_allocator_enabled_by_auto",
match_all = [
":_auto_allocator",
"@platforms//os:macos",
],
)
selects.config_setting_group(
name = "_tcmalloc_google_selected",
match_any = [
":_tcmalloc_google_selected_by_auto",
":_tcmalloc_google",
],
)
selects.config_setting_group(
name = "_tcmalloc_gperf_selected",
match_any = [
":_tcmalloc_gperf_selected_by_auto",
":_tcmalloc_gperf",
],
)
selects.config_setting_group(
name = "system_allocator_enabled",
match_any = [
":_system_allocator_enabled_by_auto",
":_system_allocator",
],
)
selects.config_setting_group(
name = "tcmalloc_google_enabled",
match_all = [
":_tcmalloc_google_selected",
"@platforms//os:linux",
":_tcmalloc_google_supported_archs",
],
)
selects.config_setting_group(
name = "tcmalloc_gperf_enabled",
match_all = [
":_tcmalloc_gperf_selected",
":_tcmalloc_gperf_supported_os",
],
)
# --------------------------------------
# gdbserver options
# --------------------------------------
@ -1006,7 +1085,7 @@ selects.config_setting_group(
name = "sanitize_address_required_settings",
match_all = [
":asan_enabled",
":system_allocator",
":system_allocator_enabled",
],
)
@ -1014,7 +1093,7 @@ selects.config_setting_group(
name = "sanitize_memory_required_settings",
match_all = [
":msan_enabled",
":system_allocator",
":system_allocator_enabled",
],
)
@ -1296,3 +1375,19 @@ selects.config_setting_group(
":linkstatic_disabled",
],
)
# --------------------------------------
# local_build
# --------------------------------------
local_build(
name = "local_build",
build_setting_default = False,
)
config_setting(
name = "local_build_enabled",
flag_values = {
"//bazel/config:local_build": "True",
},
)

View File

@ -87,7 +87,7 @@ spider_monkey_dbg = rule(
# allocator
# =========
allocator_values = ["auto", "system", "tcmalloc"]
allocator_values = ["auto", "system", "tcmalloc-gperf", "tcmalloc-google"]
allocator_provider = provider(
doc = "Allocator to use (use \"auto\" for best choice for current platform)",
@ -440,3 +440,16 @@ release = rule(
implementation = lambda ctx: release_provider(enabled = ctx.build_setting_value),
build_setting = config.bool(flag = True),
)
# =========
# local_build
# =========
local_build_provider = provider(
doc = """Allows configurations based on local builds""",
fields = ["enabled"],
)
local_build = rule(
implementation = lambda ctx: local_build_provider(enabled = ctx.build_setting_value),
build_setting = config.bool(flag = True),
)

View File

@ -493,10 +493,22 @@ SEPARATE_DEBUG_ENABLED = select({
"//conditions:default": False,
})
TCMALLOC_ERROR_MESSAGE = (
"\nError:\n" +
" Build failed due to unsupported platform for current allocator selection:\n" +
" '--//bazel/config:allocator=tcmalloc-google' is supported on linux with aarch64 or x86_64\n" +
" '--//bazel/config:allocator=tcmalloc-gperf' is supported on windows or linux, but not macos\n" +
" '--//bazel/config:allocator=system' can be used on any platform\n"
)
TCMALLOC_DEPS = select({
"//bazel/config:tcmalloc_allocator": ["//src/third_party/gperftools:tcmalloc_minimal"],
"//bazel/config:auto_allocator_windows": ["//src/third_party/gperftools:tcmalloc_minimal"],
"//bazel/config:auto_allocator_linux": ["//src/third_party/gperftools:tcmalloc_minimal"],
"//bazel/config:tcmalloc_google_enabled": ["//src/third_party/tcmalloc:tcmalloc"],
"//bazel/config:tcmalloc_gperf_enabled": ["//src/third_party/gperftools:tcmalloc_minimal"],
"//bazel/config:system_allocator_enabled": [],
}, no_match_error = TCMALLOC_ERROR_MESSAGE)
TCMALLOC_DEFINES = select({
"//bazel/config:tcmalloc_google_enabled": ["ABSL_ALLOCATOR_NOTHROW"],
"//conditions:default": [],
})
@ -527,7 +539,7 @@ DETECT_ODR_VIOLATIONS_LINKFLAGS = select({
MONGO_GLOBAL_DEFINES = DEBUG_DEFINES + LIBCXX_DEFINES + ADDRESS_SANITIZER_DEFINES + \
THREAD_SANITIZER_DEFINES + UNDEFINED_SANITIZER_DEFINES + GLIBCXX_DEBUG_DEFINES + \
WINDOWS_DEFINES
WINDOWS_DEFINES + TCMALLOC_DEFINES
MONGO_GLOBAL_COPTS = ["-Isrc"] + WINDOWS_COPTS + LIBCXX_COPTS + ADDRESS_SANITIZER_COPTS + \
MEMORY_SANITIZER_COPTS + FUZZER_SANITIZER_COPTS + UNDEFINED_SANITIZER_COPTS + \
@ -615,7 +627,8 @@ def mongo_cc_library(
includes = [],
linkstatic = False,
local_defines = [],
mongo_api_name = None):
mongo_api_name = None,
target_compatible_with = []):
"""Wrapper around cc_library.
Args:
@ -642,14 +655,14 @@ def mongo_cc_library(
This can be configured via //config/bazel:linkstatic.""")
# Avoid injecting into unwind/libunwind_asm to avoid a circular dependency.
if name not in ["unwind", "tcmalloc_minimal"]:
if name not in ["unwind", "tcmalloc_minimal"] and not native.package_name().startswith("src/third_party/tcmalloc") and not native.package_name().startswith("src/third_party/abseil-cpp"):
deps += LIBUNWIND_DEPS
local_defines += LIBUNWIND_DEFINES
fincludes_copt = force_includes_copt(native.package_name(), name)
fincludes_hdr = force_includes_hdr(native.package_name(), name)
if name != "tcmalloc_minimal":
if name != "tcmalloc_minimal" and not name.startswith("tcmalloc") and not name.startswith("absl"):
deps += TCMALLOC_DEPS
if mongo_api_name:
@ -751,6 +764,7 @@ def mongo_cc_library(
"//bazel/config:shared_archive_enabled": ["supports_pic", "pic"],
"//conditions:default": ["pie"],
}),
target_compatible_with = target_compatible_with,
)
# Creates a shared library version of our target only if //bazel/config:linkstatic_disabled is true.
@ -793,7 +807,8 @@ def mongo_cc_binary(
linkopts = [],
includes = [],
linkstatic = False,
local_defines = []):
local_defines = [],
target_compatible_with = []):
"""Wrapper around cc_binary.
Args:
@ -854,6 +869,7 @@ def mongo_cc_binary(
"//bazel/config:linkstatic_disabled": deps,
"//conditions:default": [],
}),
target_compatible_with = target_compatible_with,
)
extract_debuginfo_binary(

View File

@ -3,6 +3,18 @@ load("//bazel/platforms:remote_execution_containers.bzl", "REMOTE_EXECUTION_CONT
package(default_visibility = ["//visibility:public"])
constraint_setting(name = "tcmalloc_kernel_version")
constraint_value(
name = "kernel_version_4_4_or_greater",
constraint_setting = ":tcmalloc_kernel_version",
)
constraint_value(
name = "kernel_version_less_than_4_4",
constraint_setting = ":tcmalloc_kernel_version",
)
[
platform(
name = distro_or_os + "_" + arch + "_" + compiler,
@ -10,6 +22,7 @@ package(default_visibility = ["//visibility:public"])
"@platforms//os:linux",
"@platforms//cpu:arm64" if arch == "arm64" else "@platforms//cpu:x86_64",
"@bazel_tools//tools/cpp:" + compiler,
":kernel_version_4_4_or_greater", # remote execution platforms assume a given kernel version
],
exec_properties = {
"container-image": REMOTE_EXECUTION_CONTAINERS[distro_or_os + "_" + arch]["container-image"],

View File

@ -1,6 +1,6 @@
package(default_visibility = ['//visibility:public'])
platform(name = 'host',
# Auto-detected host platform constraints.
constraint_values = [{constraints}],
constraint_values = [{platform_constraints}],
{exec_props}
)

View File

@ -48,7 +48,7 @@ def _setup_local_config_platform(ctx):
if distro != None and distro + "_" + arch in REMOTE_EXECUTION_CONTAINERS:
container_url = REMOTE_EXECUTION_CONTAINERS[distro + "_" + arch]["container-image"]
print("Using remote execution container: {}".format(container_url))
print("Local host platform is configured to use this container if doing remote execution: {}".format(container_url))
exec_props = """
exec_properties = {
"container-image": "%s",
@ -58,8 +58,19 @@ def _setup_local_config_platform(ctx):
else:
exec_props = ""
result = ctx.execute([
"uname",
"-r",
])
version_numbers = result.stdout.split(".")
if int(version_numbers[0]) > 4 or (int(version_numbers[0]) == 4 and int(version_numbers[1]) > 3):
platform_constraints_str = constraints_str + ',\n "@//bazel/platforms:kernel_version_4_4_or_greater"'
else:
platform_constraints_str = constraints_str + ',\n "@//bazel/platforms:kernel_version_less_than_4_4"'
substitutions = {
"{constraints}": constraints_str,
"{platform_constraints}": platform_constraints_str,
"{exec_props}": exec_props,
}

View File

@ -615,14 +615,7 @@ def generate(env: SCons.Environment.Environment) -> None:
# === Build settings ===
linkstatic = env.GetOption("link-model") in ["auto", "static"]
# TODO SERVER-86472 make bazel support both tcmalloc implementations
if env.GetOption("allocator") == "tcmalloc-google":
env.ConfError("Bazel build currently does not support tcmalloc-google allocator.")
if env.GetOption("allocator") == "tcmalloc-gperf":
allocator = "tcmalloc"
else:
allocator = env.GetOption("allocator")
allocator = env.get('MONGO_ALLOCATOR', 'tcmalloc-google')
distro_or_os = normalized_os
if normalized_os == "linux":

444
src/third_party/tcmalloc/BUILD.bazel vendored Normal file
View File

@ -0,0 +1,444 @@
load("//bazel:mongo_src_rules.bzl", "mongo_cc_library")
package(default_visibility = ["//visibility:public"])
TCMALLOC_HEADERS = [
"dist/tcmalloc/allocation_sample.h",
"dist/tcmalloc/allocation_sampling.h",
"dist/tcmalloc/arena.h",
"dist/tcmalloc/central_freelist.h",
"dist/tcmalloc/common.h",
"dist/tcmalloc/cpu_cache.h",
"dist/tcmalloc/deallocation_profiler.h",
"dist/tcmalloc/experiment.h",
"dist/tcmalloc/experiment_config.h",
"dist/tcmalloc/explicitly_constructed.h",
"dist/tcmalloc/global_stats.h",
"dist/tcmalloc/guarded_page_allocator.h",
"dist/tcmalloc/hinted_tracker_lists.h",
"dist/tcmalloc/huge_address_map.h",
"dist/tcmalloc/huge_allocator.h",
"dist/tcmalloc/huge_cache.h",
"dist/tcmalloc/huge_page_aware_allocator.h",
"dist/tcmalloc/huge_page_filler.h",
"dist/tcmalloc/huge_pages.h",
"dist/tcmalloc/huge_region.h",
"dist/tcmalloc/internal/affinity.h",
"dist/tcmalloc/internal/atomic_danger.h",
"dist/tcmalloc/internal/atomic_stats_counter.h",
"dist/tcmalloc/internal/cache_topology.h",
"dist/tcmalloc/internal/clock.h",
"dist/tcmalloc/internal/config.h",
"dist/tcmalloc/internal/declarations.h",
"dist/tcmalloc/internal/environment.h",
"dist/tcmalloc/internal/fake_profile.h",
"dist/tcmalloc/internal/lifetime_predictions.h",
"dist/tcmalloc/internal/lifetime_tracker.h",
"dist/tcmalloc/internal/linked_list.h",
"dist/tcmalloc/internal/linux_syscall_support.h",
"dist/tcmalloc/internal/logging.h",
"dist/tcmalloc/internal/memory_stats.h",
"dist/tcmalloc/internal/mincore.h",
"dist/tcmalloc/internal/mock_span.h",
"dist/tcmalloc/internal/numa.h",
"dist/tcmalloc/internal/optimization.h",
"dist/tcmalloc/internal/overflow.h",
"dist/tcmalloc/internal/page_size.h",
"dist/tcmalloc/internal/parameter_accessors.h",
"dist/tcmalloc/internal/percpu.h",
"dist/tcmalloc/internal/percpu_tcmalloc.h",
"dist/tcmalloc/internal/prefetch.h",
"dist/tcmalloc/internal/proc_maps.h",
"dist/tcmalloc/internal/profile_builder.h",
"dist/tcmalloc/internal/range_tracker.h",
"dist/tcmalloc/internal/residency.h",
"dist/tcmalloc/internal/stacktrace_filter.h",
"dist/tcmalloc/internal/timeseries_tracker.h",
"dist/tcmalloc/internal/util.h",
"dist/tcmalloc/internal_malloc_extension.h",
"dist/tcmalloc/internal_malloc_tracing_extension.h",
"dist/tcmalloc/libc_override.h",
"dist/tcmalloc/lifetime_based_allocator.h",
"dist/tcmalloc/malloc_extension.h",
"dist/tcmalloc/malloc_tracing_extension.h",
"dist/tcmalloc/mock_central_freelist.h",
"dist/tcmalloc/mock_static_forwarder.h",
"dist/tcmalloc/mock_transfer_cache.h",
"dist/tcmalloc/new_extension.h",
"dist/tcmalloc/page_allocator.h",
"dist/tcmalloc/page_allocator_interface.h",
"dist/tcmalloc/page_allocator_test_util.h",
"dist/tcmalloc/page_heap.h",
"dist/tcmalloc/page_heap_allocator.h",
"dist/tcmalloc/pagemap.h",
"dist/tcmalloc/pages.h",
"dist/tcmalloc/parameters.h",
"dist/tcmalloc/peak_heap_tracker.h",
"dist/tcmalloc/profile_marshaler.h",
"dist/tcmalloc/sampled_allocation.h",
"dist/tcmalloc/sampled_allocation_allocator.h",
"dist/tcmalloc/sampled_allocation_recorder.h",
"dist/tcmalloc/sampler.h",
"dist/tcmalloc/size_class_info.h",
"dist/tcmalloc/sizemap.h",
"dist/tcmalloc/span.h",
"dist/tcmalloc/span_stats.h",
"dist/tcmalloc/stack_trace_table.h",
"dist/tcmalloc/static_vars.h",
"dist/tcmalloc/stats.h",
"dist/tcmalloc/system-alloc.h",
"dist/tcmalloc/tcmalloc.h",
"dist/tcmalloc/tcmalloc_policy.h",
"dist/tcmalloc/testing/test_allocator_harness.h",
"dist/tcmalloc/testing/testutil.h",
"dist/tcmalloc/testing/thread_manager.h",
"dist/tcmalloc/thread_cache.h",
"dist/tcmalloc/transfer_cache.h",
"dist/tcmalloc/transfer_cache_internals.h",
"dist/tcmalloc/transfer_cache_stats.h",
]
INCLUDES = ["dist"]
COPTS = [
"-Werror",
"-Wno-sign-compare",
"-Wno-uninitialized",
"-Wno-unused-function",
"-Wno-unused-variable",
] + select({
"//bazel/config:compiler_type_gcc": [
"-Wno-attribute-alias",
"-Wno-stringop-overflow",
"-Wno-unused-result",
],
"//bazel/config:compiler_type_clang": [
"-Wno-deprecated-declarations",
"-Wno-deprecated-volatile",
"-Wno-implicit-int-float-conversion",
],
})
KERNEL_SUPPORTED = select({
"//bazel/config:local_build_enabled": ["//bazel/platforms:kernel_version_4_4_or_greater"],
"//conditions:default": [],
})
mongo_cc_library(
name = "tcmalloc",
srcs = [
"dist/tcmalloc/tcmalloc.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_common",
"tcmalloc_experiment",
"tcmalloc_internal_logging",
"tcmalloc_internal_page_size",
"tcmalloc_internal_percpu",
"tcmalloc_malloc_extension",
"tcmalloc_malloc_tracing_extension",
"tcmalloc_new_extension",
"tcmalloc_sampled_allocation",
"//src/third_party/abseil-cpp:absl_base",
"//src/third_party/abseil-cpp:absl_stacktrace",
"//src/third_party/abseil-cpp:absl_status",
"//src/third_party/abseil-cpp:absl_statusor",
"//src/third_party/abseil-cpp:absl_strings",
],
)
mongo_cc_library(
name = "tcmalloc_internal_cache_topology",
srcs = [
"dist/tcmalloc/internal/cache_topology.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_internal_logging",
"tcmalloc_internal_util",
"//src/third_party/abseil-cpp:absl_base",
"//src/third_party/abseil-cpp:absl_strings",
],
)
mongo_cc_library(
name = "tcmalloc_internal_environment",
srcs = [
"dist/tcmalloc/internal/environment.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = ["//src/third_party/abseil-cpp:absl_base"],
)
mongo_cc_library(
name = "tcmalloc_internal_logging",
srcs = [
"dist/tcmalloc/internal/logging.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_malloc_extension",
"//src/third_party/abseil-cpp:absl_base",
"//src/third_party/abseil-cpp:absl_stacktrace",
"//src/third_party/abseil-cpp:absl_strings",
"//src/third_party/abseil-cpp:absl_time",
],
)
mongo_cc_library(
name = "tcmalloc_internal_memory_stats",
srcs = [
"dist/tcmalloc/internal/memory_stats.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_internal_logging",
"tcmalloc_internal_page_size",
"tcmalloc_internal_util",
"//src/third_party/abseil-cpp:absl_strings",
],
)
mongo_cc_library(
name = "tcmalloc_internal_mincore",
srcs = [
"dist/tcmalloc/internal/mincore.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_internal_page_size",
"//src/third_party/abseil-cpp:absl_base",
],
)
mongo_cc_library(
name = "tcmalloc_internal_numa",
srcs = [
"dist/tcmalloc/internal/numa.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_internal_environment",
"tcmalloc_internal_logging",
"tcmalloc_internal_percpu",
"tcmalloc_internal_util",
"//src/third_party/abseil-cpp:absl_base",
"//src/third_party/abseil-cpp:absl_strings",
],
)
mongo_cc_library(
name = "tcmalloc_internal_page_size",
srcs = [
"dist/tcmalloc/internal/page_size.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"//src/third_party/abseil-cpp:absl_base",
],
)
mongo_cc_library(
name = "tcmalloc_internal_percpu",
srcs = [
"dist/tcmalloc/internal/percpu.cc",
"dist/tcmalloc/internal/percpu_rseq_asm.S",
"dist/tcmalloc/internal/percpu_rseq_unsupported.cc",
],
hdrs = TCMALLOC_HEADERS + select({
"@//bazel/config:linux_aarch64": ["dist/tcmalloc/internal/percpu_rseq_aarch64.S"],
"@//bazel/config:linux_x86_64": ["dist/tcmalloc/internal/percpu_rseq_x86_64.S"],
}),
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_internal_logging",
"tcmalloc_internal_util",
"//src/third_party/abseil-cpp:absl_base",
],
)
mongo_cc_library(
name = "tcmalloc_internal_util",
srcs = [
"dist/tcmalloc/internal/util.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_internal_logging",
"//src/third_party/abseil-cpp:absl_base",
"//src/third_party/abseil-cpp:absl_time",
],
)
mongo_cc_library(
name = "tcmalloc_common",
srcs = [
"dist/tcmalloc/allocation_sample.cc",
"dist/tcmalloc/arena.cc",
"dist/tcmalloc/background.cc",
"dist/tcmalloc/central_freelist.cc",
"dist/tcmalloc/common.cc",
"dist/tcmalloc/cpu_cache.cc",
"dist/tcmalloc/deallocation_profiler.cc",
"dist/tcmalloc/experimental_pow2_size_class.cc",
"dist/tcmalloc/global_stats.cc",
"dist/tcmalloc/guarded_page_allocator.cc",
"dist/tcmalloc/huge_address_map.cc",
"dist/tcmalloc/huge_allocator.cc",
"dist/tcmalloc/huge_cache.cc",
"dist/tcmalloc/huge_page_aware_allocator.cc",
"dist/tcmalloc/legacy_size_classes.cc",
"dist/tcmalloc/lifetime_based_allocator.cc",
"dist/tcmalloc/page_allocator.cc",
"dist/tcmalloc/page_allocator_interface.cc",
"dist/tcmalloc/page_heap.cc",
"dist/tcmalloc/pagemap.cc",
"dist/tcmalloc/parameters.cc",
"dist/tcmalloc/peak_heap_tracker.cc",
"dist/tcmalloc/sampler.cc",
"dist/tcmalloc/size_classes.cc",
"dist/tcmalloc/sizemap.cc",
"dist/tcmalloc/span.cc",
"dist/tcmalloc/stack_trace_table.cc",
"dist/tcmalloc/static_vars.cc",
"dist/tcmalloc/stats.cc",
"dist/tcmalloc/system-alloc.cc",
"dist/tcmalloc/thread_cache.cc",
"dist/tcmalloc/transfer_cache.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_experiment",
"tcmalloc_internal_cache_topology",
"tcmalloc_internal_environment",
"tcmalloc_internal_logging",
"tcmalloc_internal_memory_stats",
"tcmalloc_internal_mincore",
"tcmalloc_internal_numa",
"tcmalloc_internal_page_size",
"tcmalloc_internal_percpu",
"tcmalloc_internal_util",
"tcmalloc_malloc_extension",
"tcmalloc_malloc_tracing_extension",
"tcmalloc_new_extension",
"tcmalloc_sampled_allocation",
"//src/third_party/abseil-cpp:absl_base",
"//src/third_party/abseil-cpp:absl_hash",
"//src/third_party/abseil-cpp:absl_malloc_internal",
"//src/third_party/abseil-cpp:absl_raw_hash_set",
"//src/third_party/abseil-cpp:absl_stacktrace",
"//src/third_party/abseil-cpp:absl_strings",
"//src/third_party/abseil-cpp:absl_synchronization",
"//src/third_party/abseil-cpp:absl_time",
],
)
mongo_cc_library(
name = "tcmalloc_experiment",
srcs = [
"dist/tcmalloc/experiment.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_internal_environment",
"tcmalloc_internal_logging",
"//src/third_party/abseil-cpp:absl_strings",
],
)
mongo_cc_library(
name = "tcmalloc_malloc_extension",
srcs = [
"dist/tcmalloc/malloc_extension.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"//src/third_party/abseil-cpp:absl_malloc_internal",
"//src/third_party/abseil-cpp:absl_strings",
"//src/third_party/abseil-cpp:absl_time",
],
)
mongo_cc_library(
name = "tcmalloc_malloc_tracing_extension",
srcs = [
"dist/tcmalloc/malloc_tracing_extension.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"//src/third_party/abseil-cpp:absl_status",
"//src/third_party/abseil-cpp:absl_statusor",
],
)
mongo_cc_library(
name = "tcmalloc_new_extension",
srcs = [
"dist/tcmalloc/new_extension.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_malloc_extension",
],
)
mongo_cc_library(
name = "tcmalloc_sampled_allocation",
srcs = [
"dist/tcmalloc/sampled_allocation.cc",
],
hdrs = TCMALLOC_HEADERS,
copts = COPTS,
includes = INCLUDES,
target_compatible_with = KERNEL_SUPPORTED,
deps = [
"tcmalloc_internal_logging",
"//src/third_party/abseil-cpp:absl_base",
"//src/third_party/abseil-cpp:absl_stacktrace",
],
)

View File

@ -160,7 +160,7 @@ def slurpBlaze(target, source, exports, env):
for cf in libDef.get('copts', []):
kwargs.setdefault('CCFLAGS', [e for e in env.get('CCFLAGS', [])]).append(cf)
tcmalloc_scons_print(f'env.Library(**{json.dumps(kwargs, indent=4)})', file=sys.stderr)
env.Library(**kwargs)
env.BazelLibrary(**kwargs)
return 0