且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MSVC10/MP不能跨项目中的文件夹构建多核

更新时间:2022-06-23 05:29:22

项目在对象文件名"(在vcxproj XML中,在CL.exe命令行上为/Fo)中使用%(RelativeDir)导致msbuild更改为按目录将cpp文件批处理到cl.exe.这可能会对使用/MP获得的收益产生重大影响.

The use of %(RelativeDir) in "Object File Name" ( in the vcxproj XML, /Fo on the CL.exe command line ) project causes msbuild to batch the cpp files to cl.exe on a per directory basis. This can have a significant impact on the benefits gained from using /MP.

请注意,如果您的项目使用%(RelativeDir)作为目标文件,则其配置很可能会尝试避免与其他文件夹中具有相同名称的cpp文件中的.obj文件冲突.

Note that if your project uses %(RelativeDir) for object files its likely that the configuration is trying to avoid colliding .obj files that from cpp files with the same name in different folders.

/Fo命令行参数通常是编译器将obj文件转储到的文件夹-仅传递了一个,因此给定目录的所有cpp文件一次只能传递到CL.exe.

The /Fo command line parameter is typically a folder that the compiler dumps the obj files into - there is only ONE passed, so all of the cpp files for a given directory can only be passed to CL.exe at a time.

那是很痛苦的-但我很高兴有一个原因和解决方案.希望对您有所帮助.

That was a pain - but I'm glad there is a reason and a solution. Hope it helps.

更新

一个队友发现,每当将MSBuild参数发送到CL.exe时,它似乎都已损坏或严重限制了/MP.这很可能是因为/MP要正常工作,***CL.exe需要包含一堆cpp文件.

A team mate found that anytime an MSBuild parameter is sent to CL.exe it seems to break or severely limit /MP. This is most likely because for /MP to work well the top level CL.exe needs to have a bundle of cpp files.

我们的解决方案是对对象文件名"不使用任何msbuild参数(我认为其为%params%).这要求我们重命名一些cpp文件,以免它们冲突.

Our solution was to not use any msbuild params ( I think its the %params% ) for 'Object File Name'. This required that we rename some cpp files so they did not collide.

希望这在VS2012或VS2013中已更改.

Hope this has changed in VS2012 or VS2013.