Skip to content

ci: add stage Tests - iOS+NativeAOT Skia - #23966

Closed
jonpryor wants to merge 1 commit into
feature/breakingchangesfrom
dev/jonpryor/jonp-add-iOS+NativeAOT-stage
Closed

jonpryor wants to merge 1 commit into
feature/breakingchangesfrom
dev/jonpryor/jonp-add-iOS+NativeAOT-stage

Conversation

@jonpryor

@jonpryor jonpryor commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

iOS supports Native AOT, and has since .NET 9.

It might be a good idea to actually test this on CI?

GitHub Issue: closes https://github.com/unoplatform/uno-private/issues/2279

PR Type:

🏗️ Build or CI related changes

What changed? 🚀

PR Checklist ✅

@jonpryor
jonpryor requested a lite review from Copilot August 4, 2026 19:28
@github-actions github-actions Bot added the area/build Categorizes an issue or PR as relevant to build infrastructure label Aug 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Azure DevOps CI stage to build and run Uno Skia iOS runtime tests with NativeAOT enabled, using a dedicated build/test template pair and a small enhancement to the existing iOS Skia build script to toggle AOT via an environment variable.

Changes:

  • Extend skia-ios-uitest-build.sh to optionally pass -p:SkiaPublishAot=true when NAOT is set.
  • Add a new CI stage Tests - iOS+NativeAOT Skia wiring new build + test templates.
  • Introduce new Azure DevOps templates for iOS NativeAOT Skia build and runtime-test execution.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
build/test-scripts/skia-ios-uitest-build.sh Adds an NAOT-controlled MSBuild property to enable NativeAOT for iOS Skia builds.
build/ci/tests/.azure-devops-tests-skia-stages.yml Adds a new iOS NativeAOT Skia stage that runs the new build and test templates.
build/ci/tests/.azure-devops-tests-ios-nativeaot-skia.yml New template that runs iOS Skia runtime tests for NativeAOT build output.
build/ci/tests/.azure-devops-tests-ios-nativeaot-skia-build.yml New template that builds and publishes the iOS SamplesApp artifact for NativeAOT runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-add-iOS+NativeAOT-stage branch from d6f1fc1 to bf19192 Compare August 4, 2026 19:34
@unodevops

Copy link
Copy Markdown
Contributor

@jonpryor

jonpryor commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Something isn't right; needs more investigation. The SamplesApp size both with and without Native AOT are the same size, and the Native AOT version has a bunch of .dll files in the .app. Neither of these are what I would expect to see.

The skia-ios-netcoremobile-sampleapp.binlog does show that -p:SkiaPublishAot=true was used, so it's something less obvious going "wrong".

@jonpryor

jonpryor commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Earlier I wrote:

Something isn't right; needs more investigation.

The problem is that Native AOT codegen/etc. only occurs as part of dotnet publish, not dotnet build, and skia-ios-uitest-build.sh is only using dotnet build.

OK, so why don't we update it to use dotnet publish?

Because we're producing a simulator iossimulator-x64 build, because we run the test app on the simulator.

OK, so why can't we dotnet publish for the simulator? Because that doesn't work:

% dotnet new ios
% dotnet publish -bl -r iossimulator-arm64  -p:PublishAot=true
Restore complete (1.4s)
  net11-ios net11.0-ios iossimulator-arm64 failed with 1 error(s) (0.0s)
    …/Xamarin.Shared.Sdk.Publish.targets(14,3): error A runtime identifier for a device architecture must be specified in order to publish this project. 'iossimulator-arm64' is a simulator architecture.

which suggests that there is no way to test Native AOT builds on CI when using the simulator. (Unless someone knows of a workaround…)

@jonpryor
jonpryor marked this pull request as draft August 6, 2026 10:42
@jonpryor

jonpryor commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Yesterday, I wrote:

(Unless someone knows of a workaround…)

Good news! Rolf has a workaround:

dotnet build -p:PublishAot=true -p:_IsPublishing=true …

Bad news: it doesn't work locally. Update skia-ios-uitest-build.sh:

diff --git a/build/test-scripts/skia-ios-uitest-build.sh b/build/test-scripts/skia-ios-uitest-build.sh
old mode 100644
new mode 100755
index 5260619151..1b10da386c
--- a/build/test-scripts/skia-ios-uitest-build.sh
+++ b/build/test-scripts/skia-ios-uitest-build.sh
@@ -6,4 +6,8 @@ _TFM="${TFM:=net10.0-ios}"
 
 cd $BUILD_SOURCESDIRECTORY/src/SamplesApp/SamplesApp.Skia.netcoremobile
 
-dotnet build -f "$_TFM" -c Release "-p:UnoTargetFrameworkOverride=$_TFM" -p:UNO_DISABLE_ANALYZERS_IN_SAMPLES=true /bl:$BUILD_ARTIFACTSTAGINGDIRECTORY/skia-ios-netcoremobile-sampleapp.binlog
+if [ "${NAOT:=}" = "1" ]; then
+    dotnet build -f "$_TFM" -c Release "-p:UnoTargetFrameworkOverride=$_TFM" -p:UNO_DISABLE_ANALYZERS_IN_SAMPLES=true /bl:$BUILD_ARTIFACTSTAGINGDIRECTORY/skia-ios-nativeaot-netcoremobile-sampleapp.binlog -p:SkiaPublishAot=true -p:_IsPublishing=true
+else
+    dotnet build -f "$_TFM" -c Release "-p:UnoTargetFrameworkOverride=$_TFM" -p:UNO_DISABLE_ANALYZERS_IN_SAMPLES=true /bl:$BUILD_ARTIFACTSTAGINGDIRECTORY/skia-ios-netcoremobile-sampleapp.binlog
+fi

Run it:

TFM=net11.0-ios \
NAOT=1 \
BUILD_SOURCESDIRECTORY=`pwd` \
BUILD_ARTIFACTSTAGINGDIRECTORY=`pwd`/artifacts \
sh build/test-scripts/skia-ios-uitest-build.sh

…and it fails:

    …/unoplatform/uno/src/SourceGenerators/Uno.UI.Tasks/Content/Uno.UI.Tasks.targets(487,3): warning Failed to resolve assembly `JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325`: Failed to resolve assembly: 'JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325'
    EXEC : error Sequence point value is out of range.
    $HOME/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""$HOME/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/tools/ilc" @"obj/Release/net11.0-ios/ios-arm64/native/SamplesApp.ilc.rsp"" exited with code 1.

Manually run the failing command, and we get the full error:

% (cd src/SamplesApp/SamplesApp.Skia.netcoremobile; "$HOME/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/tools/ilc" @"obj/Release/net11.0-ios/ios-arm64/native/SamplesApp.ilc.rsp" )
Error: Sequence point value is out of range.
System.BadImageFormatException: Sequence point value is out of range.
   at System.Reflection.Throw.SequencePointValueOutOfRange() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Throw.cs:line 239
   at System.Reflection.Metadata.SequencePointCollection.Enumerator.MoveNext() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePointCollection.cs:line 86
   at Internal.TypeSystem.Ecma.PortablePdbSymbolReader.<GetSequencePointsForMethod>d__10.MoveNext() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs:line 147
   at ILCompiler.Logging.MessageOrigin..ctor(MethodIL, Int32) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs:line 65
   at ILCompiler.Dataflow.ReflectionMethodBodyScanner.HandleGetField(MethodIL, Int32, FieldDesc) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 230
   at ILCompiler.Dataflow.MethodBodyScanner.ScanStfld(MethodIL, Int32, ILOpcode, FieldDesc, Stack`1, Nullable`1[], InterproceduralState&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 1151
   at ILCompiler.Dataflow.MethodBodyScanner.Scan(MethodIL, InterproceduralState&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 673
   at ILCompiler.Dataflow.MethodBodyScanner.InterproceduralScan(MethodIL) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 310
   at ILCompiler.Dataflow.ReflectionMethodBodyScanner.InterproceduralScan(MethodIL) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 117
   at ILCompiler.Dataflow.ReflectionMethodBodyScanner.ScanAndProcessReturnValue(NodeFactory, FlowAnnotations, Logger, MethodIL, List`1&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 137
   at ILCompiler.DependencyAnalysis.DataflowAnalyzedMethodNode.GetStaticDependencies(NodeFactory) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DataflowAnalyzedMethodNode.cs:line 33
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 183
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 260
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 309
   at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 157
   at ILCompiler.Program.<Run>g__RunScanner|4_0(Program.<>c__DisplayClass4_0&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 525
   at ILCompiler.Program.Run() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 594
   at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass263_0.<.ctor>b__0(ParseResult) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs:line 340

Which brings us to another good news/bad news: dotnet publish also fails, for the same reason:

% dotnet publish -bl -f net11.0-ios -p:UnoTargetFrameworkOverride=net11.0-ios -p:UNO_DISABLE_ANALYZERS_IN_SAMPLES=true -p:SkiaPublishAot=true src/SamplesApp/SamplesApp.Skia.netcoremobile/*.csproj
…
  SamplesApp.Skia.netcoremobile net11.0-ios ios-arm64 failed with 2 error(s) and 3 warning(s) (117.4s) → src/SamplesApp/SamplesApp.Skia.netcoremobile/bin/Release/net11.0-ios/ios-arm64/SamplesApp.dll
    EXEC : error Sequence point value is out of range.
    $HOME/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""$HOME/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/tools/ilc" @"obj/Release/net11.0-ios/ios-arm64/native/SamplesApp.ilc.rsp"" exited with code 1.
…

which is rather concerning…

Even worse, it also fails on uno/master while using .NET 10!

(This is why having such a test stage would have been handy earlier… I believe this worked at one point in time! A year ago…?)

iOS supports Native AOT, and has since .NET 9.

It might be a good idea to actually *test* this on CI?
@jonpryor
jonpryor force-pushed the dev/jonpryor/jonp-add-iOS+NativeAOT-stage branch from bf19192 to 9037eb9 Compare August 6, 2026 19:20
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 226231 has failed on Uno.UI - CI.

@jonpryor

jonpryor commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Yesterday, I wrote:

which is rather concerning…

The "good" news is that this isn't a new bug, it isn't a recent regression.

The "bad" news is that the bug -- or at least something that looks identical -- has been open since 2025: dotnet/maui#37782

dotnet/maui#37782 started life as a MAUI issue, moved to Roslyn, and is still there… but based on this comment, I believe this is actually an illink bug, because illink rewrites .pdb files.

The bug is that illink emits corrupt .pdb files in certain situations, and when ilc processes that corrupt .pdb things fail.

The workaround sounds like it should be to not use debug symbols. That "works", in that we no longer error out in ilc.

Instead, it crashes while attempting to link!

    $HOME/Downloads/dotnet-sdk-11.0.100-preview.6.26359.118/packs/Microsoft.iOS.Sdk.net10.0_26.5/26.5.10301/targets/Xamarin.Shared.Sdk.targets(2064,3): error 
      clang++ exited with code 1:
      0  0x100addc90  __assert_rtn + 252
      1  0x1009abad0  ld::Fixup::setAddend(long long, std::__1::function<unsigned int (long long)>) + 356
      2  0x100a13d4c  ld::DynamicAtom::addFixup(ld::file_format::FixupKind, unsigned int, ld::Atom const*, ld::Atom const*, long long) + 364
      3  0x1009b9fd4  ld::FixupFromRelocs::diff(relocation_info const&, relocation_info const&, long long) const + 252
      4  0x1009d2f70  ld::InputFiles::SliceParser::parseObjectFile(mach_o::UnsafeHeader const*) const + 5860
      5  0x1009df0a4  ld::InputFiles::SliceParser::parse() const + 640
      6  0x1009e1f64  ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_0::operator()(unsigned long, ld::FileInfo const&) const + 532
      7  0x18c7dd4c8  _dispatch_client_callout2 + 16
      8  0x18c7d81a4  _dispatch_apply_invoke3 + 336
      9  0x18c7dd4b0  _dispatch_client_callout + 16
      10  0x18c7c6630  _dispatch_once_callout + 32
      11  0x18c7d72f4  _dispatch_apply_invoke + 248
      12  0x18c7dd4b0  _dispatch_client_callout + 16
      13  0x18c7fad6c  _dispatch_channel_invoke.cold.9 + 28
      14  0x18c7d5adc  _dispatch_root_queue_drain + 708
      15  0x18c7d6120  _dispatch_worker_thread2 + 184
      16  0x18c97be84  _pthread_wqthread + 232
      ld snapshot written at /tmp/SamplesApp-2026-08-07-095517.ld-snapshot
      ld: Assertion failed: (_addend == uniqueIndex && "too many large addends"), function setAddend, file Fixup.cpp, line 1510.
      clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Ever get the feeling that this is cursed?

@jonpryor

jonpryor commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Meanwhile, through some interaction with Claude, I think it's not just illink, it's also Roslyn. Kinda.

Claude cooked this "pdb verification" app:

verify-pdb-sequence-points
#!/usr/bin/env -S dotnet --

#:package Mono.Options@6.12.0.148

using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;

using Mono.Options;

var Name = Environment.GetCommandLineArgs()[0];
int verbosity = 0;
var show_help = false;
var options = new OptionSet {
    $"Usage: {Name} [-v] <PDB-FILES>",
    "",
    "Verify the sequence points within `.pdb` files.",
    "",
    "Options:",
    {
        "v|verbose:",
        "Increase logging verbosity or set to {VALUE}.",
        (int? v) => verbosity = v ?? (verbosity + 1)
    },
    { "help", "Show this message and exit.", v => show_help = v != null },
};
List<string> pdb_files;
try {
    pdb_files = options.Parse(args);
}
catch (Exception e) {
    Console.Error.WriteLine($"{Name}: {e.Message}");
    if (verbosity > 0)
    {
        Console.Error.WriteLine(e);
    }
    return 1;
}

if (pdb_files.Count == 0 || show_help)
{
    options.WriteOptionDescriptions(Console.Out);
    return 0;
}

if (args.Length == 0)
{
    Console.Error.WriteLine("Usage: verify-pdb-sequence-points <path-to-pdb> [more paths...]");
    return 1;
}

int totalBad = 0;
foreach (var pdbPath in args)
{
    totalBad += VerifyPdb(pdbPath);
}
return totalBad > 0 ? 1 : 0;

int VerifyPdb(string pdbPath)
{
    Console.WriteLine($"{pdbPath}");

    byte[] pdbBytes;
    try
    {
        pdbBytes = File.ReadAllBytes(pdbPath);
    }
    catch (Exception ex)
    {
        Console.WriteLine($"  ERROR reading file: {ex.Message}");
        return 1;
    }

    using MetadataReaderProvider provider = MetadataReaderProvider.FromPortablePdbStream(new MemoryStream(pdbBytes));
    MetadataReader pdbReader = provider.GetMetadataReader();

    // Optional: a sibling .dll with matching row numbers gives us type/method names.
    var dllPath = Path.ChangeExtension(pdbPath, ".dll");
    Dictionary<int, string>? namesByRow = File.Exists(dllPath) ? TryLoadNames(dllPath) : null;

    int methodCount = pdbReader.GetTableRowCount(TableIndex.MethodDebugInformation);
    int badCount = 0;

    for (int row = 1; row <= methodCount; row++)
    {
        var handle = MetadataTokens.MethodDebugInformationHandle(row);
        MethodDebugInformation info;
        try
        {
            info = pdbReader.GetMethodDebugInformation(handle);
        }
        catch (Exception ex)
        {
            badCount++;
            Console.WriteLine($"  [row {row}] {Describe(row, namesByRow)}: FAILED to read debug info header: {ex.GetType().Name}: {ex.Message}");
            continue;
        }

        if (info.SequencePointsBlob.IsNil)
        {
            continue;
        }

        int decoded = 0;
        SequencePoint last = default;
        bool haveLast = false;
        try
        {
            foreach (var sp in info.GetSequencePoints())
            {
                last = sp;
                haveLast = true;
                decoded++;
            }
        }
        catch (Exception ex)
        {
            badCount++;
            string context = haveLast
                ? $"after {decoded} good sequence point(s); last good IL=0x{last.Offset:X} line={last.StartLine}"
                : "on the very first sequence point";
            Console.WriteLine($"  [row {row}] {Describe(row, namesByRow)}: {ex.GetType().Name}: {ex.Message} ({context})");
            if (verbosity > 0)
            {
                var reader = new StringReader(ex.ToString());
                string? line;
                while ((line = reader.ReadLine()) != null)
                {
                    Console.WriteLine($"    {line}");
                }
            }
        }
    }

    if (badCount == 0)
    {
        Console.WriteLine($"  OK - {methodCount} method(s) checked, all sequence points decoded cleanly.");
    }
    else
    {
        Console.WriteLine($"  {badCount} of {methodCount} method(s) have corrupt sequence points.");
    }

    return badCount;
}

static string Describe(int row, Dictionary<int, string>? namesByRow) =>
    namesByRow is not null && namesByRow.TryGetValue(row, out var name) ? name : "(name unavailable - no matching .dll found)";

static Dictionary<int, string>? TryLoadNames(string dllPath)
{
    try
    {
        using var dllStream = File.OpenRead(dllPath);
        using var peReader = new PEReader(dllStream);
        var mdReader = peReader.GetMetadataReader();

        var result = new Dictionary<int, string>();
        foreach (var methodHandle in mdReader.MethodDefinitions)
        {
            var methodDef = mdReader.GetMethodDefinition(methodHandle);
            var typeDef = mdReader.GetTypeDefinition(methodDef.GetDeclaringType());
            var typeName = mdReader.GetString(typeDef.Name);
            var methodName = mdReader.GetString(methodDef.Name);
            var debugHandle = methodHandle.ToDebugInformationHandle();
            var row = MetadataTokens.GetRowNumber(debugHandle);
            result[row] = $"{typeName}::{methodName}";
        }
        return result;
    }
    catch
    {
        return null;
    }
}

Here's something interesting. Take what I think is the original .pdb file, and it has problems:

% dotnet run --project …/verify-pdb-sequence-points/*.csproj src/SamplesApp/SamplesApp.Skia/bin/Release/net10.0/SamplesApp.Skia.pdb
  [row 17890] NavigationViewInfoBadgeTestPage::.ctor: BadImageFormatException: Invalid compressed integer. (after 384 good sequence point(s); last good IL=0x11F1 line=21263)
  [row 24182] ScrollViewDynamicPage::.ctor: BadImageFormatException: Invalid compressed integer. (after 156 good sequence point(s); last good IL=0x6AC line=8956)
  [row 52778] TeachingTipPage::.ctor: BadImageFormatException: Invalid compressed integer. (after 152 good sequence point(s); last good IL=0x685 line=8280)
  [row 56413] ItemsViewSummaryPage::.ctor: BadImageFormatException: Invalid compressed integer. (after 339 good sequence point(s); last good IL=0xE99 line=18531)
  4 of 159897 method(s) have corrupt sequence points.

Look at the linked version, and:

% dotnet run --project …/verify-pdb-sequence-points/*.csproj  src/SamplesApp/SamplesApp.Skia.netcoremobile/obj/Release/net10.0-ios/ios-arm64/linked/SamplesApp.Skia.pdb
  [row 18209] NavigationViewInfoBadgeTestPage::.ctor: BadImageFormatException: Sequence point value is out of range. (after 384 good sequence point(s); last good IL=0x11F1 line=21263)
  [row 24501] ScrollViewDynamicPage::.ctor: BadImageFormatException: Sequence point value is out of range. (after 156 good sequence point(s); last good IL=0x6AC line=8956)
  [row 53919] TeachingTipPage::.ctor: BadImageFormatException: Sequence point value is out of range. (after 152 good sequence point(s); last good IL=0x685 line=8280)
  [row 57554] ItemsViewSummaryPage::.ctor: BadImageFormatException: Sequence point value is out of range. (after 339 good sequence point(s); last good IL=0xE99 line=18531)
  4 of 162556 method(s) have corrupt sequence points.

What I suspect is that there is a Roslyn bug which produces the Invalid compressed integer, and when illink encountered this it becomes an Sequence point value is out of range.

@jonpryor

Copy link
Copy Markdown
Contributor Author

Last week, I mentioned a crash in clang++ when trying to build SamplesApp for iOS+Native AOT:

      clang++: error: linker command failed with exit code 1 (use -v to see invocation)

This has been filed as: dotnet/macios#26428

jonpryor added a commit that referenced this pull request Aug 13, 2026
Fixes: #24036

Context: #23966
Context: dotnet/macios#26428
Context: dotnet/cecil#504
Context: jbevain/cecil#982
Context: jbevain/cecil@0.11.4...0.11.6
Context: jbevain/cecil@0.10.1...0.11.6

In The Beginning™ was a simple idea: why don't we have an
iOS+Native AOT test stage?  Thus began #23966, which promptly fell
over, caught on fire, and sank into the swamp.

There are two issues with #23966:

 1. CI was unhappy; it errors out with

        …/Xamarin.Shared.targets(2073,3): error : No valid iOS code signing keys found in keychain. You need to request a codesigning certificate from https://developer.apple.com.

    Not sure what's happening there.  It doesn't happen locally…

 2. It couldn't build locally either!

The initial attempt to build locally would fail in `ilc`:

	# note: using changes from #23966
	% TFM=net11.0-ios \
	  NAOT=1 \
	  BUILD_SOURCESDIRECTORY=`pwd` \
	  BUILD_ARTIFACTSTAGINGDIRECTORY=`pwd`/artifacts \
	  sh build/test-scripts/skia-ios-uitest-build.sh
	…
	    …/unoplatform/uno/src/SourceGenerators/Uno.UI.Tasks/Content/Uno.UI.Tasks.targets(487,3): warning Failed to resolve assembly `JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325`: Failed to resolve assembly: 'JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325'
	    EXEC : error Sequence point value is out of range.
	    $HOME/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""$HOME/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/tools/ilc" @"obj/Release/net11.0-ios/ios-arm64/native/SamplesApp.ilc.rsp"" exited with code 1.

Thus began a fair bit of investigation, some of which is mentioned
in #24036 and dotnet/cecil#504.

What happened was a "failure cascade":

 1. The `<Csc/>` task produced a `.pdb` file.

 2. Uno's `<EmbeddedResourceInjectorTask_v0/>` task would use Cecil
    to process the assembly and `.pdb` file from (1).
    Uno was using, at most, Mono.Cecil 0.11.4, which had a bug around
    the encoding of "compressed" integers within `.pdb` files.

    (This is later fixed in jbevain/cecil#982, and released as part
    of Mono.Cecil 0.11.6.)

    The updated `.pdb` file would contain "Invalid compressed integer"
    values.

 3. Later, `illink` would run, which has it's own separate copy of
    Mono.Cecil -- from dotnet/cecil -- which would *also* update the
    `.pdb` files from (2).  When `illink` ran, any "Invalid compressed
    integer" values would be further corrupted.

 4. Later still, when `ilc` runs, it would process the `.pdb` files
    produced by (3), and at this point instead of "silently corrupting"
    data, it would error out entirely:

        Error: Sequence point value is out of range.
        System.BadImageFormatException: Sequence point value is out of range.
           at System.Reflection.Throw.SequencePointValueOutOfRange() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Throw.cs:line 239
           at System.Reflection.Metadata.SequencePointCollection.Enumerator.MoveNext() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePointCollection.cs:line 86
           at Internal.TypeSystem.Ecma.PortablePdbSymbolReader.<GetSequencePointsForMethod>d__10.MoveNext() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs:line 147
           at ILCompiler.Logging.MessageOrigin..ctor(MethodIL, Int32) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs:line 65

(Failure cascades are fun!)

*Part* of the fix here is to update Uno to use Mono.Cecil 0.11.6,
which contains the fix for reading and writing "compressed" integers
in `.pdb` files.  That is done here.

Updating Cecil will *not* fix #23966, but is a partial prerequisite.
A full fix will require dotnet/cecil#504 to be merged and released,
(currently merged), `illink` updated to use dotnet/cecil#504, and
*then* there's dotnet/macios#26428, in which `clang++` crashes when
trying to link everything even if we get past the whole `.pdb` mess
(which reportedly is fixed in the not-yet-released .NET 11 RC1).

(Aside: the `.pdb` mess can be avoided by NOT USING `.pdb` FILES,
e.g. buil with `-p:DebugType=none`.  However, who wants to do that?)

…which still leaves the original "how do we get this building on CI"
question…

Baby steps!
ramezgerges pushed a commit to ramezgerges/uno that referenced this pull request Nov 2, 2026
Fixes: unoplatform#24036

Context: unoplatform#23966
Context: dotnet/macios#26428
Context: dotnet/cecil#504
Context: jbevain/cecil#982
Context: jbevain/cecil@0.11.4...0.11.6
Context: jbevain/cecil@0.10.1...0.11.6

In The Beginning™ was a simple idea: why don't we have an
iOS+Native AOT test stage?  Thus began unoplatform#23966, which promptly fell
over, caught on fire, and sank into the swamp.

There are two issues with unoplatform#23966:

 1. CI was unhappy; it errors out with

        …/Xamarin.Shared.targets(2073,3): error : No valid iOS code signing keys found in keychain. You need to request a codesigning certificate from https://developer.apple.com.

    Not sure what's happening there.  It doesn't happen locally…

 2. It couldn't build locally either!

The initial attempt to build locally would fail in `ilc`:

	# note: using changes from unoplatform#23966
	% TFM=net11.0-ios \
	  NAOT=1 \
	  BUILD_SOURCESDIRECTORY=`pwd` \
	  BUILD_ARTIFACTSTAGINGDIRECTORY=`pwd`/artifacts \
	  sh build/test-scripts/skia-ios-uitest-build.sh
	…
	    …/unoplatform/uno/src/SourceGenerators/Uno.UI.Tasks/Content/Uno.UI.Tasks.targets(487,3): warning Failed to resolve assembly `JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325`: Failed to resolve assembly: 'JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325'
	    EXEC : error Sequence point value is out of range.
	    $HOME/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""$HOME/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/tools/ilc" @"obj/Release/net11.0-ios/ios-arm64/native/SamplesApp.ilc.rsp"" exited with code 1.

Thus began a fair bit of investigation, some of which is mentioned
in unoplatform#24036 and dotnet/cecil#504.

What happened was a "failure cascade":

 1. The `<Csc/>` task produced a `.pdb` file.

 2. Uno's `<EmbeddedResourceInjectorTask_v0/>` task would use Cecil
    to process the assembly and `.pdb` file from (1).
    Uno was using, at most, Mono.Cecil 0.11.4, which had a bug around
    the encoding of "compressed" integers within `.pdb` files.

    (This is later fixed in jbevain/cecil#982, and released as part
    of Mono.Cecil 0.11.6.)

    The updated `.pdb` file would contain "Invalid compressed integer"
    values.

 3. Later, `illink` would run, which has it's own separate copy of
    Mono.Cecil -- from dotnet/cecil -- which would *also* update the
    `.pdb` files from (2).  When `illink` ran, any "Invalid compressed
    integer" values would be further corrupted.

 4. Later still, when `ilc` runs, it would process the `.pdb` files
    produced by (3), and at this point instead of "silently corrupting"
    data, it would error out entirely:

        Error: Sequence point value is out of range.
        System.BadImageFormatException: Sequence point value is out of range.
           at System.Reflection.Throw.SequencePointValueOutOfRange() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Throw.cs:line 239
           at System.Reflection.Metadata.SequencePointCollection.Enumerator.MoveNext() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePointCollection.cs:line 86
           at Internal.TypeSystem.Ecma.PortablePdbSymbolReader.<GetSequencePointsForMethod>d__10.MoveNext() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs:line 147
           at ILCompiler.Logging.MessageOrigin..ctor(MethodIL, Int32) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs:line 65

(Failure cascades are fun!)

*Part* of the fix here is to update Uno to use Mono.Cecil 0.11.6,
which contains the fix for reading and writing "compressed" integers
in `.pdb` files.  That is done here.

Updating Cecil will *not* fix unoplatform#23966, but is a partial prerequisite.
A full fix will require dotnet/cecil#504 to be merged and released,
(currently merged), `illink` updated to use dotnet/cecil#504, and
*then* there's dotnet/macios#26428, in which `clang++` crashes when
trying to link everything even if we get past the whole `.pdb` mess
(which reportedly is fixed in the not-yet-released .NET 11 RC1).

(Aside: the `.pdb` mess can be avoided by NOT USING `.pdb` FILES,
e.g. buil with `-p:DebugType=none`.  However, who wants to do that?)

…which still leaves the original "how do we get this building on CI"
question…

Baby steps!

(cherry picked from commit 947bda0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants