I noticed that a small program takes ~ 15 ms to call when compiling with vs2012 than in 2010. This does not seem like much, but it can be called many times, and we observe a ~ 2x slowdown due to this additional 15 ms.
I found a workaround that I provided below, but my question is that this is what I am doing wrong, or if I see an error in how Visual Studio 2012 implemented the / MANIFEST: embed option, Sorry for following below, but itβs hard for me to be both thorough and concise at the same time.
About my environment:
Windows 7 Enterprise x64 + Service Pack 1
c:\tmp>cl
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.60610.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
c:\tmp>mt
Microsoft (R) Manifest Tool version 6.2.9200.16384
Copyright (c) Microsoft Corporation 2012.
All rights reserved.
I can play by running a new empty console console. One source file with this simple code:
#include <iostream>
#include <string>
int main()
{
std::string buf;
while(std::cin >> buf)
{
std::cout << buf;
buf="";
}
}
VS, ( vs , VS2012) - test.cpp, Developer Command Prompt VS 2012, :
CL.exe /c /Zi /nologo /W3 /WX- /sdl /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fd"test.pdb" /Gd /TP /analyze- /errorReport:prompt test.cpp
link.exe /ERRORREPORT:PROMPT /OUT:test.exe /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"test.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"test.lib" /MACHINE:X86 /SAFESEH test.obj
test.exe , , :
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
bat , 100 :
echo "Hello" | test.exe
, 4.5s ( cygwin, )
$ time ./test.bat
"Hello""Hello""Hell
o""Hello""Hello""He
llo""Hello""Hello""
real 0m4.523s
user 0m0.015s
sys 0m0.015s
, /: , test.exe.manifest
link.exe /ERRORREPORT:PROMPT /OUT:test.exe /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"test.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"test.lib" /MACHINE:X86 /SAFESEH test.obj
VS2010 . , test.exe.manifest:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
, exe . , , , test.exe . test.exe.manifest,
mt.exe -outputresource:test.exe;#1 -manifest test.exe.manifest
, test.exe , requestExecutionLevel - , . xml, <key></key>, <key... \>, .
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
100 bat bat 1,5
$ time ./test.bat
"Hello""Hello""Hell
o""Hello""Hello""He
llo""Hello""Hello""
real 0m3.095s
user 0m0.015s
sys 0m0.000s
, , <requestedExecutionLevel level=.... \> <requestedExecutionLevel level=... ></requestedExecutionLevel>
- , mt.exe , ?
test.exe , " " "" "-" > " ". " " $(IntDir) $(TargetName) $(TargetExt).intermediate.manifest( , Linker > Manifest File > " " ). " " , "" > " " " " /outputresource:"$(TargetDir)$(TargetName)$(TargetExt);#1"
CMAKE , , CMAKE.
mt.exe , , , . , , , , , , . dummy.manifest UAC.
dummy.manifest:
?<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
</trustInfo>
</assembly>
:
IF(WIN32)
ADD_CUSTOM_COMMAND(TARGET test
POST_BUILD
COMMAND "mt.exe" "-inputresource:\"$(TargetDir)\\$(TargetFileName);#1\" -out:\"${CMAKE_CURRENT_BINARY_DIR}/$(TargetFileName).fix.manifest\""
COMMAND "mt.exe" "-outputresource:\"$(TargetDir)\\$(TargetFileName);#1\" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}/dummy.manifest\""
COMMAND "mt.exe" "-outputresource:\"$(TargetDir)\\$(TargetFileName);#1\" -manifest \"${CMAKE_CURRENT_BINARY_DIR}/$(TargetFileName).fix.manifest\""
COMMENT "Fixing bad manifest file"
)
ENDIF(WIN32)
, , .
, , 15 . , /MANIFEST: embed, , 2010 mt.exe.