This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [Windows] test_distutils: fatal error LNK1158: cannot run 'rc.exe'
Type: Stage: resolved
Components: Tests, Windows Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: db3l, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords:

Created on 2017-11-07 09:53 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (7)
msg305728 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-07 09:53
test_distutils failed on AMD64 Windows10 3.x buildbot:

http://buildbot.python.org/all/#/builders/3/builds/128

0:19:07 [165/407/1] test_distutils failed -- running: test_multiprocessing_spawn (377 sec)
xxmodule.c
xxmodule.obj : warning LNK4197: export 'PyInit_xx' specified multiple times; using first specification
   Creating library d:\temp\tmp4zg7rpix\Debug\temp\tmp4zg7rpix\xx_d.cp37-win_amd64.lib and object d:\temp\tmp4zg7rpix\Debug\temp\tmp4zg7rpix\xx_d.cp37-win_amd64.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance
LINK : fatal error LNK1158: cannot run 'rc.exe'
foo.c
   Creating library d:\temp\tmpy79shh6o\tempt\temp\tmpl63x182t\foo_d.cp37-win_amd64.lib and object d:\temp\tmpy79shh6o\tempt\temp\tmpl63x182t\foo_d.cp37-win_amd64.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance
LINK : fatal error LNK1158: cannot run 'rc.exe'
xxmodule.c
xxmodule.obj : warning LNK4197: export 'PyInit_xx' specified multiple times; using first specification
   Creating library d:\temp\tmpkb4gpfw9\Debug\temp\tmpkb4gpfw9\xx_d.cp37-win_amd64.lib and object d:\temp\tmpkb4gpfw9\Debug\temp\tmpkb4gpfw9\xx_d.cp37-win_amd64.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance
LINK : fatal error LNK1158: cannot run 'rc.exe'
foo.c
   Creating library d:\temp\tmppmjpg5zh\tempt\temp\tmpi1x5uxdd\foo_d.cp37-win_amd64.lib and object d:\temp\tmppmjpg5zh\tempt\temp\tmpi1x5uxdd\foo_d.cp37-win_amd64.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance
LINK : fatal error LNK1158: cannot run 'rc.exe'
xxmodule.c
xxmodule.obj : warning LNK4197: export 'PyInit_xx' specified multiple times; using first specification
   Creating library build\temp.win-amd64-3.7-pydebug\Debug\xx_d.cp37-win_amd64.lib and object build\temp.win-amd64-3.7-pydebug\Debug\xx_d.cp37-win_amd64.exp
LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance
LINK : fatal error LNK1158: cannot run 'rc.exe'

D:\buildarea\3.x.bolen-windows10\build\build\test_python_2228>exit 1 

D:\buildarea\3.x.bolen-windows10\build\build\test_python_2228>exit 0

(...)


======================================================================
ERROR: test_build_ext (distutils.tests.test_build_ext.BuildExtTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\_msvccompiler.py", line 519, in link
    self.spawn([self.linker] + ld_args)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\_msvccompiler.py", line 542, in spawn
    return super().spawn(cmd)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\spawn.py", line 38, in spawn
    _spawn_nt(cmd, search_path, dry_run=dry_run)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\spawn.py", line 81, in _spawn_nt
    "command %r failed with exit status %d" % (cmd, rc))
distutils.errors.DistutilsExecError: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\tests\test_build_ext.py", line 82, in test_build_ext
    cmd.run()
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\command\build_ext.py", line 339, in run
    self.build_extensions()
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\command\build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\command\build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\command\build_ext.py", line 558, in build_extension
    target_lang=language)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\ccompiler.py", line 717, in link_shared_object
    extra_preargs, extra_postargs, build_temp, target_lang)
  File "D:\buildarea\3.x.bolen-windows10\build\lib\distutils\_msvccompiler.py", line 522, in link
    raise LinkError(msg)
distutils.errors.LinkError: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158
msg305729 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-07 09:55
Similar error on AMD64 Windows8 3.x:

http://buildbot.python.org/all/#/builders/32/builds/127
msg305730 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-07 09:58
I don't think that it's related, but a recent change in PCbuild is: bpo-31957.

IMHO it's more something that changed on the two buildbots.
msg305731 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-07 09:59
Hi David Bolen: Would you mind to look at this bug, please? thank you in advance ;-)
msg305735 - (view) Author: David Bolen (db3l) * Date: 2017-11-07 10:31
This seems to correlate with my upgrading to the latest Win10 SDK on those workers (Steve pointed out I was still getting ucrt warnings during compilation).  So they both jumped from like 10240 up to 16299.  But that's all I changed.

Interestingly I only had to fix 8.1 and 10, as 7 already had a version (15063) avoiding the warning, and it's tedious to change.  But it's not experiencing the linking problem.

I could swear I recall past link/rc problems, but my searching (and memory) are failing me at the moment.  But I wonder if that's why I had left these two workers back at 10240, or if I had some local fix in place.
msg305739 - (view) Author: David Bolen (db3l) * Date: 2017-11-07 11:42
Ok, so rc.exe appears truly not to be found when the test runs.  The binary is a bit buried in the Windows Kit directory tree, and I'm guessing something is off after the upgrade (I'm not sure where it was in the tree before).  I manually placed a copy in a directory I know is on the path and that seems to have resolved it.

I also found a similar copy of rc.exe from the SDK to a local directory on my Windows 7 worker, so I suspect that was what I was remembering, and I probably hit the same thing when updating the SDK on that worker previously.

Not sure if there's some better way it should work, but at least this resolves the issue from the SDK update - builds are currently in progress, but both workers passed test_distutils.
msg308402 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-12-15 15:13
The AMD64 Windows10 3.x buildbot: is green again, I close the issue.
History
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76148
2017-12-15 15:13:28vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg308402

stage: resolved
2017-11-07 11:42:35db3lsetmessages: + msg305739
2017-11-07 10:31:17db3lsetmessages: + msg305735
2017-11-07 09:59:52vstinnersetnosy: + db3l
messages: + msg305731
2017-11-07 09:58:26vstinnersetmessages: + msg305730
2017-11-07 09:55:01vstinnersetmessages: + msg305729
2017-11-07 09:53:23vstinnercreate