xamarin / XamarinComponents

Plugins for Xamarin
MIT License
1.99k stars 696 forks source link

Google.ZXing.Core "Broken module found, compilation aborted" when using AOT + LLVM on Android #1193

Open Tommigun1980 opened 3 years ago

Tommigun1980 commented 3 years ago

Hi.

If a Xamarin.Android project references 'Google.ZXing.Core' and is using APT + LLVM, the deployment build step will fail with the following:

    [aot-compiler stdout] Mono Ahead of Time compiler - compiling assembly /Users/myname/Projects/myproject/MyApp.Android/obj/Development/android/assets/shrunk/Google.ZXing.Core.dll
    [aot-compiler stdout] AOTID ECDFCD8D-72E5-C8A4-F042-AFFFB093547E
    [aot-compiler stdout] Executing opt: "/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild/Xamarin/Android/Darwin/opt" -f -O2 -disable-tail-calls -place-safepoints -spp-all-backedges -o "obj/Development/aot/armeabi-v7a/Google.ZXing.Core.dll/temp.opt.bc" "obj/Development/aot/armeabi-v7a/Google.ZXing.Core.dll/temp.bc"
    [aot-compiler stderr] Basic Block in function 'Google_ZXing_Client_Result_AddressBookParsedResult__ctor_string___string___string___string___string___string___string__' does not have terminator!
    [aot-compiler stderr] label %NOTINITED_BB30
    [aot-compiler stderr] LLVM ERROR: Broken module found, compilation aborted!

This is chronicled at https://github.com/xamarin/xamarin-android/issues/5779 and @dellis1972 verified at https://github.com/xamarin/xamarin-android/issues/5779#issuecomment-854650640 that said assembly indeed is broken ("[...] the Assembly being AOT'd has invalid IL in it which is breaking the compiler.").

While they investigate what is going on could you guys maybe release a rebuilt version of 'Google.ZXing.Core' so that Android apps can use LLVM again?

The 'Google.ZXing.Core' package is referenced from 'Xamarin.Facebook.Android' -> 'Xamarin.Facebook.Common.Android'. This means that any app that uses the Facebook SDK can't be compiled with AOT + LLVM until this is resolved.

Thank you!

Tommigun1980 commented 3 years ago

@moljac Hi. Any chance you guys could release a new version of the 'Google.ZXing.Core' package as it effectively prevents Android apps using Facebook from using the LLVM compiler?

Thank you.

dellis1972 commented 3 years ago

@Tommigun1980 checkout this comment https://github.com/xamarin/xamarin-android/issues/5764#issuecomment-856062396. Looks like the issue is with the GC.KeepAlive , see https://github.com/xamarin/xamarin-android/issues/5764#issuecomment-856061277 for more details.

Tommigun1980 commented 3 years ago

@dellis1972 Fantastic, thank you so much for finding that comment and referring it to me! The workaround worked flawlessly, and proves that the library is intact after all. 🥇

I'll leave this ticket open in case someone else runs into this problem and is about to report it, so feel free to close it when it's no longer relevant to keep this open.