Skip to content

Commit

Permalink
Make gcc_solink_wrapper.py work with Python 3.
Browse files Browse the repository at this point in the history
This is sort of a reland of https://crrev.com/c/2260872, but rather than
calling bytes.decode() on every line we pass |universal_newlines=True| to
subprocess.Popen() so that |lines| is still a string and not a bytes object
in Python 3.

This approach does not cause the significant slowdown during linking that
led to the previous CL being reverted.

Bug: 941669
Change-Id: I92bc14d4dea01085f9f81153f610663960cc2fcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2263712
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781825}
  • Loading branch information
rakuco authored and Commit Bot committed Jun 24, 2020
1 parent 628e7ef commit 488379f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions build/toolchain/gcc_solink_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def CollectSONAME(args):
"""Replaces: readelf -d $sofile | grep SONAME"""
toc = ''
readelf = subprocess.Popen(wrapper_utils.CommandToRun(
[args.readelf, '-d', args.sofile]), stdout=subprocess.PIPE, bufsize=-1)
[args.readelf, '-d', args.sofile]),
stdout=subprocess.PIPE,
bufsize=-1,
universal_newlines=True)
for line in readelf.stdout:
if 'SONAME' in line:
toc += line
Expand All @@ -33,11 +36,11 @@ def CollectSONAME(args):
def CollectDynSym(args):
"""Replaces: nm --format=posix -g -D -p $sofile | cut -f1-2 -d' '"""
toc = ''
nm = subprocess.Popen(
wrapper_utils.CommandToRun(
[args.nm, '--format=posix', '-g', '-D', '-p', args.sofile]),
stdout=subprocess.PIPE,
bufsize=-1)
nm = subprocess.Popen(wrapper_utils.CommandToRun(
[args.nm, '--format=posix', '-g', '-D', '-p', args.sofile]),
stdout=subprocess.PIPE,
bufsize=-1,
universal_newlines=True)
for line in nm.stdout:
toc += ' '.join(line.split(' ', 2)[:2]) + '\n'
return nm.wait(), toc
Expand Down

0 comments on commit 488379f

Please sign in to comment.