[Mono-dev] How to access AOTed assembly code?

Kamal Aboul-Hosn kamal at sooloos.com
Wed Jan 25 22:20:34 UTC 2012


Certainly. Inlining the answers. Thanks!

On Jan 25, 2012, at 5:02 PM, autif khan wrote:

> Kamal,
> 
> Can you please include the following:
> 
> 1) which gcc

/usr/bin/gcc

> 2) output of gcc --version

i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> 3) gcc helloworld.c - and then the output of "file a.out" (just have
> main(){printf("HW\n";)} in helloworld.c

a.out: Mach-O 64-bit executable x86_64

> 
> These will eliminate cross compiler as an issue.
> 
> 4) The full command that is executed before you get this output - it
> is above this output

../../doltcompile gcc -m32 -DHAVE_CONFIG_H -I. -I../.. -I../.. -I../../mono -I../../libgc/include -I../../eglib/src -I../../eglib/src  -no-cpp-precomp -D_THREAD_SAFE -DGC_MACOSX_THREADS -DPLATFORM_MACOSX -DUSE_MMAP -DUSE_MUNMAP -DGetCurrentProcess=MonoGetCurrentProcess -DGetCurrentThread=MonoGetCurrentThread -DCreateEvent=MonoCreateEvent -arch i386 -D_XOPEN_SOURCE -mmacosx-version-min=10.5  -D__default_codegen__ -D__ARM_EABI__ -DARM_FPU_NONE=1 -DNO_UNALIGNED_ACCESS  -arch i386 -D_XOPEN_SOURCE -mmacosx-version-min=10.5 -fno-strict-aliasing -g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wwrite-strings -MT mach-support-arm.lo -MD -MP -MF .deps/mach-support-arm.Tpo -c -o mach-support-arm.lo mach-support-arm.c


> 
> On Wed, Jan 25, 2012 at 3:45 PM, Kamal Aboul-Hosn <kamal at sooloos.com> wrote:
>> Thanks, Robert, that worked very well. I have one more question, if I may. So I'm embedding Mono on Android on ARM. Up until now, I've been AOT compiling the libraries by running a little app on the Android device itself. Obviously, in the long term, this is not really a good option. So now, I'm trying to build a Mono cross compiler for Android ARM on my Mac OS X machine (gcc --arch returns "i686-apple-darwin11-llvm-gcc-4.2" if that is useful).
>> 
>> I do the following configure:
>> 
>> ./configure --target=armv5-linux-androideabi --enable-nls=no  --prefix=/Users/kamal/mono-cross --disable-mcs-build
>> 
>> I also have the CC environment variable and CXX environment variable set to "gcc -m32" and "g++ -m32", respectively, as I believe I read that the cross compiler cannot work if built for 64-bit. Whenever I run make, I quickly get the following errors:
>> 
>> mach-support-arm.c: In function ‘mono_mach_arch_get_ip’:
>> mach-support-arm.c:24: error: ‘arm_thread_state_t’ undeclared (first use in this function)
>> mach-support-arm.c:24: error: (Each undeclared identifier is reported only once
>> mach-support-arm.c:24: error: for each function it appears in.)
>> mach-support-arm.c:24: error: ‘arch_state’ undeclared (first use in this function)
>> mach-support-arm.c:24: error: expected expression before ‘)’ token
>> mach-support-arm.c:27: warning: control reaches end of non-void function
>> mach-support-arm.c: In function ‘mono_mach_arch_get_sp’:
>> mach-support-arm.c:32: error: ‘arm_thread_state_t’ undeclared (first use in this function)
>> mach-support-arm.c:32: error: ‘arch_state’ undeclared (first use in this function)
>> mach-support-arm.c:32: error: expected expression before ‘)’ token
>> mach-support-arm.c:35: warning: control reaches end of non-void function
>> mach-support-arm.c: In function ‘mono_mach_arch_get_mcontext_size’:
>> mach-support-arm.c:40: error: invalid application of ‘sizeof’ to incomplete type ‘struct __darwin_mcontext’
>> mach-support-arm.c: In function ‘mono_mach_arch_thread_state_to_mcontext’:
>> mach-support-arm.c:46: error: ‘arm_thread_state_t’ undeclared (first use in this function)
>> mach-support-arm.c:46: error: ‘arch_state’ undeclared (first use in this function)
>> mach-support-arm.c:46: error: expected expression before ‘)’ token
>> mach-support-arm.c:49: error: dereferencing pointer to incomplete type
>> mach-support-arm.c: In function ‘mono_mach_arch_get_thread_state_size’:
>> mach-support-arm.c:55: error: ‘arm_thread_state_t’ undeclared (first use in this function)
>> mach-support-arm.c:56: warning: control reaches end of non-void function
>> mach-support-arm.c: In function ‘mono_mach_arch_get_thread_state’:
>> mach-support-arm.c:61: error: ‘arm_thread_state_t’ undeclared (first use in this function)
>> mach-support-arm.c:61: error: ‘arch_state’ undeclared (first use in this function)
>> mach-support-arm.c:61: error: expected expression before ‘)’ token
>> mach-support-arm.c:64: error: ‘ARM_THREAD_STATE_COUNT’ undeclared (first use in this function)
>> make[4]: *** [mach-support-arm.lo] Error 1
>> 
>> 
>> Does anyone know how to overcome these errors?
>> 
>> Much appreciated!
>> 
>> Kamal
>> 
>> On Jan 24, 2012, at 4:08 PM, Robert Jordan wrote:
>> 
>>> On 24.01.2012 19:39, Kamal Aboul-Hosn wrote:
>>>> Hi, everyone,
>>>> 
>>>> If I call mono --aot=static,asmonly on a dll to generate a .s file,
>>>> how can I get Mono to load the generated AOT'ed assembly if I include
>>>> the .s in a native .so I'm building myself as part of an application?
>>>> It seems Mono normally just goes looking for a .so file for the
>>>> AOT'ed code. Is it possible to get Mono to use the linked in AOT'ed
>>>> code in the same native library as the rest of my application? Please
>>>> let me know if I can provide any more details.
>>> 
>>> First, you must embed the runtime as described here:
>>> 
>>> http://mono-project.com/Embedding_Mono
>>> 
>>> Second, you must register the static AOT assembly with
>>> mono_aot_register_module. See the description of
>>> --aot=static on mono's man page.
>>> 
>>> This assembly can be consumed like any other file-based
>>> assembly using the embedding API.
>>> 
>>> Robert
>>> 
>>> 
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>> 
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-devel-list mailing list