Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Unified Diff: build/toolchain/gcc_solink_wrapper.py

Issue 2726983004: Output a linker map file for official builds (Closed)
Patch Set: guard behind is_official_build Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/toolchain/gcc_toolchain.gni » ('j') | build/toolchain/gcc_toolchain.gni » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | build/toolchain/gcc_toolchain.gni » ('j') | build/toolchain/gcc_toolchain.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698