dotnet / source-build

A repository to track efforts to produce a source tarball of the .NET Core SDK and all its components
MIT License
265 stars 132 forks source link

9.0-rc.1 fails to build in `runtime` with `MemoryMarshal` exception #4607

Closed corngood closed 1 month ago

corngood commented 1 month ago

Describe the Bug

      crossgen2_publish -> /tmp/tmp.OgltX7IYEl/dotnet-9.0.0-rc.1.24431.7/src/runtime/artifacts/bin/crossgen2_publish/x64/Release/crossgen2.dll
      Generating native code
    EXEC : error : One or more errors occurred. (Code generation failed for method 'bool.ToString()') [/tmp/tmp.OgltX7IYEl/dotnet-9.0.0-rc.1.24431.7/src/runtime/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj]
      System.AggregateException: One or more errors occurred. (Code generation failed for method 'bool.ToString()')
       ---> ILCompiler.CodeGenerationFailedException: Code generation failed for method 'bool.ToString()'
       ---> System.TypeLoadException: Could not load type 'System.Runtime.InteropServices.MemoryMarshal' from assembly 'System.Runtime, Version=9.0.0.0, Culture=neutral'.
         at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowTypeLoadException(ExceptionStringID, String, String) + 0xe
         at ILCompiler.TypePreinit.StringInstance.ConstructStringInstance(TypeDesc, ReadOnlySpan`1) + 0x16
         at ILCompiler.TypePreinit.TryScanMethod(MethodIL, TypePreinit.Value[], Stack`1, Int32&, TypePreinit.Value&) + 0x33df
         at ILCompiler.TypePreinit.ScanType(CompilationModuleGroup, ILProvider, TypePreinit.TypePreinitializationPolicy, ReadOnlyFieldPolicy, FlowAnnotations, MetadataType) + 0x10c
         at Internal.TypeSystem.LockFreeReaderHashtable`2.CreateValueAndEnsureValueIsInTable(TKey) + 0x14
         at ILCompiler.PreinitializationManager.IsPreinitialized(MetadataType) + 0x8b
         at ILCompiler.PreinitializationManager.HasLazyStaticConstructor(TypeDesc) + 0x5d
         at Internal.IL.ILImporter.Import() + 0x53
         at ILCompiler.ILScanner.CompileSingleMethod(ScannedMethodNode) + 0x56
         --- End of inner exception stack trace ---
         at ILCompiler.ILScanner.CompileSingleMethod(ScannedMethodNode) + 0x20e
         at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker&, Int64, Boolean&) + 0x3a1
      --- End of stack trace from previous location ---
         at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker&, Int64, Boolean&) + 0x461
         at System.Threading.Tasks.TaskReplicator.Replica.Execute() + 0x8d
         --- End of inner exception stack trace ---
         at System.Threading.Tasks.TaskReplicator.Run[TState](TaskReplicator.ReplicatableUserAction`1, ParallelOptions, Boolean) + 0x2bf
         at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt, TInt, ParallelOptions, Action`1, Action`2, Func`4, Func`1, Action`1) + 0x216
      --- End of stack trace from previous location ---
         at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection, CancellationToken, Exception) + 0x31
         at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt, TInt, ParallelOptions, Action`1, Action`2, Func`4, Func`1, Action`1) + 0x42e
         at ILCompiler.ILScanner.CompileMultiThreaded(List`1) + 0x20d
         at ILCompiler.ILScanner.ComputeDependencyNodeDependencies(List`1) + 0x170
         at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() + 0x14e
         at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() + 0x19
         at ILCompiler.Program.<Run>g__RunScanner|4_0(Program.<>c__DisplayClass4_0&) + 0x21f
         at ILCompiler.Program.Run() + 0x29ba
         at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass240_0.<.ctor>b__0(ParseResult) + 0x31e
    /tmp/tmp.OgltX7IYEl/dotnet-9.0.0-rc.1.24431.7/src/runtime/artifacts/bin/coreclr/linux.x64.Release/build/Microsoft.NETCore.Native.targets(317,5): error MSB3073: The command ""/tmp/tmp.OgltX7IYEl/dotnet-9.0.0-rc.1.24431.7/src/runtime/artifacts/bin/coreclr/linux.x64.Release/ilc-published/ilc" @"/tmp/tmp.OgltX7IYEl/dotnet-9.0.0-rc.1.24431.7/src/runtime/artifacts/obj/coreclr/crossgen2_publish/linux.x64.Release/native/crossgen2.ilc.rsp"" exited with code 1. [/tmp/tmp.OgltX7IYEl/dotnet-9.0.0-rc.1.24431.7/src/runtime/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj]

Steps to Reproduce

I'm trying to do an online build bootstrapped with the binary 9.0-rc.1 SDK from nuget.org. This is the way we usually do 'stage0' builds in nixpkgs.

Other Information

I see the same exception mentioned recently in a few places, e.g. https://github.com/dotnet/sdk/pull/43070#issuecomment-2320603051 . However, these don't seem to be happening in the same place.

dotnet-issue-labeler[bot] commented 1 month ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-issue-labeler[bot] commented 1 month ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

corngood commented 1 month ago

This turned out to be caused by mixing sdk rc.1 with source-built-artifacts preview.7. ILCompiler from the latter is not compatible with the former.

This is the first time we've hit an incompatibility like this in nixpkgs. What I'm going to try doing for now is to pull in source-built-artifacts from rc.1. Building with sdk preview.7 is also presumably an option, but would require us to package multiple versions of the binary sdk.

MichaelSimons commented 1 month ago

FWIW we only test matching sdk + artifacts.