| Index: build/toolchain/gcc_solink_wrapper.py
|
| diff --git a/build/toolchain/gcc_solink_wrapper.py b/build/toolchain/gcc_solink_wrapper.py
|
| index 426f9d66332ca34b755d112e4070864b0e4a0a7d..e7782b253c0b0b56ba6310e090e3b7233a8e994a 100755
|
| --- a/build/toolchain/gcc_solink_wrapper.py
|
| +++ b/build/toolchain/gcc_solink_wrapper.py
|
| @@ -11,9 +11,12 @@ does not have a POSIX-like shell (e.g. Windows).
|
| """
|
|
|
| import argparse
|
| +import gzip
|
| import os
|
| +import shutil
|
| import subprocess
|
| import sys
|
| +import threading
|
|
|
| import wrapper_utils
|
|
|
| @@ -57,6 +60,18 @@ def UpdateTOC(tocfile, toc):
|
| open(tocfile, 'w').write(toc)
|
|
|
|
|
| +def _GzipHelper(src_path, dest_path):
|
| + # Results for Android map file with GCC on a z620:
|
| + # Uncompressed: 207MB
|
| + # gzip -9: 16.4MB, takes 8.7 seconds.
|
| + # gzip -1: 21.8MB, takes 2.0 seconds.
|
| + # Piping directly from the linker via -print-map (or via -Map with a fifo)
|
| + # adds a whopping 30-45 seconds!
|
| + with open(src_path, 'rb') as f_in, gzip.GzipFile(dest_path, 'wb', 1) as f_out:
|
| + shutil.copyfileobj(f_in, f_out)
|
| + os.unlink(src_path)
|
| +
|
| +
|
| def main():
|
| parser = argparse.ArgumentParser(description=__doc__)
|
| parser.add_argument('--readelf',
|
| @@ -78,6 +93,10 @@ def main():
|
| required=True,
|
| help='Output table-of-contents file',
|
| metavar='FILE')
|
| + parser.add_argument('--mapfile',
|
| + help=('Use --Wl,-Map to generate a map file. Will be '
|
| + 'gzipped if extension ends with .gz'),
|
| + metavar='FILE')
|
| parser.add_argument('--output',
|
| required=True,
|
| help='Final output shared object file',
|
| @@ -99,8 +118,21 @@ def main():
|
| whitelist_candidates, args.resource_whitelist)
|
|
|
| # First, run the actual link.
|
| - result = subprocess.call(
|
| - wrapper_utils.CommandToRun(args.command), env=fast_env)
|
| + command = wrapper_utils.CommandToRun(args.command)
|
| + tmp_map_path = None
|
| + if args.mapfile and args.mapfile.endswith('.gz'):
|
| + tmp_map_path = args.mapfile + '.tmp'
|
| + command.append('-Wl,-Map,' + tmp_map_path)
|
| + elif args.mapfile:
|
| + command.append('-Wl,-Map,' + args.mapfile)
|
| + result = subprocess.call(command, env=fast_env)
|
| +
|
| + if tmp_map_path and result == 0:
|
| + threading.Thread(
|
| + target=lambda: _GzipHelper(tmp_map_path, args.mapfile)).start()
|
| + elif tmp_map_path and os.path.exists(tmp_map_file):
|
| + os.unlink(tmp_map_file)
|
| +
|
| if result != 0:
|
| return result
|
|
|
|
|