dotnet / linker

388 stars 126 forks source link

Runtime build on Loongarch failed #3130

Open kant2002 opened 1 year ago

kant2002 commented 1 year ago

I disable building Crossgen in the runtime repo and try to build on Loongarch and this is what issue I'm having

Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
     at Mono.Collections.Generic.Collection`1.get_Item(Int32 index)
     at ILLink.Shared.TrimAnalysis.FlowAnnotations.BuildTypeAnnotations(TypeDefinition type)
     at ILLink.Shared.TrimAnalysis.FlowAnnotations.GetAnnotations(TypeDefinition type)
     at Mono.Linker.Dataflow.DynamicallyAccessedMembersTypeHierarchy.ProcessMarkedTypeForDynamicallyAccessedMembersHierarchy(TypeDefinition type)
     at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
     at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field, DependencyInfo& reason, MessageOrigin& origin)
     at Mono.Linker.Steps.MarkStep.MarkFields(TypeDefinition type, Boolean includeStatic, DependencyInfo& reason, Boolean markBackingFieldsOnlyIfPropertyMarked)
     at Mono.Linker.Steps.MarkStep.ApplyPreserveInfo(TypeDefinition type)
     at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
     at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
     at Mono.Linker.Steps.MarkStep.ProcessMarkedPending()
     at Mono.Linker.Steps.MarkStep.Initialize()
     at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
     at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
     at Mono.Linker.Pipeline.Process(LinkContext context)
     at Mono.Linker.Driver.Run(ILogger customLogger)
     at Mono.Linker.Driver.Main(String[] args)

Any ideas?

/cc @shushanhf

kant2002 commented 1 year ago

Most likely not importantn, but command line is following

/home/loongson/runtime/.dotnet/dotnet "/home/loongson/.nuget/packages/microsoft.net.illink.tasks/7.0.100-1.22552.1/tools/net7.0/illink.dll" -a "/home/loongson/runtime/artifacts/obj/coreclr/System.Private.CoreLib/loongarch64/Debug/PreTrim/System.Private.CoreLib.dll" library
                     -out "/home/loongson/runtime/artifacts/obj/coreclr/System.Private.CoreLib/loongarch64/Debug/"
                     --warnaserror-  --ignore-link-attributes true --skip-unresolved true --trim-mode skip --action skip --action link System.Private.CoreLib -b true -x "/home/loongson/runtime/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.LibraryBuild.xml" --nowarn IL2008;IL2009;IL2012;IL2025;IL2026;IL2035;IL2050;IL2032;IL2055;IL2057;IL2058;IL2059;IL2060;IL2061;IL2062;IL2063;IL2064;IL2065;IL2066;IL2067;IL2068;IL2069;IL2070;IL2071;IL2072;IL2073;IL2074;IL2075;IL2076;IL2077;IL2078;IL2079;IL2080;IL2081;IL2082;IL2083;IL2084;IL2085;IL2086;IL2087;IL2088;IL2089;IL2090;IL2091;IL2121
vitek-karas commented 1 year ago

No immediate ideas - unfortunately the method BuildTypeAnnotations is rather large so it's hard to even guess where in the method the problem is.

Few questions:

If it does repro, could you please gather a repro archive for us?

kant2002 commented 1 year ago

questions:

illinkrepo produce issues

/home/loongson/illinkrepro/illinkrepro.csproj : error NU1101: Unable to find package Microsoft.NETCore.App.Runtime.linux-loongarch64. No packages exist with this id in source(s): nuget.org
/home/loongson/illinkrepro/illinkrepro.csproj : error NU1101: Unable to find package Microsoft.AspNetCore.App.Runtime.linux-loongarch64. No packages exist with this id in source(s): nuget.org

I do have .NET SDK in the ~/runtime/.dotnet/ folder, but seems to be I'm stuck with chicken/egg problem. That' probably question to runtime folks.

I copy DLL and XML files from the machine locally, and issue does not reproduced.

vitek-karas commented 1 year ago

The repro tool by default builds as single-file - just disable that in the project file. It should build then (no need for runtime packs).

kant2002 commented 1 year ago

repro.tar.gz Does not reproduced on win-x64 for me.

kant2002 commented 1 year ago

I did try to build this repo, and seems to be illink.dll is produced, but I have this error

/home/loongson/linker/eng/ilasm.ilproj : error NU1101: Unable to find package runtime.linux-loongarch64.microsoft.netcore.ilasm. No packages exist with this id in source(s): dotnet-eng, dotnet-public, dotnet-tools, dotnet6, dotnet7
/home/loongson/linker/eng/ilasm.ilproj : error NU1101: Unable to find package runtime.linux-loongarch64.microsoft.netcore.ildasm. No packages exist with this id in source(s): dotnet-eng, dotnet-public, dotnet-tools, dotnet6, dotnet7

Any ideas is this is important or not?

kant2002 commented 1 year ago

I run repro with following command on Loongarch hardware using illink.dll which is build there

~/runtime/.dotnet/dotnet /home/loongson/linker/artifacts/bin/Mono.Linker/Debug/net7.0/illink.dll @linker.rsp

and issue does not repro. any ideas?

kant2002 commented 1 year ago

Ooh, runtime use ancient version of illink 7.0.100-1.22552.1 which is from Preview 1, and seems to be you are fixing this after on latest bits. I did replace version on nuget cache with locally build version and issue is gone. would be curious to know what commit fixes this issue. Do you know what should I do to bump version of microsoft.net.illink.tasks on the runtime repo?

akoeplinger commented 1 year ago

The linker bump is currently in a PR in https://github.com/dotnet/runtime/pull/78020.

We're also updating to the stable 7.0.100 sdk in https://github.com/dotnet/runtime/pull/78034 separately (if I remember correctly the runtime build overrides the linker bits from the sdk)