-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle /notify_update in mt wrapper #63
Conversation
If this patch is tested to work (I haven't tried the syntax Do you happen to know in which cases cmake does try to execute On the other hand, it looks like |
Testing a dummy cmake project on Windows with Ninja, we can see the output for the first time generating the binary by setting env var Visual Studio Incremental Link with embedded manifests
Create test\CMakeFiles\naive_echo.dir/manifest.rc
Create empty: test\CMakeFiles\naive_echo.dir/embed.manifest
RC Pass 1:
C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe /fo test\CMakeFiles\naive_echo.dir/manifest.res test\CMakeFiles\naive_echo.dir/manifest.rc
LINK Pass 1:
C:\PROGRA~1\MIB055~1\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\link.exe /nologo test\CMakeFiles\naive_echo.dir\echo.c.obj /out:bin\naive_echo.exe /implib:test\naive_echo.lib /pdb:bin\naive_echo.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:test\CMakeFiles\naive_echo.dir/intermediate.manifest test\CMakeFiles\naive_echo.dir/manifest.res
MT:
C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe /nologo /manifest test\CMakeFiles\naive_echo.dir/intermediate.manifest /out:test\CMakeFiles\naive_echo.dir/embed.manifest /notify_update
RC Pass 2:
C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe /fo test\CMakeFiles\naive_echo.dir/manifest.res test\CMakeFiles\naive_echo.dir/manifest.rc
FINAL LINK:
C:\PROGRA~1\MIB055~1\2022\ENTERP~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\link.exe /nologo test\CMakeFiles\naive_echo.dir\echo.c.obj /out:bin\naive_echo.exe /implib:test\naive_echo.lib /pdb:bin\naive_echo.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:test\CMakeFiles\naive_echo.dir/intermediate.manifest test\CMakeFiles\naive_echo.dir/manifest.res
<?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>
Using linux utility <?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"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly> |
If we silently ignore I reworked the PR to return I think we can add a CI test for this case. Checking |
Oh, I see - so in builds with the patched cmake, it has actually never merged the manifest in the end?
Interesting; good that this can be done with a return code within 0-255 and not requiring a full 32 bit windows style return code too.
Ok, good. FWIW, for CI I don't think we strictly need to check that the manifest actually is included - I would settle for the level of smoke testing to see that building doesn't fail - we'd just need to build a test project that actually trigger including a manifest (do all cmake builds include that)? |
No, merging is always done, but the output That means if we don't handle Worse, if there is a user provided manifest, and it is modified, cmake will re-link, but the changes is not included into final binary. (cmake supports manifests as source files, simply use
Yes, incremental link (default for debug build) always invokes |
8497edf
to
b562527
Compare
After further testing, Testing: > rm -f embed.manifest
> /opt/msvc/bin/x64/mt /nologo /manifest wmain.manifest /out:embed.manifest /notify_update
> echo $?
187
> /opt/msvc/bin/x64/mt /nologo /manifest wmain.manifest /out:embed.manifest /notify_update
> echo $?
0
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<application>
<windowsSettings>
<!-- https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page -->
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
</windowsSettings>
</application>
</assembly> |
|
CMake invokes mt.exe with the undocumented option, and mt.exe may exit with 0x41020001. The exit code is truncated to 8 bits on POSIX hosts. https://gitlab.kitware.com/cmake/cmake/-/blob/0991023c30ed5b83bcb1446b5bcc9c1eae028835/Source/cmcmd.cxx#L2533 https://gitlab.kitware.com/cmake/cmake/-/blob/0991023c30ed5b83bcb1446b5bcc9c1eae028835/Source/cmcmd.cxx#L2388 Fixes mstorsjo#45
LGTM, thanks! |
CMake invokes mt.exe with the undocumented option, and mt.exe may exit with 0x41020001.
The exit code is truncated to 8 bits on POSIX hosts.
Translate exit code of mt.exe in bat file.
https://gitlab.kitware.com/cmake/cmake/-/blob/0991023c30ed5b83bcb1446b5bcc9c1eae028835/Source/cmcmd.cxx#L2533
https://gitlab.kitware.com/cmake/cmake/-/blob/0991023c30ed5b83bcb1446b5bcc9c1eae028835/Source/cmcmd.cxx#L2388
Fixes #45