Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is msbuild and link.exe "hanging" during a build?

We have a few C++ solutions and we run some build scripts using batch files that call msbuild.exe for each of the configurations in the solutions.

This had been working fine on 3 developer machines and one build machine, but then one of the projects started to hang when linking. This only happens on the newest machine which is a quad core, 2.8ghz I think. It runs on Windows Server 2003 and the others are on XP or Vista.

This happens consistently even if I change the order of builds in the bat file.

If I run the build from the IDE on that machine it does not hang.

Any ideas about what could possibly be causing this?

I am using Visual Studio 2008.


Edit:

I see now that when it is hung the following are running:

  • link.exe (2 instances) One with large memory usage and one with a small amount of memory usage.
  • vcbuild.exe
  • msbuild.exe
  • vcbuildhelper.exe
  • mspdbsrv.exe

Edit:

The exe file exists and so does the pdb file.

The exe file is locked by some process, and I can't delete it or move it. I can delete the pdb file though.

I also have the problem if I just use VCBuild.exe.

I decided to try debugging the 2 link.exe processes and the mspdbsrv.exe processes.

When I attached the debugger/MSdev IDE to them I got a message box saying that the application was deadlocked and/or that "all threads have exited".

I guess I will have to check for a service pack for that msdev install on that machine.


Edit:

In the debug.htm output file I get all sorts of stuff output after the link.exe command is generated.

However, for the release buildlog.htm the linke.exe line is the last line.

This is clearly a hang in the linker. Definitely a Microsoft bug.

I am now trying to figure out what the .rsp (linker response) file is.

When I issue:

link.exe @c:\\Release\RSP00000535202392.rsp /NOLOGO /ERRORREPORT:QUEUE

That is the last line in the release build log. The debug one has lots more information after that.

Reinstalling a different version of Visual Studio did not solve the problem.

I will open an issue/ticket with Microsoft. I will post an answer if I can.

like image 920
Tim Avatar asked Jul 03 '09 20:07

Tim


People also ask

What is MSBuild EXE?

The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software. Visual Studio uses MSBuild, but MSBuild doesn't depend on Visual Studio.

What is the difference between MSBuild and Visual Studio build?

Visual Studio determines the build order and calls into MSBuild separately (as needed), all completely under Visual Studio's control. Another difference arises when MSBuild is invoked with a solution file, MSBuild parses the solution file, creates a standard XML input file, evaluates it, and executes it as a project.

Can I use MSBuild without Visual Studio?

To install MSBuild on a system that doesn't have Visual Studio, go to Build Tools for Visual Studio 2019, or install the . NET SDK. If you have Visual Studio, then you already have MSBuild installed. With Visual Studio 2022, it's installed under the Visual Studio installation folder.

Is MSBuild a build tool?

MSBuild is a build tool that helps automate the process of creating a software product, including compiling the source code, packaging, testing, deployment and creating documentations. With MSBuild, it is possible to build Visual Studio projects and solutions without the Visual Studio IDE installed.


1 Answers

Whole-program optimization (/GL and /LTCG) and /MP don't mix -- the linker hangs. I raised this on Connect.

The upshot is that it's a confirmed bug in VS2008; contact PSS if you want a hotfix; and the fix is included in VS2010.

If you can't wait that long, turn off /MP (slower compiles) or /LTCG (slower code).

VS2012 screenshot for setting

like image 97
Roger Lipscombe Avatar answered Oct 02 '22 21:10

Roger Lipscombe