dotnet / dotnet/fsharp

F# compiler is generating invalid IL for SRTP witness methods with `byref<T>` in the SRTP signature

Open
#18,702 23 comments 0 reactions 0 assignees View on GitHub
Needs-Triage
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

_From @NickDarvey on Wed, 21 Jun 2023 11:28:51 GMT_

### Steps to Reproduce

1. Download `FsToolkitiOSApp.zip` (attached)
2. Run
```
dotnet build -c Release -t:Run -f net7.0-ios -p:RuntimeIdentifier=ios-arm64 -p:_DeviceName=1234 -bl
```

### Expected Behavior

Release build completes.

### Actual Behavior

```
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.7067/targets/Xamarin.Shared.Sdk.targets(765,3): ILStrip failed for obj/Release/net7.0-ios/ios-arm64/linked/FsToolkit.ErrorHandling.dll: Must be of type CilStrip.Mono.Cecil.TypeReference [/FsToolkitiOSApp.fsproj]

System.ArgumentException: Must be of type CilStrip.Mono.Cecil.TypeReference
at CilStrip.Mono.Cecil.GenericArgumentCollection.OnValidate(Object o)
at System.Collections.CollectionBase.System.Collections.IList.Add(Object value)
at CilStrip.Mono.Cecil.GenericArgumentCollection.Add(TypeReference value)
at CilStrip.Mono.Cecil.ReflectionReader.GetTypeRefFromSig(SigType t, GenericContext context)
at CilStrip.Mono.Cecil.ReflectionReader.GetGenericArg(GenericArg arg, GenericContext context)
at CilStrip.Mono.Cecil.ReflectionReader.GetTypeRefFromSig(SigType t, GenericContext context)
at CilStrip.Mono.Cecil.ReflectionReader.CompleteParameter(ParameterDefinition parameter, Param signature, GenericContext context)
at CilStrip.Mono.Cecil.ReflectionReader.BuildParameterDefinition(String name, Int32 sequence, ParameterAttributes attrs, Param psig, GenericContext context)
at CilStrip.Mono.Cecil.ReflectionReader.CompleteMethods()
at CilStrip.Mono.Cecil.ReflectionReader.VisitTypeDefinitionCollection(TypeDefinitionCollection types)
at CilStrip.Mono.Cecil.AggressiveReflectionReader.VisitTypeDefinitionCollection(TypeDefinitionCollection types)
at CilStrip.Mono.Cecil.ReflectionReader.VisitModuleDefinition(ModuleDefinition mod)
at CilStrip.Mono.Cecil.StructureReader.TerminateAssemblyDefinition(AssemblyDefinition asm)
at CilStrip.Mono.Cecil.AssemblyDefinition.Accept(IReflectionStructureVisitor visitor)
at CilStrip.Mono.Cecil.AssemblyFactory.GetAssembly(ImageReader irv, Boolean manifestOnly)
at CilStrip.Mono.Cecil.AssemblyFactory.GetAssembly(ImageReader reader)
at CilStrip.Mono.Cecil.AssemblyFactory.GetAssembly(String file)
at ILStrip.StripAssembly(ITaskItem assemblyItem)

```

### Environment

Version information

```
dotnet 7.0.304
dotnet workload maui-ios 7.0.86/7.0.100
```

### Build Logs and Example Project

[FsToolkitiOSApp.zip](https://github.com/xamarin/xamarin-macios/files/11816963/FsToolkitiOSApp.zip)

### Workaround

Disabling IL stripping, as described in https://github.com/xamarin/xamarin-macios/issues/14841#issue-1218995218, works.

Is there a way to _only_ disable it for this asssembly?

_Copied from original issue xamarin/xamarin-macios#18485_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.