Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOT compile aot-instances.dll, the AOT compiler exited with code 139. #109966

Open
rolfbjarne opened this issue Nov 19, 2024 · 32 comments
Open

AOT compile aot-instances.dll, the AOT compiler exited with code 139. #109966

rolfbjarne opened this issue Nov 19, 2024 · 32 comments
Assignees

Comments

@rolfbjarne
Copy link
Member

From @bwinklesky on Fri, 15 Nov 2024 19:19:59 GMT

Apple platform

iOS

Framework version

net9.0-*

Affected platform version

.NET 9

Description

After upgrading to Xcode 16 and upgrading source code to version 9 we are getting this error.

IL stripping assemblies
12:01:24 Tool /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).
12:01:24
12:01:24 /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net9.0_18.0/18.0.9617/targets/Xamarin.Shared.Sdk.targets(1277,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.

Steps to Reproduce

dotnet publish release

Did you find any workaround?

No response

Build logs

No response

Copied from original issue xamarin/xamarin-macios#21634

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Fri, 15 Nov 2024 19:29:01 GMT

Could you get an MSBuild binlog and attach it here? Thanks!

@rolfbjarne
Copy link
Member Author

From @bwinklesky on Fri, 15 Nov 2024 19:52:13 GMT

msbuild.binlog.zip

Let me know if this doesn't work

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Mon, 18 Nov 2024 08:13:11 GMT

Unfortunately that didn't give me many clues.

Is there any chance we could get access to your project to compile it ourselves?

@rolfbjarne
Copy link
Member Author

From @bwinklesky on Mon, 18 Nov 2024 19:06:13 GMT

Unfortunately that didn't give me many clues.

Is there any chance we could get access to your project to compile it ourselves?

@rolfbjarne I created a respository and gave you access. WasatchBackcountryAlliance is the app to build.

I ask that you destroy the source code after you've diagnosed the issue.

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Tue, 19 Nov 2024 12:28:31 GMT

Unfortunately that didn't give me many clues.
Is there any chance we could get access to your project to compile it ourselves?

@rolfbjarne I created a respository and gave you access. WasatchBackcountryAlliance is the app to build.

I ask that you destroy the source code after you've diagnosed the issue.

I confirm I can reproduce the problem; I'll see if I can figure out where to route the bug and create a smaller test project that doesn't involve any of your code.

@rolfbjarne
Copy link
Member Author

From @formerlymisterhenson on Tue, 19 Nov 2024 13:27:19 GMT

Well this error occured in my project as well, I went with:

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0-ios|AnyCPU'">
    <EnableSGenConc>True</EnableSGenConc>
    <MtouchInterpreter>-all,System.Private.Windows.Core</MtouchInterpreter>
</PropertyGroup>

@rolfbjarne
Copy link
Member Author

From @rolfbjarne on Tue, 19 Nov 2024 16:17:20 GMT

Smaller test case: aot-instances-1003365.zip

To repro: unzip & run ./bug.sh

Binlog: msbuild.binlog.zip

Crash report (mono-aot-cross): crash.txt

@bwinklesky
Copy link

From @rolfbjarne on Tue, 19 Nov 2024 12:28:31 GMT

Unfortunately that didn't give me many clues.
Is there any chance we could get access to your project to compile it ourselves?

@rolfbjarne I created a respository and gave you access. WasatchBackcountryAlliance is the app to build.
I ask that you destroy the source code after you've diagnosed the issue.

I confirm I can reproduce the problem; I'll see if I can figure out where to route the bug and create a smaller test project that doesn't involve any of your code.

@rolfbjarne thanks for looking into this!

@mwilson25
Copy link

Just to let you know that I have this problem also - exactly as described above. I gave the solution from @formerlymisterhenson a shot and my build has now completed OK. However, not sure whether

True
-all,System.Private.Windows.Core

is going to have any adverse effects?

@ivanpovazan ivanpovazan added os-ios Apple iOS and removed untriaged New issue has not been triaged by the area owner labels Nov 21, 2024
Copy link
Contributor

Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

@vitek-karas
Copy link
Member

@BrzVlad could you please repro from Rolf's repro and get a real callstack - the one in the crash report is probably without symbols. That should help us triage this better.

@GUELIANEBelkacem
Copy link

Any news on this issue? we have the exact same

@BrzVlad
Copy link
Member

BrzVlad commented Dec 9, 2024

The fix is there, the release cycle will take a while. I would assume the new .NET9 version will be available sometime in January.

@vitek-karas
Copy link
Member

The backport to 9 is #110271.

@Dark-MatterSoftware
Copy link

Dark-MatterSoftware commented Dec 23, 2024

Tried the suggestion above and others separate and together and still same issues.IOSBuild.zip

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net9.0-ios|AnyCPU'">
	<NoSymbolStrip Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">True</NoSymbolStrip>
	<CodesignKey>Apple Distribution: XXXXX (YYYYYY)</CodesignKey>
	<CodesignProvision>Fertilizer Calc Distribution</CodesignProvision>
	<ProvisioningType>manual</ProvisioningType>
	<ArchiveOnBuild>true</ArchiveOnBuild>
	<MtouchLink>None</MtouchLink>
	<!-- Disable code linking entirely -->
	<MtouchUseLlvm>True</MtouchUseLlvm>
	<!-- Disable LLVM compilation -->
	<EnableSGenConc>True</EnableSGenConc>
	<!-- Disable concurrent garbage collection -->
	<NoSymbolStrip>true</NoSymbolStrip>
	<MtouchNoSymbolStrip>True</MtouchNoSymbolStrip>
	<EmbedOnDemandResources>True</EmbedOnDemandResources>
	<SuppressTrimAnalysisWarnings>True</SuppressTrimAnalysisWarnings>
	<!-- Suppress warnings -->
	<EnableTrimAnalyzer>False</EnableTrimAnalyzer>
	<!-- Disable the trim analyzer -->
	<MtouchExtraArgs>--aot=verbose</MtouchExtraArgs>
	<MtouchExtraArgs>--aot-options=limit-llvm-stack=400MB</MtouchExtraArgs>
	<MtouchExtraArgs>--aot=threads=1</MtouchExtraArgs>
	<MtouchInterpreter>-all,System.Private.Windows.Core</MtouchInterpreter>
	<EnableSGenConc>True</EnableSGenConc>
</PropertyGroup>

1> With environment:
1> DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
1> Tool /Users/donaldjoyce/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution finished (exit code = 139).
1> C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk.net9.0_18.2\18.2.9170\targets\Xamarin.Shared.Sdk.targets(1279,3): error : Failed to AOT compile aot-instances.dll, the AOT compiler exited with code 139.
1> Tool /Users/donaldjoyce/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64/9.0.0/Sdk/../tools/mono-aot-cross execution started with arguments: --path=/Users/donaldjoyce/Library/Caches/Xamarin/mtbs/builds/FertilizerCalcMobile/90be3bdb69a51e414ed28f356ba1bbe5e404546b43a276067601ad0a57db572c/obj/Release/net9.0-ios/ios-arm64/linked --aot=mtriple=arm64-ios,data-outfile=obj/Release/net9.0-ios/ios-arm64/nativelibraries/aot-output/arm64/FertilizerCalcMobile.aotdata,static,asmonly,dedup-skip,direct-icalls,threads=1,interp,full,readonly-value=ObjCRuntime.Runtime.Arch=i4/0,nodebug,dwarfdebug,llvm-path=/Users/donaldjoyce/Library/Caches/Xamarin/XMA/SDKs/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64/9.0.0/Sdk/../tools,outfile=obj/Release/net9.0-ios/ios-arm64/nativelibraries/aot-output/arm64/FertilizerCalcMobile.dll.s,llvm-outfile=obj/Release/net9.0-ios/ios-arm64/nativelibraries/aot-output/arm64/FertilizerCalcMobile.dll.llvm.o --debug --llvm -O=gsharedvt /Users/donaldjoyce/Library/Caches/Xamarin/mtbs/builds/FertilizerCalcMobile/90be3bdb69a51e414ed28f356ba1bbe5e404546b43a276067601ad0a57db572c/obj/Release/net9.0-ios/ios-arm64/linked/FertilizerCalcMobile.dll
1> Current directory: /Users/donaldjoyce/Library/Caches/Xamarin/mtbs/builds/FertilizerCalcMobile/90be3bdb69a51e414ed28f356ba1bbe5e404546b43a276067601ad0a57db572c

@DCox2016
Copy link

True -all,System.Private.Windows.Core

this worked for me I was able to do a release build. @rolfbjarne thank you

@Dark-MatterSoftware
Copy link

As of to date. Still not able to do a release, but have been able to upload a "Debug" version of the app for Test Flight until this is fixed.

@bwinklesky
Copy link

As of to date. Still not able to do a release, but have been able to upload a "Debug" version of the app for Test Flight until this is fixed.

Not sure if you’re building against .NET 9 or not, but if you are… you can downgrade to version 8 and you should be able to publish a release build.

@Dark-MatterSoftware
Copy link

As of to date. Still not able to do a release, but have been able to upload a "Debug" version of the app for Test Flight until this is fixed.

Not sure if you’re building against .NET 9 or not, but if you are… you can downgrade to version 8 and you should be able to publish a release build.

I am developing for .Net 9. I did try switching to .Net 8 but many of my libraries also needed to be downgraded as well. Then some other issues came up that were fixed in the 9 libraries. So I will wait, this application is multi platform.

@Migoked
Copy link

Migoked commented Dec 29, 2024

Removing the package SixLabors.ImageSharp from the project "resolved" the problem for me.

@Robbidos
Copy link

Any word on when this fix will be released? I too have the SizLablrs.ImageSharp nuget package and I'm getting this error. Unfortunately, I can't remove that package.

@vitek-karas
Copy link
Member

#110271 is now merged into the servicing branch for 9. It should go out with the next release (Feb). Assuming you're hitting the same problem the fix is for.

@Dark-MatterSoftware
Copy link

For a workaround at the moment. I can compile in Debug and Publish, but the Publish hangs. If you watch the folder "/Users/{Username}/Library/Developer/Xcode/Archives" on your Mac. A folder will be created with a date stamp "YYYY-MM-DD" format with an archive file located inside. From there I have to end Visual Studio via Task Manager. Canceling causes issues with the file, perhaps it's trying to roll back. Double clicking the file will open XCode to Validate and/or Distribute the app to the Store. My app is still in TestFlight for the moment so this is workable until this issue can be resolved.

@softlion
Copy link

#110271 is now merged into the servicing branch for 9. It should go out with the next release (Feb). Assuming you're hitting the same problem the fix is for.

first tuesday of january ?

@vitek-karas
Copy link
Member

@softlion I think it should be second week of February.

@BleuBleu
Copy link

BleuBleu commented Feb 1, 2025

I am getting this too with .NET 8.0 on IOS when using VS 17.13 preview 4.0. Rollbacking to preview 1.0 fixes it.

Will the fix in .net 9.0 will apply to .net 8.0 as well?

-Mat

@BrzVlad
Copy link
Member

BrzVlad commented Feb 4, 2025

Another failure was detected on this sample with the 9.0.2 service release (due in February). An additional fix was required #112005, which will be included in 9.0.3 release (due in March from my understanding). Sorry about the delay.

@BleuBleu A fix for these AOT compilation issues was introduced on .NET9 and these subsequent fixes expand on that work so they are only relevant for .NET9. There is nothing planned for .NET8.

@electro-logic
Copy link

Same issue with MAUI 9 + ImageSharp + iOS

@electro-logic
Copy link

electro-logic commented Feb 9, 2025

Adding this fixed the compilation

	<!--Don't enable the interpreter for release builds on Android because it disables JIT compilation.-->
	<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
		<UseInterpreter>true</UseInterpreter>
	</PropertyGroup>

Not a super clean workaround, but worked for me

@bchehab
Copy link

bchehab commented Feb 12, 2025

Adding this fixed the compilation

	<!--Don't enable the interpreter for release builds on Android because it disables JIT compilation.-->
	<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
		<UseInterpreter>true</UseInterpreter>
	</PropertyGroup>

Not a super clean workaround, but worked for me

I'm using MAUI on .NET 9 with ImageSharp as well, and @electro-logic workaround worked for me.

While MtouchInterpreter -all didn't.

@softlion
Copy link

Adding this fixed the compilation

	<!--Don't enable the interpreter for release builds on Android because it disables JIT compilation.-->
	<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
		<UseInterpreter>true</UseInterpreter>
	</PropertyGroup>

Not a super clean workaround, but worked for me

I'm using MAUI on .NET 9 with ImageSharp as well, and @electro-logic workaround worked for me.

While MtouchInterpreter -all didn't.

It does work, but makes the app very very slow.
It's already slow with Maui but with the interpréter it's horrible.

@bchehab
Copy link

bchehab commented Feb 12, 2025

@softlion true. I read that this option should still perform aot for everything it can, and fallback to interpreter mode. But my build used to take 20+ minutes and now it finishes in 5 mins. So I guess no aot is taking place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests