Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting JITs at compile time in MonoTouch

I'm working on a build system for a fairly large MonoTouch application which is using a lot of cross-platform components. As a result, we often run into a situation where one of those cross-platform components does something that cannot be aot compiled. Should that something actually get executed, the device build will crash. At that point, we have to track down where the crash happened, find the offending method, and hack it up so that it won't try to JIT in the MonoTouch build.

My question is, is there a way to detect these things during the build process? At first, we had a regex that tried to detect generic virtual methods, but there are also issues with certain types of LINQ and lambdas that will try to JIT as well, and I'd rather not try to write my own parser to detect them all. I've tried using monodis AssemblyName.dll, and it will give me a lot of missing method errors, but most of them seem to be innocuous - and even if they weren't, it doesn't tell me where the references to said method are so that I can see what needs to be done. On top of that, sometimes it will crash with Abort trap: 6 or Bus error: 10 before the end of the assembly, which is quite unhelpful. Is there a better way I can detect attempts to JIT in my build process?

like image 755
David Merriman Avatar asked Nov 14 '22 09:11

David Merriman


1 Answers

My question is, is there a way to detect these things during the build process?

No. Using the JIT (or more accurately the exception that it's trying to use the JIT) is a runtime fallback when something is not found inside the native executable.

It's not impossible (nor easy) to detect (some/most) conditions leading to the exception using your own tool (it could even be a Gendarme rule). However this is a moving target since we're fixing reported issues so you'll have to update your tooling with each new version (or risk spending time fixing things that are not issues anymore).

What would be really helpful (with or without your own tool) is to report such issues so they can be tracked and become part of Xamarin's test suite.

I've tried using monodis AssemblyName.dll

monodis requires to have access to all assembly references, otherwise it won't work (and can crash).

like image 57
poupou Avatar answered Nov 16 '22 04:11

poupou