Skip to content

Commit

Permalink
ci compress linux debug symbols
Browse files Browse the repository at this point in the history
Start compressing the extracted debug symbols. The current size of the
.debug file is over 2 GB.

#13315
  • Loading branch information
Samuel Clark authored and Julien Isorce committed Jul 15, 2019
1 parent b8379aa commit 276fe5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ step-maybe-electron-dist-strip: &step-maybe-electron-dist-strip
command: |
if [ "$STRIP_BINARIES" == "true" ] && [ "`uname`" != "Darwin" ]; then
cd src
electron/script/copy-debug-symbols.py --target-cpu="$TARGET_ARCH" --out-dir=out/Default/debug
electron/script/copy-debug-symbols.py --target-cpu="$TARGET_ARCH" --out-dir=out/Default/debug --compress
electron/script/strip-binaries.py --target-cpu="$TARGET_ARCH"
electron/script/add-debug-link.py --target-cpu="$TARGET_ARCH"
fi
Expand Down
22 changes: 15 additions & 7 deletions script/copy-debug-symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from lib.util import execute, get_objcopy_path, get_out_dir, safe_mkdir

# It has to be done before stripping the binaries.
def copy_debug_from_binaries(directory, out_dir, target_cpu):
def copy_debug_from_binaries(directory, out_dir, target_cpu, compress):
for binary in LINUX_BINARIES:
binary_path = os.path.join(directory, binary)
if os.path.isfile(binary_path):
copy_debug_from_binary(binary_path, out_dir, target_cpu)
copy_debug_from_binary(binary_path, out_dir, target_cpu, compress)

def copy_debug_from_binary(binary_path, out_dir, target_cpu):
def copy_debug_from_binary(binary_path, out_dir, target_cpum, compress):
try:
objcopy = get_objcopy_path(target_cpu)
except:
Expand All @@ -23,8 +23,10 @@ def copy_debug_from_binary(binary_path, out_dir, target_cpu):
return
raise
debug_name = get_debug_name(binary_path)
cmd = [objcopy, '--only-keep-debug', binary_path,
os.path.join(out_dir, debug_name)]
cmd = [objcopy, '--only-keep-debug']
if compress:
cmd.extend(['--compress-debug-sections'])
cmd.extend([binary_path, os.path.join(out_dir, debug_name)])
execute(cmd)
return debug_name

Expand All @@ -35,9 +37,11 @@ def main():
args = parse_args()
safe_mkdir(args.out_dir)
if args.file:
copy_debug_from_binary(args.file, args.out_dir, args.target_cpu)
copy_debug_from_binary(args.file, args.out_dir, args.target_cpu,
args.compress)
else:
copy_debug_from_binaries(args.directory, args.out_dir, args.target_cpu)
copy_debug_from_binaries(args.directory, args.out_dir, args.target_cpu,
args.compress)

def parse_args():
parser = argparse.ArgumentParser(description='Copy debug from binaries')
Expand All @@ -59,6 +63,10 @@ def parse_args():
default='',
required=False,
help='Target cpu of binaries to copy debug symbols')
parser.add_argument('--compress',
action='store_true',
required=False,
help='Compress the debug symbols')

return parser.parse_args()

Expand Down

0 comments on commit 276fe5e

Please sign in to comment.