Skip to content

Commit

Permalink
Add extra_compiler_files attribute to make suppression files availa…
Browse files Browse the repository at this point in the history
…ble to sanitizers during compilation
  • Loading branch information
lalten committed Jan 12, 2024
1 parent 214fc1c commit a7f195d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def llvm_register_toolchains():
coverage_link_flags_dict = rctx.attr.coverage_link_flags,
unfiltered_compile_flags_dict = rctx.attr.unfiltered_compile_flags,
llvm_version = llvm_version,
extra_compiler_files = rctx.attr.extra_compiler_files,
)
host_dl_ext = "dylib" if os == "darwin" else "so"
host_tools_info = dict([
Expand Down Expand Up @@ -293,6 +294,10 @@ def _cc_toolchain_str(
# TODO: Are there situations where we can continue?
return ""

extra_compiler_files = ""
if toolchain_info.extra_compiler_files:
extra_compiler_files = '"{}",'.format(toolchain_info.extra_compiler_files)

extra_files_str = "\":internal-use-files\""

# `struct` isn't allowed in `BUILD` files so we JSON encode + decode to turn
Expand Down Expand Up @@ -358,7 +363,10 @@ filegroup(
template = template + """
filegroup(
name = "compiler-components-{suffix}",
srcs = [":sysroot-components-{suffix}"],
srcs = [
":sysroot-components-{suffix}"
{extra_compiler_files}
],
)
filegroup(
Expand Down Expand Up @@ -391,6 +399,7 @@ filegroup(
"{llvm_dist_label_prefix}clang",
"{llvm_dist_label_prefix}include",
":sysroot-components-{suffix}",
{extra_compiler_files}
],
)
Expand Down Expand Up @@ -468,6 +477,7 @@ cc_toolchain(
coverage_link_flags = _list_to_string(_dict_value(toolchain_info.coverage_link_flags_dict, target_pair)),
unfiltered_compile_flags = _list_to_string(_dict_value(toolchain_info.unfiltered_compile_flags_dict, target_pair)),
llvm_version = toolchain_info.llvm_version,
extra_compiler_files = extra_compiler_files,
extra_files_str = extra_files_str,
host_tools_info = host_tools_info,
)
Expand Down
7 changes: 7 additions & 0 deletions toolchain/internal/repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ _compiler_configuration_attrs = {
mandatory = False,
doc = ("Override the toolchain's `target_settings` attribute."),
),
"extra_compiler_files": attr.string(
mandatory = False,
doc = ("Extra label to add to the srcs of the filegroup that for the toolchain's " +
"compiler_files attr. It will be available for compile actions. " +
"Useful for sanitizer compile-time ignorelists. " +
"Example: \"@@//sanitizers:ignorelist.txt\""),
),
}

llvm_config_attrs = dict(common_attrs)
Expand Down

0 comments on commit a7f195d

Please sign in to comment.