mirror of
https://github.com/bazelbuild/rules_cc
synced 2024-11-26 20:02:22 +00:00
d8dfa8b829
Numerous tools override --custom_malloc to add debugging or monitoring runtimes (see e.g. sanitizers). While this is fine for cases where the tool must also override malloc to function, in other cases it's simply misuse of --custom_malloc where no other mechanism exists to link an extra library. This becomes especially problematic where a runtime library is supposed to be added in certain configurations that should run in production or other performance sensitive builds. In these cases, we should _not_ override malloc, which may also be specified by a cc_binary target. Doing so would introduce unwanted changes, potentially affecting performance negatively. This is the @rules_cc counterpart to the equivalent Bazel tools flag --@bazel_tools//tools/cpp:link_extra_libs. Users that use @rules_cc to build their C++ projects may use both flags interchangably, however, the @rules_cc flag should be preferred. PiperOrigin-RevId: 510103352 Change-Id: Iafccd00ffdb65cb4f953d5acadc451cffc134533
26 lines
644 B
Python
26 lines
644 B
Python
load("//cc:defs.bzl", "cc_library")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
licenses(["notice"])
|
|
|
|
exports_files(["LICENSE"])
|
|
|
|
cc_library(name = "empty_lib")
|
|
|
|
# Label flag for extra libraries to be linked into every binary.
|
|
# TODO(bazel-team): Support passing flag multiple times to build a list.
|
|
label_flag(
|
|
name = "link_extra_libs",
|
|
build_setting_default = ":empty_lib",
|
|
)
|
|
|
|
# The final extra library to be linked into every binary target. This collects
|
|
# the above flag, but may also include more libraries depending on config.
|
|
cc_library(
|
|
name = "link_extra_lib",
|
|
deps = [
|
|
":link_extra_libs",
|
|
],
|
|
)
|