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
Description
crossgen2 crashes with an unhandled
System.CommandLine.CommandLineExceptionwhen--strip-debug-infois passed on Apple mobile platforms (iOS, MacCatalyst). TheSystem.CommandLineparser treats the next argument (--instruction-set:apple-m1) as a file path value for--strip-debug-info, then fails inAppendExpandedPathstrying to glob-expand it.Exception
Root Cause
dotnet/runtime#124604 added
--strip-debug-infoand--strip-inlining-infoas boolean flags to crossgen2. dotnet/sdk#53514 passes these viaPublishReadyToRunCrossgen2ExtraArgsinMicrosoft.NET.CrossGen.targetsfor Apple mobile RIDs.The issue appears to be that
--strip-debug-infois not correctly declared as a zero-arity (boolean) option in crossgen2'sSystem.CommandLineconfiguration. The parser consumes the next positional argument (--instruction-set:apple-m1) as its value and attempts to resolve it as a file path.Reproduction
11.0.100-preview.3.26202.110(first build containing sdk#53514)net11.0-maccatalystornet11.0-ioswith CoreCLR (PublishReadyToRun=true)Previous SDK builds (
26171.106and earlier) do not have this issue as they predate sdk#53514.Affected CI Builds
maui-pr-devicetests, "Build Device Tests (CoreCLR)" stepRelated PRs
--strip-debug-infoand--strip-inlining-infoto crossgen2/cc @kotlarmilos