[Mono-list] Problem using 0.24 aot - Please help

Paolo Molaro lupus@ximian.com
Mon, 19 May 2003 11:21:54 +0200

On 05/18/03 Vivek, Bharath Varma (IE10) wrote:
> I'm facing few problems using the new aot compiler.
> The problem is explained in detail below.....

Note, the AOT compiler is not yet at the same level of performance or
robustness as the plain JIT, so find issues with it is likely at this
time. Also, it's completely untested by us on windows and won't work as
it is. Help by windows programmers is appreciated.

> Doing mono --aot HelloWorld.exe, gave me the following.........
> Executing the native assembler now:
> as c:\WINNT\Profiles\vivekv\LOCALS~1\Temp/mono_aot_03456 -o
> c:\WINNT\Profiles\vivekv\LOCALS~1\Temp/mono_aot_03456.o;ld -shared -o
> HelloWorld.exe.so c:\WINNT\Profiles\vivekv\LOCALS~1\Temp/mono_aot_03456.o;rm
> c:\WINNT\Profiles\vivekv\LOCALS~1\Temp/mono_aot_03456.o;strip
> --strip-unneeded --discard-all HelloWorld.exe.so
> as: unrecognized option `-shared'

The windows shell doesn't understand the command separator ';'.
We'll need to issue the separate commands with separate system() calls.

> Using the ld(GNU linker) as mentioned above gave me the following..........
> Cannot export method_06000001: symbol not found
> Cannot export method_06000001_patch_info: symbol not found
> Cannot export method_06000002: symbol not found
> Cannot export method_06000002_patch_info: symbol not found
> Cannot export mono_assembly_guid: symbol not found
> So I removed the -shared option and did 
> ld -o HelloWorld.exe.so
> c:\WINNT\Profiles\vivekv\LOCALS~1\Temp/mono_aot_03456.o

You can't remove -shared: the linker is supposed to create a shared
library (.dll) with all the needed methods exported, so that it can be
later loaded by the JIT as a library at runtime.

> To make sure that the aot compiled code was being used, I debugged the
> execution and found that it was not using the aot compiled code!

Yes, using mini --stats will also report:
Methods from AOT:       0

Since you didn't compile to a dll, it can't work.

> Few Questions.....
> Why did I get the unrecognized option "-shared"?

See above the issue with the shell.

> Why did I get "cannot export method" errors when using the linker? 

No idea, the function in the assembly output may need to be marked with
some windows-specific stuff, try checking the assembly generated by gcc
and make the aot code output the same kind of stuff.

> I created HelloWorld.exe.so without using the -shared option, so did my
> HelloWorld.exe.so getting created properly?

No, you need to create a shared library.

> Why is "g_module_symbol" not able to find the symbol which contains my
> assembly's GUID?

Because you didn't build a dll that exported the symbol.
Note, after you've fixed those issues, there is another one to address,
grep in aot.c for this chunk of code:
#ifndef PLATFORM_WIN32
                /* disable write protection */
                page_start = (char *) (((int) (code)) & ~ (PAGESIZE - 1));
                pages = (code + code_len - page_start + PAGESIZE - 1) / PAGESIZE;
                err = mprotect (page_start, pages * PAGESIZE, PROT_READ | PROT_WRITE | PROT_EXEC);
                g_assert (err == 0);
You need to write the equivalent code that works on windows, basically
get the area of memory at page_start have read, write and execute


lupus@debian.org                                     debian/rules
lupus@ximian.com                             Monkeys do it better