Pass the mspdbsrv flag as a command line argument to the link wrapper.
This variable causes separate instances of mspdbsrv to be used
for each invocation of the linker.
Patch by sebmarchand@chromium.org.
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/134383002
git-svn-id: http://gyp.googlecode.com/svn/trunk@1835 78cadc50-ecff-11dd-a971-7dbc132099af
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index b85b7a8..7461814 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -1606,10 +1606,12 @@
'resname': resource_name,
'embed': embed_manifest }
rule_name_suffix = _GetWinLinkRuleNameSuffix(embed_manifest)
+ use_separate_mspdbsrv = (
+ int(os.environ.get('GYP_USE_SEPARATE_MSPDBSRV', '0')) != 0)
dlldesc = 'LINK%s(DLL) $binary' % rule_name_suffix.upper()
- dllcmd = ('%s gyp-win-tool link-wrapper $arch '
+ dllcmd = ('%s gyp-win-tool link-wrapper $arch %s '
'$ld /nologo $implibflag /DLL /OUT:$binary '
- '@$binary.rsp' % sys.executable)
+ '@$binary.rsp' % (sys.executable, use_separate_mspdbsrv))
dllcmd = FullLinkCommand(dllcmd, '$binary', 'dll')
master_ninja.rule('solink' + rule_name_suffix,
description=dlldesc, command=dllcmd,
@@ -1625,9 +1627,9 @@
pool='link_pool')
# Note that ldflags goes at the end so that it has the option of
# overriding default settings earlier in the command line.
- exe_cmd = ('%s gyp-win-tool link-wrapper $arch '
+ exe_cmd = ('%s gyp-win-tool link-wrapper $arch %s '
'$ld /nologo /OUT:$binary @$binary.rsp' %
- sys.executable)
+ (sys.executable, use_separate_mspdbsrv))
exe_cmd = FullLinkCommand(exe_cmd, '$binary', 'exe')
master_ninja.rule('link' + rule_name_suffix,
description='LINK%s $binary' % rule_name_suffix.upper(),
@@ -1892,7 +1894,7 @@
master_ninja.rule(
'alink',
description='LIB $out',
- command=('%s gyp-win-tool link-wrapper $arch '
+ command=('%s gyp-win-tool link-wrapper $arch False '
'$ar /nologo /ignore:4221 /OUT:$out @$out.rsp' %
sys.executable),
rspfile='$out.rsp',
diff --git a/pylib/gyp/win_tool.py b/pylib/gyp/win_tool.py
index 1634ff9..e2b06be 100755
--- a/pylib/gyp/win_tool.py
+++ b/pylib/gyp/win_tool.py
@@ -18,9 +18,9 @@
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
-# A regex matching an argument corresponding to a PDB filename passed as an
-# argument to link.exe.
-_LINK_EXE_PDB_ARG = re.compile('/PDB:(?P<pdb>.+\.exe\.pdb)$', re.IGNORECASE)
+# A regex matching an argument corresponding to the output filename passed to
+# link.exe.
+_LINK_EXE_OUT_ARG = re.compile('/OUT:(?P<out>.+)$', re.IGNORECASE)
def main(args):
executor = WinTool()
@@ -33,25 +33,22 @@
"""This class performs all the Windows tooling steps. The methods can either
be executed directly, or dispatched from an argument list."""
- def _MaybeUseSeparateMspdbsrv(self, env, args):
- """Allows to use a unique instance of mspdbsrv.exe for the linkers linking
- an .exe target if GYP_USE_SEPARATE_MSPDBSRV has been set."""
- if not os.environ.get('GYP_USE_SEPARATE_MSPDBSRV'):
- return
-
+ def _UseSeparateMspdbsrv(self, env, args):
+ """Allows to use a unique instance of mspdbsrv.exe per linker instead of a
+ shared one."""
if len(args) < 1:
raise Exception("Not enough arguments")
if args[0] != 'link.exe':
return
- # Checks if this linker produces a PDB for an .exe target. If so use the
- # name of this PDB to generate an endpoint name for mspdbsrv.exe.
+ # Use the output filename passed to the linker to generate an endpoint name
+ # for mspdbsrv.exe.
endpoint_name = None
for arg in args:
- m = _LINK_EXE_PDB_ARG.match(arg)
+ m = _LINK_EXE_OUT_ARG.match(arg)
if m:
- endpoint_name = '%s_%d' % (m.group('pdb'), os.getpid())
+ endpoint_name = '%s_%d' % (m.group('out'), os.getpid())
break
if endpoint_name is None:
@@ -99,13 +96,14 @@
else:
shutil.copy2(source, dest)
- def ExecLinkWrapper(self, arch, *args):
+ def ExecLinkWrapper(self, arch, use_separate_mspdbsrv, *args):
"""Filter diagnostic output from link that looks like:
' Creating library ui.dll.lib and object ui.dll.exp'
This happens when there are exports from the dll or exe.
"""
env = self._GetEnv(arch)
- self._MaybeUseSeparateMspdbsrv(env, args)
+ if use_separate_mspdbsrv == 'True':
+ self._UseSeparateMspdbsrv(env, args)
link = subprocess.Popen(args,
shell=True,
env=env,