Skip to content

Crossgen fails when compiling a trimmed Mac Catalyst project #123953

@rolfbjarne

Description

@rolfbjarne

Description

Crossgen fails to compile a trimmed Mac Catalyst project with:

error Error: Failed to load type 'System.Runtime.Intrinsics.Arm.Crc32' from assembly 'System.Private.CoreLib'

Reproduction Steps

Use .NET 11 preview 1, install the mac catalyst workload, create a mac catalyst project, compile.

This script does it:

#!/bin/bash -eu

curl -LO https://ci.dot.net/public/Sdk/11.0.100-preview.1.26081.107/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64.tar.gz
mkdir dotnet
tar -xzf *.tar.gz -C dotnet

cat >NuGet.config <<EOF
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="macios10" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-macios-b364fe57/nuget/v3/index.json" />
    <add key="dotnet11" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet11/nuget/v3/index.json" />
    <add key="macios" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-macios-64064500/nuget/v3/index.json" />
    <add key="official" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
  <disabledPackageSources>
    <clear />
  </disabledPackageSources>
</configuration>
EOF

./dotnet/dotnet workload config --update-mode manifests
./dotnet/dotnet workload install maccatalyst
mkdir catalysttest
cd catalysttest
../dotnet/dotnet new maccatalyst
../dotnet/dotnet build -p:UseMonoRuntime=false -p:MtouchLink=SdkOnly

Expected behavior

Successful build.

Actual behavior

$ dotnet build -p:UseMonoRuntime=false -p:MtouchLink=SdkOnly -bl
Restore complete (0.5s)
    info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  catalysttest net11.0-maccatalyst maccatalyst-arm64 failed with 16 error(s) (11.6s) → bin/Debug/net11.0-maccatalyst/maccatalyst-arm64/catalysttest.dll
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error Error: Failed to load type 'System.Runtime.Intrinsics.Arm.Crc32' from assembly 'System.Private.CoreLib'
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error Internal.TypeSystem.TypeSystemException+TypeLoadException: Failed to load type 'System.Runtime.Intrinsics.Arm.Crc32' from assembly 'System.Private.CoreLib'
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at Internal.TypeSystem.ThrowHelper.ThrowTypeLoadException(ExceptionStringID, String, String)
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at Internal.TypeSystem.ResolutionFailure.Throw()
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at Internal.TypeSystem.Ecma.EcmaModule.GetType(ReadOnlySpan`1, ReadOnlySpan`1, NotFoundBehavior)
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at Internal.TypeSystem.ModuleDesc.GetType(ReadOnlySpan`1, ReadOnlySpan`1, Boolean)
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at Internal.JitInterface.InstructionSetParser.<LookupPlatformIntrinsicTypes>d__1.MoveNext()
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at ILCompiler.ReadyToRunHardwareIntrinsicRootProvider.AddCompilationRoots(IRootingServiceProvider)
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at ILCompiler.Compilation..ctor(DependencyAnalyzerBase`1, NodeFactory, IEnumerable`1, ILProvider, DevirtualizationManager, IEnumerable`1, Logger, InstructionSetSupport)
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at ILCompiler.ReadyToRunCodegenCompilation..ctor(DependencyAnalyzerBase`1, NodeFactory, IEnumerable`1, ILProvider, Logger, DevirtualizationManager, IEnumerable`1, String, InstructionSetSupport, Boolean, Boolean, Boolean, Boolean, Func`2, String, Boolean, String, Int32, Boolean, Int32, ProfileDataManager, MethodLayoutAlgorithm, FileLayoutAlgorithm, Int32, Boolean, ReadyToRunContainerFormat)
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at ILCompiler.ReadyToRunCodegenCompilationBuilder.ToCompilation()
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at ILCompiler.Program.RunSingleCompilation(Dictionary`2, InstructionSetSupport, String, Dictionary`2, HashSet`1, ReadyToRunCompilerContext, Logger)
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at ILCompiler.Program.Run()
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(488,5): error    at ILCompiler.Crossgen2RootCommand.<>c__DisplayClass211_0.<.ctor>b__0(ParseResult)
    clang : error no such file or directory: 'obj/Debug/net11.0-maccatalyst/maccatalyst-arm64/R2R/catalysttest.r2r.o'
    /Users/rolf/Downloads/dotnet-sdk-11.0.100-preview.1.26081.107-osx-arm64/sdk/11.0.100-preview.1.26081.107/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(666,5): error MSB3073: The command ""/Applications/Xcode_26.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -gz=zlib -isysroot "/Applications/Xcode_26.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk" --target=arm64-apple-ios15.0-macabi -dynamiclib -Wl,-dead_strip -Wl,-install_name,"@rpath/catalysttest.r2r.dylib" obj/Debug/net11.0-maccatalyst/maccatalyst-arm64/R2R/catalysttest.r2r.o -o obj/Debug/net11.0-maccatalyst/maccatalyst-arm64/R2R/catalysttest.r2r.dylib" exited with code 1.

Build failed with 16 error(s) in 12.7s

Regression?

No.

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions