From 2f27f9bf85b21f149c5972197ef07f957fe20b41 Mon Sep 17 00:00:00 2001 From: brettw Date: Fri, 19 Jun 2015 15:34:48 -0700 Subject: [PATCH] Fix some build symbol configuration. Remove -gdwarf-4 from GYP build. This is the default for GCC 4.8 which is now required, so this command-line argument is redundant. Only set use_debug_fission in the GN build in debug mode. This matches GYP. Release mode symbols will be non-fission. Implement linux_symbols target in GN. Convert dump_app_syms from sh to Python for better GN usability, and it's more readable for normal programmers on the team. Reland of https://codereview.chromium.org/1182663007/ Reland of https://codereview.chromium.org/1179393004/ TBR=thakis@chromium.org Review URL: https://codereview.chromium.org/1197793002 Cr-Commit-Position: refs/heads/master@{#335370} --- build/common.gypi | 1 - build/config/compiler/BUILD.gn | 4 ++-- build/linux/dump_app_syms | 36 ---------------------------------- build/linux/dump_app_syms.py | 29 +++++++++++++++++++++++++++ chrome/BUILD.gn | 36 ++++++++++++++++++++++++++++++++++ chrome/chrome.gyp | 6 ++++-- 6 files changed, 71 insertions(+), 41 deletions(-) delete mode 100755 build/linux/dump_app_syms create mode 100644 build/linux/dump_app_syms.py diff --git a/build/common.gypi b/build/common.gypi index cb474a36b35721..d1c09dd382d058 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -3687,7 +3687,6 @@ 'cflags': [ '-O>(debug_optimize)', '-g', - '-gdwarf-4', ], 'conditions' : [ ['OS=="android" and target_arch!="mipsel" and target_arch!="mips64el"', { diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 5f00020685fa87..05ac0236f0bc65 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -51,8 +51,8 @@ declare_args() { # with some utilities such as icecc and ccache. Requires gold and # gcc >= 4.8 or clang. # http://gcc.gnu.org/wiki/DebugFission - use_debug_fission = - !is_win && use_gold && linux_use_bundled_binutils && !use_ccache + use_debug_fission = is_debug && !is_win && use_gold && + linux_use_bundled_binutils && !use_ccache if (is_win) { # Whether the VS xtree header has been patched to disable warning 4702. If diff --git a/build/linux/dump_app_syms b/build/linux/dump_app_syms deleted file mode 100755 index cbeb676271205f..00000000000000 --- a/build/linux/dump_app_syms +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2010 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Helper script to run dump_syms on Chrome Linux executables and strip -# them if needed. - -set -e - -usage() { - echo -n "$0 " >&2 - echo " " >&2 -} - - -if [ $# -ne 4 ]; then - usage - exit 1 -fi - -SCRIPTDIR="$(readlink -f "$(dirname "$0")")" -DUMPSYMS="$1" -STRIP_BINARY="$2" -INFILE="$3" -OUTFILE="$4" - -# Dump the symbols from the given binary. -if [ ! -e "$OUTFILE" -o "$INFILE" -nt "$OUTFILE" ]; then - "$DUMPSYMS" -r "$INFILE" > "$OUTFILE" -fi - -if [ "$STRIP_BINARY" != "0" ]; then - strip "$INFILE" -fi diff --git a/build/linux/dump_app_syms.py b/build/linux/dump_app_syms.py new file mode 100644 index 00000000000000..c18bff77694ae2 --- /dev/null +++ b/build/linux/dump_app_syms.py @@ -0,0 +1,29 @@ +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Helper script to run dump_syms on Chrome Linux executables and strip +# them if needed. + +import os +import subprocess +import sys + +if len(sys.argv) != 5: + print "dump_app_syms.py " + print " " + sys.exit(1) + +dumpsyms = sys.argv[1] +strip_binary = sys.argv[2] +infile = sys.argv[3] +outfile = sys.argv[4] + +# Dump only when the output file is out-of-date. +if not os.path.isfile(outfile) or \ + os.stat(outfile).st_mtime > os.stat(infile).st_mtime: + with open(outfile, 'w') as outfileobj: + subprocess.check_call([dumpsyms, '-r', infile], stdout=outfileobj) + +if strip_binary != '0': + subprocess.check_call(['strip', infile]) diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn index 0d3d801ef0b937..e33713bf94c745 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn @@ -806,4 +806,40 @@ if (is_linux) { "-e s/@@CONFDIR@@/$confdir/", ] } + + action("linux_symbols") { + script = "//build/linux/dump_app_syms.py" + + dump_syms_label = "//breakpad:dump_syms($host_toolchain)" + dump_syms_binary = + get_label_info(dump_syms_label, "root_out_dir") + "/" + "dump_syms" + + chrome_binary = "$root_out_dir/chrome" + if (current_cpu == "x86") { + # Use "ia32" instead of "x86" for GYP compat. + symbol_file = "$root_out_dir/chrome.breakpad.ia32" + } else { + symbol_file = "$root_out_dir/chrome.breakpad.$current_cpu" + } + + inputs = [ + chrome_binary, + dump_syms_binary, + ] + outputs = [ + symbol_file, + ] + + args = [ + "./" + rebase_path(dump_syms_binary, root_build_dir), + "0", # TODO(GYP) This is linux_strip_binary if it is needed. + rebase_path(chrome_binary, root_build_dir), + rebase_path(symbol_file, root_build_dir), + ] + + deps = [ + ":chrome", + dump_syms_label, + ] + } } diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index e8c7a756ae5c01..633b8a25a0fae8 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -349,6 +349,7 @@ ['OS=="linux"', { 'targets': [ { + # GN version: //chrome:linux_symbols 'target_name': 'linux_symbols', 'type': 'none', 'conditions': [ @@ -357,14 +358,15 @@ { 'action_name': 'dump_symbols', 'inputs': [ - '<(DEPTH)/build/linux/dump_app_syms', + '<(DEPTH)/build/linux/dump_app_syms.py', '<(PRODUCT_DIR)/dump_syms', '<(PRODUCT_DIR)/chrome', ], 'outputs': [ '<(PRODUCT_DIR)/chrome.breakpad.<(target_arch)', ], - 'action': ['<(DEPTH)/build/linux/dump_app_syms', + 'action': ['python', + '<(DEPTH)/build/linux/dump_app_syms.py', '<(PRODUCT_DIR)/dump_syms', '<(linux_strip_binary)', '<(PRODUCT_DIR)/chrome',