Skip to content

Commit

Permalink
Move .dwp files to lib.unstripped folder.
Browse files Browse the repository at this point in the history
- .dwp files produced by clank build will now be output to
lib.unstripped folder instead of the root out folder. This is to ensure
they are in the expected place for Breakpad symbol generation and symbol
archiving.

Bug: 1112935
Change-Id: Id5cfb8a0188e3a6fa30fb56ed98bdb4e7da2af03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2406595
Commit-Queue: Nelson Billing <nbilling@google.com>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809448}
  • Loading branch information
Nelson Billing authored and Commit Bot committed Sep 22, 2020
1 parent 2776bee commit aa05b86
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 33 deletions.
10 changes: 1 addition & 9 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ declare_args() {
current_cpu == "x64"))))
}

if (use_debug_fission == "default") {
use_debug_fission = is_debug && !is_android && !is_fuchsia && !is_apple &&
!is_win && (use_gold || use_lld) && cc_wrapper == ""
}

if (is_win || is_android || (is_chromeos && is_chromeos_device)) {
# Set the path to use orderfile for linking Chrome
# Note that this is for using only one orderfile for linking
Expand Down Expand Up @@ -2350,10 +2345,7 @@ config("symbols") {
# NOTE: This flag is for use by the link wrapper scripts. They are also
# expected to remove it before sending the rest of ldflags to the actual
# linker. Only expect Android Chrome build on Android OS to need this.
ldflags += [
"--generate-dwp",
"-gsplit-dwarf",
]
ldflags += [ "-gsplit-dwarf" ]
}

# TODO(thakis): Figure out if there's a way to make this go for 32-bit,
Expand Down
16 changes: 12 additions & 4 deletions build/config/compiler/compiler.gni
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import("//build/config/chromecast_build.gni")
import("//build/config/chromeos/args.gni")
import("//build/config/compiler/pgo/pgo.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")
import("//build_overrides/build.gni")
Expand Down Expand Up @@ -223,11 +224,19 @@ if (strip_absolute_paths_from_debug_symbols_default) {
}
}

# If it wasn't manually set, then default use_debug_fission to false.
assert(
use_debug_fission == "default" || use_debug_fission || !use_debug_fission,
"Invalid use_debug_fission.")
if (use_debug_fission == "default") {
use_debug_fission = is_debug && !is_android && !is_fuchsia && !is_apple &&
!is_win && (use_gold || use_lld) && cc_wrapper == ""
}

# If it wasn't manually set, set to an appropriate default.
assert(symbol_level >= -1 && symbol_level <= 2, "Invalid symbol_level")
if (symbol_level == -1) {
if (is_android && !is_component_build &&
!(use_debug_fission != "default" && use_debug_fission)) {
if (is_android && !is_component_build && !use_debug_fission) {
# Reduce symbol level when it will cause invalid elf files to be created
# (due to file size). https://crbug.com/648948.
symbol_level = 1
Expand Down Expand Up @@ -277,8 +286,7 @@ if (forbid_non_component_debug_builds) {
# toolchain there to build relatively small binaries.
assert(
ignore_elf32_limitations || !is_android || target_os == "chromeos" ||
is_component_build || symbol_level < 2 ||
(use_debug_fission != "default" && use_debug_fission),
is_component_build || symbol_level < 2 || use_debug_fission,
"Android 32-bit non-component builds without DWARF Fission cannot " +
"have symbol_level=2 due to 4GiB file size limit, see " +
"https://crbug.com/648948. " + "If you really want to try this out, " +
Expand Down
2 changes: 1 addition & 1 deletion build/extract_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def main():
if args.dwp:
dwp_args = [
args.dwp, '-e', args.unstripped_output, '-o',
args.stripped_output + '.dwp'
args.unstripped_output + '.dwp'
]
subprocess.check_call(dwp_args)

Expand Down
5 changes: 2 additions & 3 deletions build/partitioned_shared_library.gni
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ template("partitioned_shared_library") {
# Restrict to Android OS because ChromeOS uses the Android toolchain with
# use_debug_fission set globally, which isn't reliable across all
# possible build configs with Android.
if (is_android && target_os == "android" &&
use_debug_fission != "default" && use_debug_fission) {
if (is_android && target_os == "android" && use_debug_fission) {
dwp = rebase_path("${android_tool_prefix}dwp", root_build_dir)
args += [ "--dwp=${dwp}" ]
outputs += [ invoker.stripped_output + ".dwp" ]
outputs += [ invoker.unstripped_output + ".dwp" ]
}
args += [ rebase_path(sources[0], root_build_dir) ]
}
Expand Down
10 changes: 2 additions & 8 deletions build/toolchain/gcc_link_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def main():
help='Linking command')
args = parser.parse_args()

generate_dwp = '--generate-dwp' in args.command
if generate_dwp:
args.command.remove('--generate-dwp')

# Work-around for gold being slow-by-default. http://crbug.com/632230
fast_env = dict(os.environ)
fast_env['LC_ALL'] = 'C'
Expand All @@ -68,15 +64,13 @@ def main():

# If dwp is set, then package debug info for this exe.
dwp_proc = None
if generate_dwp:
if not args.dwp:
parser.error('--generate-dwp requireds --dwp')
if args.dwp:
exe_file = args.output
if args.unstripped_file:
exe_file = args.unstripped_file
dwp_proc = subprocess.Popen(
wrapper_utils.CommandToRun(
[args.dwp, '-e', exe_file, '-o', args.output + '.dwp']))
[args.dwp, '-e', exe_file, '-o', exe_file + '.dwp']))

# Finally, strip the linked executable (if desired).
if args.strip:
Expand Down
7 changes: 2 additions & 5 deletions build/toolchain/gcc_solink_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def main():
# https://crbug.com/954311 tracks finding a better way to plumb these.
link_only = InterceptFlag('--link-only', args.command)
collect_inputs_only = InterceptFlag('--collect-inputs-only', args.command)
generate_dwp = InterceptFlag('--generate-dwp', args.command)

# If only linking, we are likely generating a partitioned .so that will be
# split apart later. In that case:
Expand Down Expand Up @@ -162,12 +161,10 @@ def main():

# If dwp is set, then package debug info for this SO.
dwp_proc = None
if generate_dwp:
if not args.dwp:
parser.error('--generate-dwp requireds --dwp')
if args.dwp:
dwp_proc = subprocess.Popen(
wrapper_utils.CommandToRun(
[args.dwp, '-e', args.sofile, '-o', args.output + '.dwp']))
[args.dwp, '-e', args.sofile, '-o', args.sofile + '.dwp']))

# Next, generate the contents of the TOC file.
result, toc = CollectTOC(args)
Expand Down
42 changes: 39 additions & 3 deletions build/toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,12 @@ template("gcc_toolchain") {
# The host might not have a POSIX shell and utilities (e.g. Windows).
solink_wrapper =
rebase_path("//build/toolchain/gcc_solink_wrapper.py", root_build_dir)
command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch--dwp=\"${dwp}\" --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\"$map_switch --output=\"$sofile\" -- $link_command"
dwp_switch = ""
if (is_android && target_os == "android" && use_debug_fission &&
symbol_level == 2) {
dwp_switch = " --dwp=\"${dwp}\""
}
command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\"$nm\" $strip_switch$dwp_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\"$map_switch --output=\"$sofile\" -- $link_command"

if (target_cpu == "mipsel" && is_component_build && is_android) {
rspfile_content = "-Wl,--start-group -Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}} -Wl,--end-group"
Expand Down Expand Up @@ -454,6 +459,18 @@ template("gcc_toolchain") {
runtime_outputs = [ unstripped_sofile ]
}
}

# Clank build will generate DWP files when Fission is used.
# Other builds generate DWP files outside of the gn link targets, if at
# all.
if (is_android && target_os == "android" && use_debug_fission &&
symbol_level == 2) {
outputs += [ unstripped_sofile + ".dwp" ]
if (defined(invoker.use_unstripped_as_runtime_outputs) &&
invoker.use_unstripped_as_runtime_outputs) {
runtime_outputs += [ unstripped_sofile + ".dwp" ]
}
}
if (defined(map_file)) {
outputs += [ map_file ]
}
Expand Down Expand Up @@ -547,9 +564,17 @@ template("gcc_toolchain") {
strip_switch = " --strip=\"${invoker.strip}\" --unstripped-file=\"$unstripped_outfile\""
}

dwp_switch = ""
if (is_android && target_os == "android" && use_debug_fission &&
symbol_level == 2) {
dwp_switch = " --dwp=\"${dwp}\""
} else {
not_needed([ "dwp" ])
}

link_wrapper =
rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir)
command = "$python_path \"$link_wrapper\" --output=\"$outfile\"$strip_switch$map_switch --dwp=\"${dwp}\" -- $link_command"
command = "$python_path \"$link_wrapper\" --output=\"$outfile\"$strip_switch$map_switch$dwp_switch -- $link_command"

description = "LINK $outfile"
rspfile_content = "{{inputs}}"
Expand All @@ -561,6 +586,18 @@ template("gcc_toolchain") {
runtime_outputs = [ unstripped_outfile ]
}
}

# Clank build will generate DWP files when Fission is used.
# Other builds generate DWP files outside of the gn link targets, if at
# all.
if (is_android && target_os == "android" && use_debug_fission &&
symbol_level == 2) {
outputs += [ unstripped_outfile + ".dwp" ]
if (defined(invoker.use_unstripped_as_runtime_outputs) &&
invoker.use_unstripped_as_runtime_outputs) {
runtime_outputs += [ unstripped_outfile + ".dwp" ]
}
}
if (defined(invoker.link_outputs)) {
outputs += invoker.link_outputs
}
Expand Down Expand Up @@ -611,7 +648,6 @@ template("clang_toolchain") {
readelf = "${toolprefix}readelf"
ar = "${prefix}/llvm-ar"
nm = "${toolprefix}nm"
dwp = "${toolprefix}dwp"

forward_variables_from(invoker,
[
Expand Down

0 comments on commit aa05b86

Please sign in to comment.