Skip to content

crossgen2 crashes with CommandLineException when --strip-debug-info is passed via ExtraArgs on Apple mobile #126510

@PureWeen

Description

@PureWeen

Description

crossgen2 crashes with an unhandled System.CommandLine.CommandLineException when --strip-debug-info is passed on Apple mobile platforms (iOS, MacCatalyst). The System.CommandLine parser treats the next argument (--instruction-set:apple-m1) as a file path value for --strip-debug-info, then fails in AppendExpandedPaths trying to glob-expand it.

Exception

Microsoft.NET.CrossGen.targets(501,5): error :
Unhandled exception. System.CommandLine.CommandLineException: No files matching --strip-debug-info --instruction-set:apple-m1
   at System.CommandLine.Helpers.AppendExpandedPaths(Dictionary`2, String, Boolean)
   at System.CommandLine.Helpers.BuildPathDictionary(IReadOnlyList`1, Boolean)
   at System.CommandLine.Argument`1.<>c__DisplayClass8_0.<set_CustomParser>b__0(ArgumentResult, Object&)
   at System.CommandLine.Parsing.ArgumentResult.ValidateAndConvert(Boolean)
   at System.CommandLine.Parsing.CommandResult.ValidateAndAddDefaultResults(Boolean)
   at System.CommandLine.Parsing.ParseOperation.ValidateAndAddDefaultResults()
   at System.CommandLine.Parsing.ParseOperation.Parse()
   at System.CommandLine.Parsing.CommandLineParser.Parse(Command, IReadOnlyList`1, String, ParserConfiguration)
   at ILCompiler.Program.Main(String[] args)

Root Cause

dotnet/runtime#124604 added --strip-debug-info and --strip-inlining-info as boolean flags to crossgen2. dotnet/sdk#53514 passes these via PublishReadyToRunCrossgen2ExtraArgs in Microsoft.NET.CrossGen.targets for Apple mobile RIDs.

The issue appears to be that --strip-debug-info is not correctly declared as a zero-arity (boolean) option in crossgen2's System.CommandLine configuration. The parser consumes the next positional argument (--instruction-set:apple-m1) as its value and attempts to resolve it as a file path.

Reproduction

  • SDK: 11.0.100-preview.3.26202.110 (first build containing sdk#53514)
  • Target: net11.0-maccatalyst or net11.0-ios with CoreCLR (PublishReadyToRun=true)
  • Platform: Apple ARM64

Previous SDK builds (26171.106 and earlier) do not have this issue as they predate sdk#53514.

Affected CI Builds

Related PRs

/cc @kotlarmilos

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions