-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
ILStrip failure for FsToolkit.ErrorHandling(Must be of type CilStrip.Mono.Cecil.TypeReference) #87867
Comments
From @rolfbjarne on Wed, 21 Jun 2023 12:18:17 GMT Smaller repro: testproj.zip Download & execute:
|
From @rolfbjarne on Wed, 21 Jun 2023 12:18:34 GMT
It's rather ugly, but you can add something like this to your project file: <Target Name="_RemoveILStripTrigger" BeforeTargets="_StripAssemblyIL">
<ItemGroup>
<_RemovedResolvedFileToPublish Include="@(ResolvedFileToPublish)" Condition="'%(Filename)%(Extension)' == 'FsToolkit.ErrorHandling.dll'" />
<ResolvedFileToPublish Remove="@(_RemovedResolvedFileToPublish)" />
</ItemGroup>
</Target>
<Target Name="_RestoreILStripTrigger" AfterTargets="_StripAssemblyIL">
<ItemGroup>
<ResolvedFileToPublish Include="@(_RemovedResolvedFileToPublish)" />
</ItemGroup>
</Target> |
From @rolfbjarne on Wed, 21 Jun 2023 12:18:58 GMT Moving to dotnet/runtime, since the ILStrip implementation lives there. |
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas Issue DetailsFrom @NickDarvey on Wed, 21 Jun 2023 11:28:51 GMT Steps to Reproduce
Expected BehaviorRelease build completes. Actual Behavior
EnvironmentVersion information
Build Logs and Example ProjectWorkaroundDisabling IL stripping, as described in xamarin/xamarin-macios#14841 (comment), works. Is there a way to only disable it for this asssembly? Copied from original issue xamarin/xamarin-macios#18485
|
I can replicate the issue both with the current ILStrip and one from net6.0. |
Moving to net9.0, since there is a workaround. |
When opening the assembly to be trimmed, Cecil chokes on the following method: .method public static
valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpValueOption`1<!!'value'> tryParse$W<'value'> (
class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!!'value'&, bool>> tryParse,
string valueToParse
) cil managed
{...} Note the |
This is our repro https://github.com/Ecierge/FsToolkit.ErrorHandling_AOT_repro on .NET 8 |
This makes me sad... The ILStrip task uses a private copy of Mono.Cecil because it seems to need to set metadata token values (which mainline Cecil doesn't support). This private copy is maintained in dotnet/runtime-assets and was added with dotnet/runtime-assets#160. But it's really just a copy from mono/mono which was added with mono/mono@29e9001. That is a 14 years old commit - there's no way to tell how old the source was when the copy was made, but at least 14 years. The problem:
The thing which breaks the 14 year old Cecil is a ref type in a generic parameter - not surprising as ref types didn't exist 14 years ago really - specifically this: https://github.com/demystifyfp/FsToolkit.ErrorHandling/blob/fd9460f0bfa9b670d7ef95ba48ec274a5146871c/src/FsToolkit.ErrorHandling/ValueOption.fs#L44 Quick look at the usage of Cecil says that this is not going to be easy to fix as Cecil changed a LOT since then (the public APIs used The "fix" for this whole situation is probably tracked by #60273. Honestly, it's surprising this is not a more common problem. /cc @steveisok |
Any updates? |
From @NickDarvey on Wed, 21 Jun 2023 11:28:51 GMT
Steps to Reproduce
FsToolkitiOSApp.zip
(attached)Expected Behavior
Release build completes.
Actual Behavior
Environment
Version information
Build Logs and Example Project
FsToolkitiOSApp.zip
Workaround
Disabling IL stripping, as described in xamarin/xamarin-macios#14841 (comment), works.
Is there a way to only disable it for this asssembly?
Copied from original issue xamarin/xamarin-macios#18485
The text was updated successfully, but these errors were encountered: