-
Notifications
You must be signed in to change notification settings - Fork 127
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
Wpf applications can't be published as a trimmed single exe #651
Comments
/cc @tgani-msft, @rladuca |
I found the root cause: The C++ compiler initializes static variables via data table in the metadata. Specifically, it generates The IL Linker reorders the Native vtables have the same issue since they use the same initialization mechanism (with To support C++/CLI images, the linker needs to preserve the ordering of the |
@sbomer do we know if the illinker can reliably rewrite all C++/CLI images? It may be safer to explicitly exclude such assemblies from rewriting (which would avoid this particular issue). |
I don't believe so - I agree that we should exclude them. @vatsan-madhavan /@jkoritzinsky is there a reliable way to distinguish C++/CLI images from normal managed dlls? If not we may need to special-case DirectWriteForwarder. |
You can reliably identify WPF's C++/CLI images by looking for I don't know of a way to reliably identify every C++/CLI image. WPF has two assemblies that are C++/CLI: |
The corflags (part of the COM_20 header) for C++/CLI images are 0x0... though even IL only images can also be 0x0 (though not when produced with our tooling). |
At present, WPF is the only real user of C++/CLI on .NET Core. When official support for C++/CLI is made available in Dev16.3 timeframe, we should either have linker support C++/CLI (which would amount to mixed-mode image support - likely a stretch-goal), or have the props/targets support in Visual Studio automatically stamp |
I don't know of any full proof way, but there's a few things that you could use as reliable heuristics.
|
The C++/CLI assemblies produced by WPF at present are
Not sure why |
Based on @vatsan-madhavan's response, you can also use the |
There is something odd going on. Here is what I see in my local build for a 32-bit image:
The compiler set |
Yeah now that you mention it I think ReadyToRun does that. Nevermind my previous comment about using that as a heuristic. |
I'm seeing that (non-C++/CLI) R2R assemblies (which the linker can process) are |
Verified local build output for x64 also -
|
So, crossgen'd WPF C++/CLI (clr/pure) are indistinguishable from crossgen'd .NET assemblies on the basis of ILOnly/ILLibrary, right? Does crossgen support mixed-mode assemblies? I'm also seeing some .NET assemblies with |
Sounds like a reasonable plan to me. An authoritative answer is best obtained from @tgani-msft (better asked over email) - esp. if the plan is to leverage |
I tested this change (#658 - note the caveats mentioned in this PR) and this fixes the immediate issue. However the app still doesn't start unless
It seems that the inclusion of the debug dll lets it recover from the exception. The exception looks like it's caused by dotnet/wpf#634. greenshot/greenshot#135 (comment) suggests a fix is in the works for this - I will try this again when that's available. |
…C++/CLI images. See dotnet/linker#651 and dotnet/linker#658. In turn, this results in a failure of dependencies of such assemblies (like System.Diagnostics.Debug.dll, which is required by DirectWriteForwarder.dll) from being identified and included in the ReadyToRun images. These linker hints tell ILLinker to include certain dependencies, which we know to be required by DirectWriteForwarder and System.Printing respectively.
* When producing ReadyToRun images, the ILLinker is configured to skip C++/CLI images. See dotnet/linker#651 and dotnet/linker#658. In turn, this results in a failure of dependencies of such assemblies (like System.Diagnostics.Debug.dll, which is required by DirectWriteForwarder.dll) from being identified and included in the ReadyToRun images. These linker hints tell ILLinker to include certain dependencies, which we know to be required by DirectWriteForwarder and System.Printing respectively. * Add netstandard and mscorlib to the list of dependencies
Closing as the workaround has landed as well as the fix for System.Diagnostics.Debug. The support for C++ assemblies is tracked at #676 |
https://github.com/dotnet/coreclr/issues/25334#issue-459511455 from @Lakritzator
https://github.com/dotnet/coreclr/issues/25334#issuecomment-505107221 from @jeffschwMSFT
https://github.com/dotnet/coreclr/issues/25334#issuecomment-506836765 from @sbomer
The text was updated successfully, but these errors were encountered: