Commit 798beff1 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Check for LNK1201 and retry links when it occurs

LNK1201 seems to be happening increasingly frequently on our debug x64
builds for no clear reason. Subsequent builds tend to succeed so this
change updates our link wrapper to retry links when this error is hit.

This retry logic may solve the problem. If not then it gives us more
evidence about the problem, including a backup copy of the PDB that
might be helpful in investigating.

Bug: 782660
Change-Id: Iad60648425a01e07a20d108fcc5b74acaead9ee8
Reviewed-on: https://chromium-review.googlesource.com/769333
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516769}
parent 152e7cf9
...@@ -21,6 +21,13 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__)) ...@@ -21,6 +21,13 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# A regex matching an argument corresponding to the output filename passed to # A regex matching an argument corresponding to the output filename passed to
# link.exe. # link.exe.
_LINK_EXE_OUT_ARG = re.compile('/OUT:(?P<out>.+)$', re.IGNORECASE) _LINK_EXE_OUT_ARG = re.compile('/OUT:(?P<out>.+)$', re.IGNORECASE)
_LINK_PDB_OUT_ARG = re.compile('/PDB:(?P<out>.+)$', re.IGNORECASE)
_LINK_ERROR = re.compile('.* error LNK(\d+):')
# Retry links when this error is hit, to try to deal with crbug.com/782660
_LINKER_RETRY_ERRORS = 1201
# Maximum number of linker retries.
_LINKER_RETRIES = 3
def main(args): def main(args):
exit_code = WinTool().Dispatch(args) exit_code = WinTool().Dispatch(args)
...@@ -133,16 +140,34 @@ class WinTool(object): ...@@ -133,16 +140,34 @@ class WinTool(object):
# Popen(['/bin/sh', '-c', args[0], args[1], ...])" # Popen(['/bin/sh', '-c', args[0], args[1], ...])"
# For that reason, since going through the shell doesn't seem necessary on # For that reason, since going through the shell doesn't seem necessary on
# non-Windows don't do that there. # non-Windows don't do that there.
link = subprocess.Popen(args, shell=sys.platform == 'win32', env=env, pdb_name = None
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) for arg in args:
# Read output one line at a time as it shows up to avoid OOM failures when m = _LINK_PDB_OUT_ARG.match(arg)
# GBs of output is produced. if m:
for line in link.stdout: pdb_name = m.group('out')
if (not line.startswith(' Creating library ') and for retry_count in range(_LINKER_RETRIES):
not line.startswith('Generating code') and retry = False
not line.startswith('Finished generating code')): link = subprocess.Popen(args, shell=sys.platform == 'win32', env=env,
print line, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
return link.wait() # Read output one line at a time as it shows up to avoid OOM failures when
# GBs of output is produced.
for line in link.stdout:
if (not line.startswith(' Creating library ') and
not line.startswith('Generating code') and
not line.startswith('Finished generating code')):
m = _LINK_ERROR.match(line)
if m:
error_code = int(m.groups()[0])
if error_code == _LINKER_RETRY_ERRORS:
print 'Retrying link due to error %d' % error_code
if pdb_name:
shutil.copyfile(pdb_name, pdb_name + 'failure_backup')
retry = True
print line,
result = link.wait()
if not retry:
break
return result
def ExecAsmWrapper(self, arch, *args): def ExecAsmWrapper(self, arch, *args):
"""Filter logo banner from invocations of asm.exe.""" """Filter logo banner from invocations of asm.exe."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment