Commit aa05b866 authored by Nelson Billing's avatar Nelson Billing Committed by Commit Bot

Move .dwp files to lib.unstripped folder.

- .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: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809448}
parent 2776beea
...@@ -174,11 +174,6 @@ declare_args() { ...@@ -174,11 +174,6 @@ declare_args() {
current_cpu == "x64")))) 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)) { if (is_win || is_android || (is_chromeos && is_chromeos_device)) {
# Set the path to use orderfile for linking Chrome # Set the path to use orderfile for linking Chrome
# Note that this is for using only one orderfile for linking # Note that this is for using only one orderfile for linking
...@@ -2350,10 +2345,7 @@ config("symbols") { ...@@ -2350,10 +2345,7 @@ config("symbols") {
# NOTE: This flag is for use by the link wrapper scripts. They are also # 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 # 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. # linker. Only expect Android Chrome build on Android OS to need this.
ldflags += [ ldflags += [ "-gsplit-dwarf" ]
"--generate-dwp",
"-gsplit-dwarf",
]
} }
# TODO(thakis): Figure out if there's a way to make this go for 32-bit, # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
......
...@@ -7,6 +7,7 @@ import("//build/config/chromecast_build.gni") ...@@ -7,6 +7,7 @@ import("//build/config/chromecast_build.gni")
import("//build/config/chromeos/args.gni") import("//build/config/chromeos/args.gni")
import("//build/config/compiler/pgo/pgo.gni") import("//build/config/compiler/pgo/pgo.gni")
import("//build/config/sanitizers/sanitizers.gni") import("//build/config/sanitizers/sanitizers.gni")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/goma.gni") import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni") import("//build/toolchain/toolchain.gni")
import("//build_overrides/build.gni") import("//build_overrides/build.gni")
...@@ -223,11 +224,19 @@ if (strip_absolute_paths_from_debug_symbols_default) { ...@@ -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. # If it wasn't manually set, set to an appropriate default.
assert(symbol_level >= -1 && symbol_level <= 2, "Invalid symbol_level") assert(symbol_level >= -1 && symbol_level <= 2, "Invalid symbol_level")
if (symbol_level == -1) { if (symbol_level == -1) {
if (is_android && !is_component_build && if (is_android && !is_component_build && !use_debug_fission) {
!(use_debug_fission != "default" && use_debug_fission)) {
# Reduce symbol level when it will cause invalid elf files to be created # Reduce symbol level when it will cause invalid elf files to be created
# (due to file size). https://crbug.com/648948. # (due to file size). https://crbug.com/648948.
symbol_level = 1 symbol_level = 1
...@@ -277,8 +286,7 @@ if (forbid_non_component_debug_builds) { ...@@ -277,8 +286,7 @@ if (forbid_non_component_debug_builds) {
# toolchain there to build relatively small binaries. # toolchain there to build relatively small binaries.
assert( assert(
ignore_elf32_limitations || !is_android || target_os == "chromeos" || ignore_elf32_limitations || !is_android || target_os == "chromeos" ||
is_component_build || symbol_level < 2 || is_component_build || symbol_level < 2 || use_debug_fission,
(use_debug_fission != "default" && use_debug_fission),
"Android 32-bit non-component builds without DWARF Fission cannot " + "Android 32-bit non-component builds without DWARF Fission cannot " +
"have symbol_level=2 due to 4GiB file size limit, see " + "have symbol_level=2 due to 4GiB file size limit, see " +
"https://crbug.com/648948. " + "If you really want to try this out, " + "https://crbug.com/648948. " + "If you really want to try this out, " +
......
...@@ -50,7 +50,7 @@ def main(): ...@@ -50,7 +50,7 @@ def main():
if args.dwp: if args.dwp:
dwp_args = [ dwp_args = [
args.dwp, '-e', args.unstripped_output, '-o', args.dwp, '-e', args.unstripped_output, '-o',
args.stripped_output + '.dwp' args.unstripped_output + '.dwp'
] ]
subprocess.check_call(dwp_args) subprocess.check_call(dwp_args)
......
...@@ -103,11 +103,10 @@ template("partitioned_shared_library") { ...@@ -103,11 +103,10 @@ template("partitioned_shared_library") {
# Restrict to Android OS because ChromeOS uses the Android toolchain with # Restrict to Android OS because ChromeOS uses the Android toolchain with
# use_debug_fission set globally, which isn't reliable across all # use_debug_fission set globally, which isn't reliable across all
# possible build configs with Android. # possible build configs with Android.
if (is_android && target_os == "android" && if (is_android && target_os == "android" && use_debug_fission) {
use_debug_fission != "default" && use_debug_fission) {
dwp = rebase_path("${android_tool_prefix}dwp", root_build_dir) dwp = rebase_path("${android_tool_prefix}dwp", root_build_dir)
args += [ "--dwp=${dwp}" ] args += [ "--dwp=${dwp}" ]
outputs += [ invoker.stripped_output + ".dwp" ] outputs += [ invoker.unstripped_output + ".dwp" ]
} }
args += [ rebase_path(sources[0], root_build_dir) ] args += [ rebase_path(sources[0], root_build_dir) ]
} }
......
...@@ -54,10 +54,6 @@ def main(): ...@@ -54,10 +54,6 @@ def main():
help='Linking command') help='Linking command')
args = parser.parse_args() 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 # Work-around for gold being slow-by-default. http://crbug.com/632230
fast_env = dict(os.environ) fast_env = dict(os.environ)
fast_env['LC_ALL'] = 'C' fast_env['LC_ALL'] = 'C'
...@@ -68,15 +64,13 @@ def main(): ...@@ -68,15 +64,13 @@ def main():
# If dwp is set, then package debug info for this exe. # If dwp is set, then package debug info for this exe.
dwp_proc = None dwp_proc = None
if generate_dwp: if args.dwp:
if not args.dwp:
parser.error('--generate-dwp requireds --dwp')
exe_file = args.output exe_file = args.output
if args.unstripped_file: if args.unstripped_file:
exe_file = args.unstripped_file exe_file = args.unstripped_file
dwp_proc = subprocess.Popen( dwp_proc = subprocess.Popen(
wrapper_utils.CommandToRun( 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). # Finally, strip the linked executable (if desired).
if args.strip: if args.strip:
......
...@@ -122,7 +122,6 @@ def main(): ...@@ -122,7 +122,6 @@ def main():
# https://crbug.com/954311 tracks finding a better way to plumb these. # https://crbug.com/954311 tracks finding a better way to plumb these.
link_only = InterceptFlag('--link-only', args.command) link_only = InterceptFlag('--link-only', args.command)
collect_inputs_only = InterceptFlag('--collect-inputs-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 # If only linking, we are likely generating a partitioned .so that will be
# split apart later. In that case: # split apart later. In that case:
...@@ -162,12 +161,10 @@ def main(): ...@@ -162,12 +161,10 @@ def main():
# If dwp is set, then package debug info for this SO. # If dwp is set, then package debug info for this SO.
dwp_proc = None dwp_proc = None
if generate_dwp: if args.dwp:
if not args.dwp:
parser.error('--generate-dwp requireds --dwp')
dwp_proc = subprocess.Popen( dwp_proc = subprocess.Popen(
wrapper_utils.CommandToRun( 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. # Next, generate the contents of the TOC file.
result, toc = CollectTOC(args) result, toc = CollectTOC(args)
......
...@@ -417,7 +417,12 @@ template("gcc_toolchain") { ...@@ -417,7 +417,12 @@ template("gcc_toolchain") {
# The host might not have a POSIX shell and utilities (e.g. Windows). # The host might not have a POSIX shell and utilities (e.g. Windows).
solink_wrapper = solink_wrapper =
rebase_path("//build/toolchain/gcc_solink_wrapper.py", root_build_dir) 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) { 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" rspfile_content = "-Wl,--start-group -Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}} -Wl,--end-group"
...@@ -454,6 +459,18 @@ template("gcc_toolchain") { ...@@ -454,6 +459,18 @@ template("gcc_toolchain") {
runtime_outputs = [ unstripped_sofile ] 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)) { if (defined(map_file)) {
outputs += [ map_file ] outputs += [ map_file ]
} }
...@@ -547,9 +564,17 @@ template("gcc_toolchain") { ...@@ -547,9 +564,17 @@ template("gcc_toolchain") {
strip_switch = " --strip=\"${invoker.strip}\" --unstripped-file=\"$unstripped_outfile\"" 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 = link_wrapper =
rebase_path("//build/toolchain/gcc_link_wrapper.py", root_build_dir) 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" description = "LINK $outfile"
rspfile_content = "{{inputs}}" rspfile_content = "{{inputs}}"
...@@ -561,6 +586,18 @@ template("gcc_toolchain") { ...@@ -561,6 +586,18 @@ template("gcc_toolchain") {
runtime_outputs = [ unstripped_outfile ] 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)) { if (defined(invoker.link_outputs)) {
outputs += invoker.link_outputs outputs += invoker.link_outputs
} }
...@@ -611,7 +648,6 @@ template("clang_toolchain") { ...@@ -611,7 +648,6 @@ template("clang_toolchain") {
readelf = "${toolprefix}readelf" readelf = "${toolprefix}readelf"
ar = "${prefix}/llvm-ar" ar = "${prefix}/llvm-ar"
nm = "${toolprefix}nm" nm = "${toolprefix}nm"
dwp = "${toolprefix}dwp"
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment