-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Compile OpenConsoleProxy without CRT #11610
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it works, I'm good.
This comment has been minimized.
This comment has been minimized.
36772ef
to
17526d6
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
17526d6
to
9ee9026
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// but we need one to compile IID_GENERIC_CHECK_IID. | ||
// Luckily we only ever use memcmp for IIDs. | ||
#pragma function(memcmp) | ||
inline int memcmp(const IID* a, const IID* b, size_t count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WOW. Clever, but scary. No way to ensure that we do not explode if a dependency creeps in!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we ever introduce another dependency on memcmp we could just write a generic one. It's fairly easy to write one, but I figured this one is a bit leaner (since it just delegates).
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<CallingConvention>StdCall</CallingConvention> | ||
<AdditionalIncludeDirectories>.;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
<CallingConvention Condition="'$(Platform)'!='ARM64'">StdCall</CallingConvention> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not break arm64 .... does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler was complaining on ARM64 that /Zg isn't a valid option actually so I silenced it.
Co-authored-by: Dustin L. Howett <[email protected]>
Validated on ARM64 with https://dev.azure.com/microsoft/Dart/_build/results?buildId=40697594&view=results from this branch. It works now |
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Hi! Sorry to crash your dev party, but what's CRT? I came from the now closed #11529, and I don't quite understand the assumption if the user doesn't have a CRT installed globally on their system. 11529 was repro on Windows 11 out of the box. What exactly did you expect to be installed globally that wasn't shipped with the OS? Also makes me wonder how it was tested. Thanks, |
Sure! So, the "CRT" is the C Runtime. It is distributed in the "Visual C++ Redistributable" package that you've probably seen on most of your computers. That package includes a few DLLs: They're also not installed by default on Windows. You can find it here, or wait for it to be installed by another piece of software. Michael and Leonard tested on a fresh Windows 11 machine that could not launch Terminal by default. The fix here is to not depend on those DLLs at all. "OpenConsoleProxy" is another DLL file that tells Windows how to activate Terminal, and it doesn't depend on anything from those DLLs. They were marked as "required" by mistake. We did not find this in our own testing because all of our development computers have the Visual C++ Redistributable installed already, since it comes with so much other software (like Visual Studio!) |
Sorry, when we say CRT we mean the C Runtime Library. We didn't expect this dll to have a dependency on the CRT at all. That's what we get for re-using our build scripts for every project in our solution blindly 😅. |
@DHowett thanks, that's a perfect explanation |
Hello! I do confirm that installing VC++ redist facilitates the expected behavior. However, this only applies to non-elevated cmd / powershell. Their elevated instances still open as their own separate windows, regardless of whether an elevated WT is open or not (i.e. Is this the expected behavior? If not, please point to the existing issue, as I can't find it (tried this query and variants). |
Alas, that is by design. From #10276 (comment)
|
🎉 Handy links: |
🎉 Handy links: |
When #13160 introduced a new interface to the IConsoleHandoff idl, it changed midl's RPC proxy stub lookup algorithm from a direct GUID comparison to an unrolled binary search. Now, that would ordinarily not be a problem... However, in #11610, we took a shortcut and replaced `memcmp` -- used only by RPC for GUID comparison -- with a direct GUID-only equality comparator. This worked totally fine, and ordinarily would not be a problem... The unrolled binary search unfortunately _relies on memcmp's contract_: it uses memcmp to match against a fully sorted set. Our memcmp only returned 0 or 1 (equal or not), and it knew nothing about ordering. When a package that contains a PackagedCOM proxy stub is installed, it is selected as the primary proxy stub for any interfaces it can proxy. After all, interfaces are immutable, so it doesn't matter whose proxy you're using. Now, given that we installed a *broken* proxy... *all* IIDs that got whacked by our memcmp issue broke for every consumer. To fix it: instead of implementing memcmp ourselves, we're just going to take a page out of WinAppSDK's book and link this binary using the "Hybrid CRT" model. It will statically link any parts of the STL it uses (none) and dynamically link the ucrt (which is guaranteed to be present on Windows.) Sure, the binary size goes up from 8k to 24k, but... the cost is never having to worry about this again. Closes #13251
After this commit OpenConsoleProxy will be built without a CRT.
This cuts down its binary size and DLL dependency bloat.
We hope that this fixes a COM server activation bug if the
user doesn't have a CRT installed globally on their system.
Fixes #11529