-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include the symlinked dwp/objcopy/strip files in the toolchain (#108)
* Fix including symlink extra files in dwp/objcopy * Add strip filegroups to support strip inside sandbox * tests: add a `.stripped` test * tests: test that `.dwp` targets can be built This has some things we'll eventually want to remove; see #109 for some context. * tests: have `dwp_file` transition to `-c dbg` so .dwo files are generated with clang-12+ Issue #109 and [this comment](#108 (comment)) have some context; the short version is that `-gsplit-dwarf` no longer implies `-g2` which means under `-c fastbuild` (implies `-g0`) no `.dwo` files are created. There's a patch to `unix_cc_toolchain_config.bzl` but for now we'll just use `-c dbg` for this one target using a transition. * tests: migration fixes Co-authored-by: Rahul Butani <rr.butani@gmail.com>
- Loading branch information
Showing
4 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
"""Helper transitions for tests.""" | ||
|
||
# This transition function sets `--features=per_object_debug_info` and | ||
# `--fission` as well as the compilation mode. | ||
# | ||
# These three Bazel flags influence whether or not `.dwo` and `.dwp` are | ||
# created. | ||
def _fission_transition_impl(settings, attr): | ||
features = settings["//command_line_option:features"] | ||
if "per_object_debug_info" in features: | ||
features.remove("per_object_debug_info") | ||
|
||
enable_per_object_debug_info = attr.per_object_debug_info | ||
if enable_per_object_debug_info: | ||
features.append("per_object_debug_info") | ||
|
||
compilation_mode = settings["//command_line_option:compilation_mode"] | ||
if attr.override_compilation_mode: | ||
compilation_mode = attr.override_compilation_mode | ||
|
||
return { | ||
"//command_line_option:compilation_mode": compilation_mode, | ||
"//command_line_option:fission": attr.fission, | ||
"//command_line_option:features": features, | ||
} | ||
|
||
fission_transition = transition( | ||
implementation = _fission_transition_impl, | ||
inputs = [ | ||
"//command_line_option:compilation_mode", | ||
"//command_line_option:features", | ||
], | ||
outputs = [ | ||
"//command_line_option:compilation_mode", | ||
"//command_line_option:features", | ||
"//command_line_option:fission", | ||
], | ||
) | ||
|
||
def _dwp_file_impl(ctx): | ||
file = ctx.attr.name | ||
file = ctx.actions.declare_file(file) | ||
ctx.actions.symlink( | ||
output = file, | ||
target_file = ctx.attr.src[0][DebugPackageInfo].dwp_file, | ||
) | ||
|
||
return [DefaultInfo(files = depset([file]))] | ||
|
||
dwp_file = rule( | ||
implementation = _dwp_file_impl, | ||
attrs = { | ||
"src": attr.label( | ||
cfg = fission_transition, | ||
mandatory = True, | ||
doc = "The actual target to build and grab the .dwp file from.", | ||
providers = [DebugPackageInfo], | ||
), | ||
# NOTE: we should eventually be able to remove this (see #109). | ||
"per_object_debug_info": attr.bool( | ||
default = True, | ||
), | ||
"fission": attr.string( | ||
default = "yes", | ||
values = ["yes", "no", "dbg", "fastbuild", "opt"], | ||
), | ||
# NOTE: this should eventually not be necessary; see #109 for context | ||
# and also: | ||
# - https://reviews.llvm.org/D80391 | ||
# - https://github.com/bazelbuild/bazel/issues/14038 | ||
# - https://github.com/bazelbuild/rules_cc/pull/115 | ||
# | ||
# Essentially, we now need to specify `-g2` explicitly to generate | ||
# `.dwo` files. | ||
"override_compilation_mode": attr.string( | ||
default = "", | ||
mandatory = False, | ||
values = ["dbg", "fastbuild", "opt"], | ||
), | ||
"_allowlist_function_transition": attr.label( | ||
default = "@bazel_tools//tools/allowlists/function_transition_allowlist" | ||
), | ||
}, | ||
incompatible_use_toolchain_transition = True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters