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 Jun 26, 2019
1 parent 66c3ba2 commit 347ee92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ step-maybe-electron-dist-strip: &step-maybe-electron-dist-strip
mkdir out/Default/debug
# Generate electron.debug. Required to do it from there in order to maintain debug references.
cd out/Default/debug
../../../electron/script/copy-debug-symbols.py --target-cpu="$TARGET_ARCH"
../../../electron/script/copy-debug-symbols.py --target-cpu="$TARGET_ARCH" --compress
../../../electron/script/strip-binaries.py --target-cpu="$TARGET_ARCH"
../../../electron/script/copy-debug-symbols.py --target-cpu="$TARGET_ARCH" --add-debug-link
fi
Expand Down
19 changes: 13 additions & 6 deletions script/copy-debug-symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
from lib.util import execute, get_out_dir

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

def copy_debug_from_binary(binary_path, target_cpu):
def copy_debug_from_binary(binary_path, target_cpu, compress):
objcopy = get_objcopy_path(target_cpu)
if not objcopy:
return
debug_name = get_debug_name(binary_path)
cmd = [objcopy, '--only-keep-debug', binary_path, debug_name]
cmd = [objcopy, '--only-keep-debug']
if compress:
cmd.extend(['--compress-debug-sections'])
cmd.extend([binary_path, debug_name])
execute(cmd)
return debug_name

Expand Down Expand Up @@ -57,9 +60,9 @@ def main():
add_debug_link_into_binaries(args.directory, args.target_cpu)
else:
if args.file:
copy_debug_from_binary(args.file, args.target_cpu)
copy_debug_from_binary(args.file, args.target_cpu, args.compress)
else:
copy_debug_from_binaries(args.directory, args.target_cpu)
copy_debug_from_binaries(args.directory, args.target_cpu, args.compress)

def parse_args():
parser = argparse.ArgumentParser(description='Copy debug from binaries')
Expand All @@ -81,6 +84,10 @@ def parse_args():
action='store_true',
required=False,
help='Path to a specific file to add the debug link')
parser.add_argument('--compress',
action='store_true',
required=False,
help='Compress the debug symbols')

return parser.parse_args()

Expand Down

0 comments on commit 347ee92

Please sign in to comment.