How can msbuild.exe be set up to embed the proper value for SSE2 into _M_IX86_FP?

点点圈 提交于 2021-01-28 01:56:56

问题


I have built a solution with VS2010 Express Edition with SSE2 set in the properties C++ code generation enhanced instruction set. Then in the program test against predefined MARCO _M_IX86_FP yields as expected the value of 2. The same project built with msbuild.exe with

/p:"VCBuildAdditionalOptions=/arch:SSE2"

appears to build the solution with /arch:SSE2 in place for each project. But, the test against predefined MARCO _M_IX86_FP yields a value of zero.

How can msbuild.exe be set up to embed the proper value for SSE2 into _M_IX86_FP?

testcase

// sse2testcase.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
    int dummy;
    if (_M_IX86_FP == 0)
        std::cout << "No sse" <<std::endl;
    if (_M_IX86_FP == 1)
        std::cout << "sse1" <<std::endl;
    if (_M_IX86_FP == 2)
        std::cout << "sse2" <<std::endl;
    std::cin >> dummy;
    return 0;

}

Result build with msbuild fails to present the proper values of _M_IX86_FP

Workaround:
1. Open Visual Studio 2010 IDE
2. Open or create a solution. (Any solution will do)
3. Tools->Settings Check mark Expert Settings
4. At the bottom of the Solution Panel Select Properties (Text may be truncated)
5. Expand either Debug or Release.
6. Right click on Microsoft.Cpp.Win32.user
7. Expand C++ and select Code Generation
8. Next to Enable Enhanced Instruction Set. Select the desired setting.
9. Apply
10. Exit Visual Studio 2010 saving when requested.

Microsoft.Cpp.Win32.user settings apply to all solutions and projects. This forces the setting of /arch:SSE or /arch:SSE2 to be present when Msbuild.exe invokes Cl.exe. The switch /p:"VCBuildAdditionalOptions=/arch:SSE2" is not needed. Still don't know why it doesn't work.

I guess you can't answer you own question.


回答1:


A more thorough answer from Microsoft.

http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/2b772255-b37b-4da1-bc1e-b4681f5122f3/




回答2:


Workaround:

  1. Open Visual Studio 2010 IDE
  2. Open or create a solution. (Any solution will do)
  3. Tools->Settings Check mark Expert Settings
  4. At the bottom of the Solution Panel Select Properties (Text may be truncated)
  5. Expand either Debug or Release,
  6. Right click on Microsoft.Cpp.Win32.user
  7. Expand C++ and select Code Generation
  8. Next to Enable Enhanced Instruction Set. Select the desired setting.
  9. Apply
  10. Exit Visual Studio 2010 saving when requested.

Microsoft.Cpp.Win32.user settings apply to all solutions and projects. This forces the setting of /arch:SSE or /arch:SSE2 to be present when Msbuild.exe invokes Cl.exe. The switch /p:"VCBuildAdditionalOptions=/arch:SSE2" is not needed. Still don't know why it doesn't work.



来源:https://stackoverflow.com/questions/6448256/how-can-msbuild-exe-be-set-up-to-embed-the-proper-value-for-sse2-into-m-ix86-fp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!