Re: [Mono-dev] How do I develop mono/C# applications for the AppleiPhone?
I have been working for the last three weeks on trying to get Mono running on the iPhone. I have been fairly successful and I am able to run small pieces of managed code now. However, I am a long, long way from being able to write the whole app in managed code. The only way to get things on the screen is to use the native UIKit so that means that you have to do a lot of back and forth between managed and unmanaged code. I haven't seen a framework that helps you cross that bridge yet. Unity is of course geared for games so they take care of all of that for you and I have heard it is a really great product. There is a lot of different issues that you are faced with when trying to get Mono running on the iPhone. The first part is to compile it with the apple arm toolchain. This assumes that you are familiar with a *nix-style of development with make files, auto tools etc... Things are very well laid out and it isn't that difficult to get things compiled but it requires a different skillset than if you are used to VS.NET. I hadn't done this style of development for a long time so it took me a while to ramp-up. The second issue which is a lot more difficult I think is to be able to do the full AOT compilation of your managed code. In order to do this you have to run Mono on an ARM processor or patch Mono quite heavily (this is the way Unity went...). What I have to do is to run Mono on the iPhone in order to compile the assembly and the run Mono again using the just compiled assembly. Before I can run my managed assembly I have to use the Apple assembler and linker as well as codesign the library before I can put it back on the iPhone. Compling AOT on the device means that the turn-around time is much longer than for instance what Unity can offer. A third option would be to use a ARM emulator (QEMU) and do the compilation on that virtual machine. Now you have some managed code that you can run on the iPhone. The next challenge as I mentioned first in my reply is how you would interact with the UI using managed code. For right now it would have to be a hybrid approach where you transition between unmanaged and managed code so you would have to mix C, Objective-C and C# in your app. This is all doable but maybe not the most productive way of developing. It is a challenge to do what you want to do but a very interesting and intellectually rewarding challenge as well. Mariner, David wrote: Hi Daniel, Firstly, I'll only talk about the authorized development scene for the device. If you don't already know or can't find out about alternate methods, then you'll probably have little success with them if I pointed you in their direction. Firstly you're going to need to get a mac to dev on. An intel Mini with 10.5 is minimum requirements for the iPhone toolchain, but will do the job fine. Spring for some extra RAM, but google around for DIY upgrade, don't pay the Apple tax on it. Next you're going to need ADC membership (which is free), and then sign up to the iPhone dev program (also free) which will let you download the toolchain (including emulator) but then you'll need to pay over $99 for a certificate to let you run any apps you develop on the device. Then you're all set to develop and deploy to the iPhone in general. If you're wanting to start hacking around in mono on the device, the first thing to do would be to check out the source from the SVN server, and look at ~/mono/build-mono.sh. This is what will enable you to cross-compile using the apple toolchain. From then on you're into exposing APIs, working out a nice productive development / deployment toolchain and all that good stuff. Also, bear in mind that the combination of the Apple developer agreement and Novell's license terms for mono means that if you're going to be a commercial developer, you'll need to speak to Novell regarding a commercial license. But IANAL, so take professional advice as necessary. Or you can go for the Unity option. You'll still need the mac and the $99 certificate from Apple, but if you want to dev in c# on the iPhone, it's really going to be your quickest route to deployment. One of the best things about it is that you can do extremely rapid code-build-test cycles...in the order of about 3 seconds until you're seeing the results of your changes. I know that it seems like a large outlay, but if you're seriously looking to develop any game-style applications and you want to avoid a whole world of pain then I'd really recommend the Unity route. If you're more in it for the hacker culture aspect of cool toys, or if you want to do applications rather than games then try without it first. Once you've got the mac setup, you can always evaluate the 30 day trial of Unity to see how you get on with it as an environment. Hope this helps, Dave P.S. In the interest of full disclosure, my wife works at Unity. But that doesn't change the fact that it's
[Mono-dev] Full AOT compilation of generics supported?
Running a two-week old SVN HEAD version of Mono and have been using the full AOT compilation feature as well as the mono_aot_only mode of running the system so that I can execute managed code on the iPhone. I have been successful in doing so and have been instantiating and executing various managed code methods to verify the functionality. Last night I fully AOT compiled an assembly that has a method with some generics code in it. I basically add a few strings to a Liststring collection. When running this method an assert was triggered and looking at the stack trace it seemed to have stopped when it tried to compile a runtime_invoke_void_* method (not sure about the exact name of this method)... which was created as an extra method when previously compiling the generic code. Now, the assert was triggered because I was running with mono_aot_only = TRUE but the code was trying to invoke a JIT compilation. Does this mean that generics isn't supported right now for full AOT compilation? or does it mean that I haven't initialized the system correctly (either at compile time or at runtime)? If it is not supported are there any goals for when this would be available? Thanks, -- View this message in context: http://www.nabble.com/Full-AOT-compilation-of-generics-supported--tp22204268p22204268.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Full AOT compilation of generics supported?
Hi again, I got the latest from SVN and recompiled all of my base libraries again (mscorlib,System and System.Core) as well as my custom assembly. The base libraries are taken from the mono/2.1 folder so I am compiling with the Silverlight binaries. When I try to run my method I get the following assert... ** ERROR **: Attempting to JIT compile method '(wrapper static-rgctx-invoke) System.Collections.Generic.Comparer`1string:static_rgctx_invoke_void ()' while running with --aot-only. This is the code that I am trying to run... using System; using System.Collections.Generic; namespace MonoSLLibrary { public class Class1 { /// summary /// Cretes a generic list, creates a few items descending order, sorts the list /// and returns the first item. The first item should be a 1; /// /summary /// returns/returns public string SortListAndReturnFirstItem() { Liststring strings = new Liststring(); strings.Add(3); strings.Add(2); strings.Add(1); strings.Sort(); return strings[0]; } } } I guess it is the call to strings.Sort that is causing some issues with the comparer. Is still one of those rare cases where Mono doesn't JIT-compile or should this not be happening? Peter Hi, full aot + generics is mostly supported, but it is very hard to statically determine the set of generics methods which need to be AOTed so it might not work in all cases. Try current SVN HEAD as there were fixes in this area in the past two weeks. Zoltan -- View this message in context: http://www.nabble.com/Full-AOT-compilation-of-generics-supported--tp22204268p22217501.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Full AOT compilation of generics supported?
Update on this one.. If I comment out the line that has strings.Sort(); on it I am successful in retrieving back the string 3 from the managed world. Hi again, I got the latest from SVN and recompiled all of my base libraries again (mscorlib,System and System.Core) as well as my custom assembly. The base libraries are taken from the mono/2.1 folder so I am compiling with the Silverlight binaries. When I try to run my method I get the following assert... ** ERROR **: Attempting to JIT compile method '(wrapper static-rgctx-invoke) System.Collections.Generic.Comparer`1string:static_rgctx_invoke_void ()' while running with --aot-only. This is the code that I am trying to run... using System; using System.Collections.Generic; namespace MonoSLLibrary { public class Class1 { /// summary /// Cretes a generic list, creates a few items descending order, sorts the list /// and returns the first item. The first item should be a 1; /// /summary /// returns/returns public string SortListAndReturnFirstItem() { Liststring strings = new Liststring(); strings.Add(3); strings.Add(2); strings.Add(1); strings.Sort(); return strings[0]; } } } I guess it is the call to strings.Sort that is causing some issues with the comparer. Is still one of those rare cases where Mono doesn't JIT-compile or should this not be happening? Peter Zoltan Varga wrote: Hi, full aot + generics is mostly supported, but it is very hard to statically determine the set of generics methods which need to be AOTed so it might not work in all cases. Try current SVN HEAD as there were fixes in this area in the past two weeks. Zoltan -- View this message in context: http://www.nabble.com/Full-AOT-compilation-of-generics-supported--tp22204268p22217671.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Unable to call methods on managed objects while running Mono on the iPhone
Over the past couple of weeks I have been working with getting the Mono framework up and running on the iPhone and I am darn close to have it all working.. .I have been able to get the AOT compilation to work and was able this morning to startup Mono in full aot mode on the device. Big thanks to Zoltan Varga for helping me through all the roadblocks I ran into. I have been working with a SVN HEAD version that I updated last week sometime. Next step I took was to try to invoke some methods on classes in the msorlib assembly to see if I could execute managed code and this is where I ran into a new road block.. It looks like I am only able to execute .ctor methods!? During the startup of Mono it creates a few exceptions (OutOfMemoryException etc..) and it invokes its constructor method and passes in parameters. This works just fine...and here it is executing managed code. However, I tried to execute the ToString() method on an instance of the Exception class and then the program is interrupted and stopped in the prolog for the function mono_get_lmf_addr.. if I continue to run the program I get a BAD_INSTRUCTION message and the whole thing shuts down... Here is the code I am trying to execute... MonoDomain * domain = mono_jit_init(); MonoAssembly* msCorlib = mono_domain_assembly_open (domain,mscorlib); MonoImage* image = mono_assembly_get_image(msCorlib); MonoClass *klass = mono_class_from_name (image, System, Exception); MonoObject* o = mono_object_new (domain, klass); MonoMethodDesc* methodDesc = mono_method_desc_new(System.Object:ToString, TRUE); MonoMethod* toStringMethod = mono_method_desc_search_in_class(methodDesc, klass); MonoObject* result = mono_runtime_invoke(toStringMethod, o, NULL, NULL); I don't know if it would help you but here is the assembly where it all stops... mono_get_lmf_addr 0x001d5bdc + push {r4, r5, r7, lr} 0x001d5bde +0002 add r7, sp, #8 0x001d5be0 +0004 sub sp, #12 -- stops here 0x001d5be2 +0006 ldr r3, [pc, #76] (0x1d5c30 mono_get_lmf_addr+84) 0x001d5be4 +0008 add r3, pc 0x001d5be6 +0010 ldr r3, [r3, #0] 0x001d5be8 +0012 adds r0, r3, #0 0x001d5bea +0014 bl 0x3e640 TlsGetValue I get the same problem if I try to run other methods on other objects or static methods as well...Only constructor methods seems to work. It looks to me that the stack isn't setup properly since it always throws the EXC_BAD_INSTRUCTION when trying to access the stack pointer. I have been banging my head against this problem for two days and right now I am not able to figure out how to troubleshoot this. If there is anyone out there that have any suggestion on how I should go about troubleshooting this I would really appreciate it. It stings a bit to come this close and not be able to cross the finish line... Thanks, -- View this message in context: http://www.nabble.com/Unable-to-call-methods-on-managed-objects-while-running-Mono-on-the-iPhone-tp22155202p22155202.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unable to call methods on managed objects while running Mono on the iPhone
An update on this one...I found a setting in XCode that said Compile for Thumb and that one was set to true. I unchecked it and recompiled everything and now the code doesn't stop at the same position anymore...now I get an EXC_BAD_ACCESS on the get_hazardous_pointer...so I am still not there but at least I cleared the hurdle I first posted about. Since thumb instructions are 16 bits and ARM mode are 32 bits things must have not been aligned properly and hence the BAD_INSTRUCTION exceptions. This is the call stack right now... #0 0x0007e0cc in get_hazardous_pointer at domain.c:276 #1 0x0007e4e8 in mono_jit_info_table_find at domain.c:370 #2 0x0020f17c in mono_get_generic_context_from_code at mini-generic-sharing.c:26 #3 0x0020f5a8 in mono_convert_imt_slot_to_vtable_slot at mini-trampolines.c:47 #4 0x0021044c in mono_magic_trampoline at mini-trampolines.c:348 #5 0x03904524 in method_order_end I guess my next step is to research my hazardous_pointers mobbe wrote: Over the past couple of weeks I have been working with getting the Mono framework up and running on the iPhone and I am darn close to have it all working.. .I have been able to get the AOT compilation to work and was able this morning to startup Mono in full aot mode on the device. Big thanks to Zoltan Varga for helping me through all the roadblocks I ran into. I have been working with a SVN HEAD version that I updated last week sometime. Next step I took was to try to invoke some methods on classes in the msorlib assembly to see if I could execute managed code and this is where I ran into a new road block.. It looks like I am only able to execute .ctor methods!? During the startup of Mono it creates a few exceptions (OutOfMemoryException etc..) and it invokes its constructor method and passes in parameters. This works just fine...and here it is executing managed code. However, I tried to execute the ToString() method on an instance of the Exception class and then the program is interrupted and stopped in the prolog for the function mono_get_lmf_addr.. if I continue to run the program I get a BAD_INSTRUCTION message and the whole thing shuts down... Here is the code I am trying to execute... MonoDomain * domain = mono_jit_init(); MonoAssembly* msCorlib = mono_domain_assembly_open (domain,mscorlib); MonoImage* image = mono_assembly_get_image(msCorlib); MonoClass *klass = mono_class_from_name (image, System, Exception); MonoObject* o = mono_object_new (domain, klass); MonoMethodDesc* methodDesc = mono_method_desc_new(System.Object:ToString, TRUE); MonoMethod* toStringMethod = mono_method_desc_search_in_class(methodDesc, klass); MonoObject* result = mono_runtime_invoke(toStringMethod, o, NULL, NULL); I don't know if it would help you but here is the assembly where it all stops... mono_get_lmf_addr 0x001d5bdc + push {r4, r5, r7, lr} 0x001d5bde +0002 add r7, sp, #8 0x001d5be0 +0004 sub sp, #12 -- stops here 0x001d5be2 +0006 ldr r3, [pc, #76] (0x1d5c30 mono_get_lmf_addr+84) 0x001d5be4 +0008 add r3, pc 0x001d5be6 +0010 ldr r3, [r3, #0] 0x001d5be8 +0012 adds r0, r3, #0 0x001d5bea +0014 bl 0x3e640 TlsGetValue I get the same problem if I try to run other methods on other objects or static methods as well...Only constructor methods seems to work. It looks to me that the stack isn't setup properly since it always throws the EXC_BAD_INSTRUCTION when trying to access the stack pointer. I have been banging my head against this problem for two days and right now I am not able to figure out how to troubleshoot this. If there is anyone out there that have any suggestion on how I should go about troubleshooting this I would really appreciate it. It stings a bit to come this close and not be able to cross the finish line... Thanks, -- View this message in context: http://www.nabble.com/Unable-to-call-methods-on-managed-objects-while-running-Mono-on-the-iPhone-tp22155202p2216.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] On what platform|cpu-arch|mono-version does full AOT actually work?
I compiled the Mono framework (the unmanaged pieces) so that I could run it on my iPhone. I was successful in doing that and thought that I would try to do AOT on the iPhone...transfer the temporary asm output to my Mac to assemble and link it and from there keep going... however when performing the AOT compilation of mscorlib.dll Mono hit another assert... something with inst-sreg1 being negative 1 (-1) (Don't remember right now what funtion it stopped in..will have to supply that information when I get to my Mac later tonight). If I commented out the assert it went on a bit further but stopped on a another assert when trying to emit the op-code saying that it was expecting 0 bytes for the op-code ld_loadmembase but got 4... Anyone out there have an ideas of where I should be looking next in order to try to solve this? It seems like the instruction set it is using for ARM doesn't match the source codes assumptions. I am sure that I am doing something wrong but don't know where to begin to look for the issue. Maybe someone out there has a cpu-arm.h file that they know works that I can compare with mine? Are there any other generated files regarding the instruction set that I should double check? Thanks for your help in advance. Hi, full-aot currently only works on amd64/arm. Zoltan -- View this message in context: http://www.nabble.com/On-what-platform%7Ccpu-arch%7Cmono-version-does-full-AOT-actually-work--tp21988583p22038601.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] On what platform|cpu-arch|mono-version does full AOT actually work?
I am indeed trying to compile a 2.0 version of the mscorlib. I will grab the 1.0 version instead and see if I have better luck with that one...if I can get that to work then I will migrate to use the code from SVN and try with the 2.0 profile. Thanks, Zoltan Varga wrote: Hi, You might be trying to use full-aot with the 2.0 profile. Currently, only the 1.0 mscorlib can be full-aot-ed, altough 2.0 should work when using mono SVN. Zoltan On Mon, Feb 16, 2009 at 3:48 PM, mobbe peter.mob...@gmail.com wrote: I compiled the Mono framework (the unmanaged pieces) so that I could run it on my iPhone. I was successful in doing that and thought that I would try to do AOT on the iPhone...transfer the temporary asm output to my Mac to assemble and link it and from there keep going... however when performing the AOT compilation of mscorlib.dll Mono hit another assert... something with inst-sreg1 being negative 1 (-1) (Don't remember right now what funtion it stopped in..will have to supply that information when I get to my Mac later tonight). If I commented out the assert it went on a bit further but stopped on a another assert when trying to emit the op-code saying that it was expecting 0 bytes for the op-code ld_loadmembase but got 4... Anyone out there have an ideas of where I should be looking next in order to try to solve this? It seems like the instruction set it is using for ARM doesn't match the source codes assumptions. I am sure that I am doing something wrong but don't know where to begin to look for the issue. Maybe someone out there has a cpu-arm.h file that they know works that I can compare with mine? Are there any other generated files regarding the instruction set that I should double check? Thanks for your help in advance. Hi, full-aot currently only works on amd64/arm. Zoltan -- View this message in context: http://www.nabble.com/On-what-platform%7Ccpu-arch%7Cmono-version-does-full-AOT-actually-work--tp21988583p22038601.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list -- View this message in context: http://www.nabble.com/On-what-platform%7Ccpu-arch%7Cmono-version-does-full-AOT-actually-work--tp21988583p22039018.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] On what platform|cpu-arch|mono-version does full AOT actually work?
Nope...same results with a mscorlib.dll from the 1.0 folder. It gets stuck in the mono_local_regalloc method on the assert checking for ins-sreg != -1... Exactly the same message as before. It is trying to compile the Equals method The inst op code is 633 and both sreg1 and sreg2 is -1.. . I am running the system with build 125709 and compiling the mscorlib.dll from the 1.0 folder... mobbe wrote: I am indeed trying to compile a 2.0 version of the mscorlib. I will grab the 1.0 version instead and see if I have better luck with that one...if I can get that to work then I will migrate to use the code from SVN and try with the 2.0 profile. Thanks, Zoltan Varga wrote: Hi, You might be trying to use full-aot with the 2.0 profile. Currently, only the 1.0 mscorlib can be full-aot-ed, altough 2.0 should work when using mono SVN. Zoltan On Mon, Feb 16, 2009 at 3:48 PM, mobbe peter.mob...@gmail.com wrote: I compiled the Mono framework (the unmanaged pieces) so that I could run it on my iPhone. I was successful in doing that and thought that I would try to do AOT on the iPhone...transfer the temporary asm output to my Mac to assemble and link it and from there keep going... however when performing the AOT compilation of mscorlib.dll Mono hit another assert... something with inst-sreg1 being negative 1 (-1) (Don't remember right now what funtion it stopped in..will have to supply that information when I get to my Mac later tonight). If I commented out the assert it went on a bit further but stopped on a another assert when trying to emit the op-code saying that it was expecting 0 bytes for the op-code ld_loadmembase but got 4... Anyone out there have an ideas of where I should be looking next in order to try to solve this? It seems like the instruction set it is using for ARM doesn't match the source codes assumptions. I am sure that I am doing something wrong but don't know where to begin to look for the issue. Maybe someone out there has a cpu-arm.h file that they know works that I can compare with mine? Are there any other generated files regarding the instruction set that I should double check? Thanks for your help in advance. Hi, full-aot currently only works on amd64/arm. Zoltan -- View this message in context: http://www.nabble.com/On-what-platform%7Ccpu-arch%7Cmono-version-does-full-AOT-actually-work--tp21988583p22038601.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list -- View this message in context: http://www.nabble.com/On-what-platform%7Ccpu-arch%7Cmono-version-does-full-AOT-actually-work--tp21988583p22049003.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] On what platform|cpu-arch|mono-version does full AOT actually work?
I downloaded a openSUSE 11.0 image with Mono 2.2 and tried the following in a terminal window... sudo mono --aot=full /usr/lib/1.0/mscorlib.dll The end result is that an assert in the code triggers a halt. The specific assert message is: ** ERROR: (mini-x86.c:5314): mono_arch_get_patch_offset: code should not be reached. I have been working with enabling AOT on the Mac and I get the same message there... looks like it doesn't recognize certain opcodes and then the assert halts the program. Anyone know on what platform/cpu combination and Mono version the full AOT actually works? I have been trying to debug the code and see if I could figure out what was wrong but as I said..it just looks like certain opcodes that Mono generates don't sit well with the code generator. If it is not the code but rather that I am not invoking the tools correctly then please let me know as well... Thanks -- View this message in context: http://www.nabble.com/On-what-platform%7Ccpu-arch%7Cmono-version-does-full-AOT-actually-work--tp21988583p21988583.html Sent from the Mono - Dev mailing list archive at Nabble.com. ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list