[Mono-dev] Crosscompiling Mono 5.0.0.100
Angelo Compagnucci
angelo.compagnucci at gmail.com
Tue May 23 21:04:01 UTC 2017
Dearh Bernhard,
2017-05-23 19:54 GMT+02:00 Bernhard Urban <beurba at microsoft.com>:
> > Host: arm-buildroot-linux-gnueabi
> > Target: arm-buildroot-linux-gnueabi
>
> so... you aren't actually cross-compiling, am I right?
I'm actually crosscompiling inside buildroot wich somewhat cheats.
> That's weird then, configure should pick up all the right settings. I'm curious to see the emitted code around the crash site. If you use gdb, something like `x/100i $pc-0x40` should do the trick.
=================================================================
Got a SIGILL while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Thread 1 "mono-sgen" received signal SIGABRT, Aborted.
0xb6cede50 in raise () from /lib/libc.so.6
(gdb) x/100i $pc-0x40
0xb6cede10 <ssignal+196>: andseq r1, r1, r12, ror #8
0xb6cede14 <ssignal+200>:
; <UNDEFINED> instruction: 0x0010e2b8
0xb6cede18 <raise>: push {r7, lr}
0xb6cede1c <raise+4>: mov r2, r0
0xb6cede20 <raise+8>: bl 0xb6cd8650
0xb6cede24 <raise+12>: ldr r1, [r0, #-1112] ; 0xfffffba8
0xb6cede28 <raise+16>: mov r12, r0
0xb6cede2c <raise+20>: cmp r1, #0
0xb6cede30 <raise+24>: ldr r0, [r0, #-1108] ; 0xfffffbac
0xb6cede34 <raise+28>: bne 0xb6cede64 <raise+76>
0xb6cede38 <raise+32>: mov r7, #224 ; 0xe0
0xb6cede3c <raise+36>: svc 0x00000000
0xb6cede40 <raise+40>: mov r1, r0
0xb6cede44 <raise+44>: str r0, [r12, #-1112] ; 0xfffffba8
0xb6cede48 <raise+48>: mov r7, #268 ; 0x10c
0xb6cede4c <raise+52>: svc 0x00000000
=> 0xb6cede50 <raise+56>: cmn r0, #4096 ; 0x1000
0xb6cede54 <raise+60>: mov r3, r0
0xb6cede58 <raise+64>: bhi 0xb6cede80 <raise+104>
0xb6cede5c <raise+68>: mov r0, r3
0xb6cede60 <raise+72>: pop {r7, pc}
0xb6cede64 <raise+76>: cmp r0, #0
---Type <return> to continue, or q <return> to quit---
0xb6cede68 <raise+80>: bgt 0xb6cede48 <raise+48>
0xb6cede6c <raise+84>: bic r3, r0, #-2147483648 ; 0x80000000
0xb6cede70 <raise+88>: cmp r3, #0
0xb6cede74 <raise+92>: rsbne r0, r0, #0
0xb6cede78 <raise+96>: moveq r0, r1
0xb6cede7c <raise+100>: b 0xb6cede48 <raise+48>
0xb6cede80 <raise+104>:
ldr r2, [pc, #20] ; 0xb6cede9c <raise+132>
0xb6cede84 <raise+108>: rsb r1, r0, #0
0xb6cede88 <raise+112>: ldr r2, [pc, r2]
0xb6cede8c <raise+116>: bl 0xb6cd8650
0xb6cede90 <raise+120>: mvn r3, #0
0xb6cede94 <raise+124>: str r1, [r0, r2]
0xb6cede98 <raise+128>: b 0xb6cede5c <raise+68>
0xb6cede9c <raise+132>: andseq lr, r0, r8, lsr #4
0xb6cedea0 <killpg>: cmp r0, #0
0xb6cedea4 <killpg+4>: push {lr} ; (str lr, [sp, #-4]!)
0xb6cedea8 <killpg+8>: blt 0xb6cedeb8 <killpg+24>
0xb6cedeac <killpg+12>: rsb r0, r0, #0
0xb6cedeb0 <killpg+16>: pop {lr} ; (ldr lr, [sp], #4)
0xb6cedeb4 <killpg+20>: b 0xb6cee120 <kill>
0xb6cedeb8 <killpg+24>:
ldr r3, [pc, #20] ; 0xb6ceded4 <killpg+52>
---Type <return> to continue, or q <return> to quit---
0xb6cedebc <killpg+28>: bl 0xb6cd8650
0xb6cedec0 <killpg+32>: ldr r3, [pc, r3]
0xb6cedec4 <killpg+36>: mov r2, #22
0xb6cedec8 <killpg+40>: str r2, [r0, r3]
0xb6cedecc <killpg+44>: mvn r0, #0
0xb6ceded0 <killpg+48>: pop {pc} ; (ldr pc, [sp], #4)
0xb6ceded4 <killpg+52>:
; <UNDEFINED> instruction: 0x0010e1f0
0xb6ceded8: push {r4, r5, r6, r7, lr}
0xb6cededc: ldr r6, [pc, #324] ; 0xb6cee028
0xb6cedee0: subs r5, r1, #0
0xb6cedee4: sub sp, sp, #284 ; 0x11c
0xb6cedee8: mov r7, r0
0xb6cedeec: mov r4, r2
0xb6cedef0: add r6, pc, r6
0xb6cedef4: beq 0xb6cedf28
0xb6cedef8: mov r1, r5
0xb6cedefc: ldr r3, [r1], #4
0xb6cedf00: add r0, sp, #12
0xb6cedf04: mov r2, #128 ; 0x80
0xb6cedf08: str r3, [sp]
0xb6cedf0c: bl 0xb6d3d7a0 <memcpy>
0xb6cedf10: ldr r3, [r5, #132] ; 0x84
---Type <return> to continue, or q <return> to quit---
0xb6cedf14: str r3, [sp, #4]
0xb6cedf18: tst r3, #67108864 ; 0x4000000
0xb6cedf1c: beq 0xb6cedfa8
0xb6cedf20: ldr r3, [r5, #136] ; 0x88
0xb6cedf24: str r3, [sp, #8]
0xb6cedf28: cmp r4, #0
0xb6cedf2c: addne r2, sp, #140 ; 0x8c
0xb6cedf30: moveq r2, r4
0xb6cedf34: cmp r5, #0
0xb6cedf38: mov r0, r7
0xb6cedf3c: movne r1, sp
0xb6cedf40: moveq r1, r5
0xb6cedf44: mov r3, #8
0xb6cedf48: mov r7, #174 ; 0xae
0xb6cedf4c: svc 0x00000000
0xb6cedf50: cmn r0, #4096 ; 0x1000
0xb6cedf54: mov r5, r0
0xb6cedf58: bhi 0xb6cee00c
0xb6cedf5c: adds r3, r4, #0
0xb6cedf60: movne r3, #1
0xb6cedf64: cmp r0, #0
0xb6cedf68: movlt r3, #0
0xb6cedf6c: cmp r3, #0
---Type <return> to continue, or q <return> to quit---
0xb6cedf70: beq 0xb6cedf9c
0xb6cedf74: ldr r3, [sp, #140] ; 0x8c
0xb6cedf78: mov r0, r4
0xb6cedf7c: str r3, [r0], #4
0xb6cedf80: mov r2, #128 ; 0x80
0xb6cedf84: add r1, sp, #152 ; 0x98
0xb6cedf88: bl 0xb6d3d7a0 <memcpy>
0xb6cedf8c: ldr r2, [sp, #144] ; 0x90
0xb6cedf90: ldr r3, [sp, #148] ; 0x94
0xb6cedf94: str r2, [r4, #132] ; 0x84
0xb6cedf98: str r3, [r4, #136] ; 0x88
0xb6cedf9c: mov r0, r5
The file command reports:
/usr/bin/mono-sgen: ELF 32-bit LSB executable, ARM, EABI5 version 1
(SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for
GNU/Linux 2.6.16, stripped
So the cross compilation went well.
Sincerely, Angelo
>
> -Bernhard
> ________________________________________
> From: Angelo Compagnucci <angelo.compagnucci at gmail.com>
> Sent: Tuesday, May 23, 2017 6:35:06 PM
> To: Bernhard Urban
> Cc: Mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] Crosscompiling Mono 5.0.0.100
>
> Hello Bernhard,
>
> The recpie is this one:
>
> ################################################################################
> #
> # mono
> #
> ################################################################################
>
> MONO_VERSION = 5.0.0.100
> MONO_SITE = https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdownload.mono-project.com%2Fsources%2Fmono&data=02%7C01%7Cbeurba%40microsoft.com%7C25ae3075088c4b176de708d4a1f9c451%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636311541495053555&sdata=gh4wrnniTrAEH5C7lGkDBF8dLLusjvGNkJR9KCkHzH4%3D&reserved=0
> MONO_SOURCE = mono-$(MONO_VERSION).tar.bz2
> MONO_LICENSE = GPL-2.0 or MIT (compiler, tools), MIT (libs) or commercial
> MONO_LICENSE_FILES = LICENSE mcs/COPYING eglib/COPYING \
> external/Newtonsoft.Json/Tools/7-zip/copying.txt
> MONO_INSTALL_STAGING = YES
>
> ## Mono native
>
> # patching configure.ac
> MONO_AUTORECONF = YES
>
> # Disable managed code (mcs folder) from building
> MONO_CONF_OPTS = --with-mcs-docs=no \
> --with-ikvm-native=no \
> --enable-minimal=profiler,aot \
> --disable-mcs-build \
> --with-xen_opt=no \
> --disable-btls \
> --enable-static
>
> # The libraries have been built by the host-mono build. Since they are
> # architecture-independent, we simply copy them to the target.
> define MONO_INSTALL_LIBS
> rsync -av --exclude=*.so --exclude=*.mdb \
> $(HOST_DIR)/usr/lib/mono $(TARGET_DIR)/usr/lib/
> endef
>
> MONO_POST_INSTALL_TARGET_HOOKS += MONO_INSTALL_LIBS
>
> ifeq ($(BR2_PACKAGE_LIBICONV),y)
> MONO_DEPENDENCIES += libiconv
> endif
>
> MONO_DEPENDENCIES += host-mono
>
> ## Mono managed
>
> HOST_MONO_CONF_OPTS = --with-mcs-docs=no \
> --disable-libraries \
> --with-ikvm-native=no \
> --enable-minimal=profiler,aot \
> --with-xen_opt=no \
> --disable-btls \
> --enable-static
>
> # ensure monolite is used
> HOST_MONO_MAKE_OPTS += EXTERNAL_MCS=false
>
> HOST_MONO_DEPENDENCIES = host-monolite host-gettext
>
> define HOST_MONO_SETUP_MONOLITE
> rm -rf $(@D)/mcs/class/lib/monolite
> (cd $(@D)/mcs/class/lib; ln -s $(HOST_DIR)/usr/lib/monolite monolite)
> endef
>
> HOST_MONO_POST_CONFIGURE_HOOKS += HOST_MONO_SETUP_MONOLITE
>
> $(eval $(autotools-package))
> $(eval $(host-autotools-package))
>
>
> The package is compiled in two phases: the first compiles host-mono,
> which in reality only compiles the libraries using monolite. Then the
> recipe compiles mono native.
> All the cross compiling options is passed to the recipe by buildroot.
>
> Configure output:
>
> mcs source: mcs
> C# Compiler: roslyn
>
> Engine:
> Host: arm-buildroot-linux-gnueabi
> Target: arm-buildroot-linux-gnueabi
> GC: sgen (concurrent by default) and Included Boehm
> GC with typed GC and parallel mark
> TLS: __thread
> SIGALTSTACK: yes
> Engine: Building and using the JIT
> BigArrays: no
> DTrace: no
> LLVM Back End: no (dynamically loaded: no)
> Interpreter: no
>
> Libraries:
> .NET 4.x: no
> Xamarin.Android: no
> Xamarin.iOS: no
> Xamarin.WatchOS: no
> Xamarin.TVOS: no
> Xamarin.Mac: no
> Windows AOT: no
> Orbis: no
> Test profiles: AOT Full (no), AOT Hybrid (no)
> JNI support:
> libgdiplus: assumed to be installed
> zlib:
> BTLS: no
> Disabled: profiler,aot
>
>
> Consider that the same recipe with mono 4.8.1.0 works like expected.
>
> Sincerely, Angelo
>
> 2017-05-23 18:21 GMT+02:00 Bernhard Urban <beurba at microsoft.com>:
>> How does your configure line look like and what's the output?
>>
>> -Bernhard
>> ________________________________________
>> From: Angelo Compagnucci <angelo.compagnucci at gmail.com>
>> Sent: Tuesday, May 23, 2017 6:07:07 PM
>> To: Bernhard Urban
>> Cc: Mono-devel-list at lists.ximian.com
>> Subject: Re: [Mono-dev] Crosscompiling Mono 5.0.0.100
>>
>> Hello Bernhard,
>>
>> 2017-05-23 17:21 GMT+02:00 Bernhard Urban <beurba at microsoft.com>:
>>> Hello Angelo,
>>>
>>> could you install gdb (or lldb) on your target? It looks like the target device doesn't support some instructions that mono generates (hence SIGILL). It would be useful to get a native stack trace, or a disassembly around the crash site.
>>
>> I have gdb but I'm not having success with a backtrace, I'll try more!
>>
>>> What CPU architecture/platform are you targeting?
>>
>> Qemu versatile, so it's an ARM926EJ-S
>>
>>> That might be helpful as well: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mono-project.com%2Fdocs%2Fdebug%2Bprofile%2Fdebug%2F&data=02%7C01%7Cbeurba%40microsoft.com%7C843ac485cb334abb79e208d4a1f5db83%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636311524711368693&sdata=ZWTL2w5DPPR2ldn8JWj6wV5FxTGLpKSijP6VG8DpNu0%3D&reserved=0
>>
>> I'm looking at it!
>>
>> Thanks!
>>
>>>
>>>
>>> -Bernhard
>>> ________________________________________
>>> From: Mono-devel-list <mono-devel-list-bounces at lists.dot.net> on behalf of Angelo Compagnucci <angelo.compagnucci at gmail.com>
>>> Sent: Tuesday, May 23, 2017 2:43:48 PM
>>> To: Mono-devel-list at lists.ximian.com
>>> Subject: [Mono-dev] Crosscompiling Mono 5.0.0.100
>>>
>>> Hello developers,
>>>
>>> I'm trying to crosscompile mono for qemu versatile with the buildroot
>>> crosscompiling system. More precisely, I'm trying to update the recipe
>>> bundled with buildroot for mono 4.8.1.100.
>>> I'm actually not a novice in this sort of thing, I actually
>>> contributed the recipe in the first place and contributed several
>>> patches to the mono build system to be cross compilable and musl
>>> compatible.
>>>
>>> Actually I have a working recipe, the same one i use for 4.8.1.100 and
>>> which works, and I can successfully compile mono 5.0.0.100.
>>>
>>> Unfortunately, compiling a simple hello world produces this error:
>>>
>>> # mcs hello.cs
>>> Stacktrace:
>>>
>>> at <unknown> <0xffffffff>
>>> at Mono.SafeStringMarshal.get_Value () [0x0001a] in
>>> <a1ccf43d50c94435a9f0fcab25017dca>:0
>>> at System.Environment.internalGetEnvironmentVariable (string)
>>> [0x0000c] in <a1ccf43d50c94435a9f0fcab25017dca>:0
>>> at System.Environment.GetEnvironmentVariable (string) [0x00000] in
>>> <a1ccf43d50c94435a9f0fcab25017dca>:0
>>> at Mono.CSharp.Driver.Main (string[]) [0x00000] in
>>> <65e20f41151e464c8d313246de15d1a3>:0
>>> at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object
>>> (object,intptr,intptr,intptr) [0x00054] in
>>> <65e20f41151e464c8d313246de15d1a3>:0
>>> /proc/self/maps:
>>> 00008000-00299000 r-xp 00000000 08:00 3367 /usr/bin/mono-sgen
>>> 002a0000-002a2000 rwxp 00290000 08:00 3367 /usr/bin/mono-sgen
>>> 002a2000-0033b000 rwxp 00000000 00:00 0 [heap]
>>> b4c91000-b4f09000 r-xp 00000000 08:00 3263
>>> /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
>>> b4f09000-b5000000 r-xp 00000000 08:00 2599
>>> /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
>>> b5000000-b5021000 rwxp 00000000 00:00 0
>>> b5021000-b5100000 ---p 00000000 00:00 0
>>> b51a9000-b51aa000 ---p 00000000 00:00 0
>>> b51aa000-b52a9000 rwxp 00000000 00:00 0
>>> b52a9000-b5652000 r-xp 00000000 08:00 1491 /usr/lib/mono/4.5/mscorlib.dll
>>> b5652000-b5800000 r-xp 00000000 08:00 1270 /usr/lib/mono/4.5/mcs.exe
>>> b5800000-b6000000 rwxp 00000000 00:00 0
>>> b6000000-b6001000 ---p 00000000 00:00 0
>>> b6001000-b6c00000 rwxp 00000000 00:00 0
>>> b6c70000-b6cf0000 rwxp 00000000 00:00 0
>>> b6cf2000-b6d0b000 rwxp 00000000 00:00 0
>>> b6d0b000-b6d3a000 ---p 00000000 00:00 0
>>> b6d3a000-b6d4a000 rwxp 00000000 00:00 0
>>> b6d4a000-b6e7d000 r-xp 00000000 08:00 3567 /lib/libc-2.18.so
>>> b6e7d000-b6e84000 ---p 00133000 08:00 3567 /lib/libc-2.18.so
>>> b6e84000-b6e86000 r-xp 00132000 08:00 3567 /lib/libc-2.18.so
>>> b6e86000-b6e87000 rwxp 00134000 08:00 3567 /lib/libc-2.18.so
>>> b6e87000-b6e8a000 rwxp 00000000 00:00 0
>>> b6e8a000-b6eab000 r-xp 00000000 08:00 543 /lib/libgcc_s.so.1
>>> b6eab000-b6eb2000 ---p 00021000 08:00 543 /lib/libgcc_s.so.1
>>> b6eb2000-b6eb3000 rwxp 00020000 08:00 543 /lib/libgcc_s.so.1
>>> b6eb3000-b6ec9000 r-xp 00000000 08:00 991 /lib/libpthread-2.18.so
>>> b6ec9000-b6ed0000 ---p 00016000 08:00 991 /lib/libpthread-2.18.so
>>> b6ed0000-b6ed1000 r-xp 00015000 08:00 991 /lib/libpthread-2.18.so
>>> b6ed1000-b6ed2000 rwxp 00016000 08:00 991 /lib/libpthread-2.18.so
>>> b6ed2000-b6ed4000 rwxp 00000000 00:00 0
>>> b6ed4000-b6ed8000 r-xp 00000000 08:00 209 /lib/libdl-2.18.so
>>> b6ed8000-b6edf000 ---p 00004000 08:00 209 /lib/libdl-2.18.so
>>> b6edf000-b6ee0000 r-xp 00003000 08:00 209 /lib/libdl-2.18.so
>>> b6ee0000-b6ee1000 rwxp 00004000 08:00 209 /lib/libdl-2.18.so
>>> b6ee1000-b6ee7000 r-xp 00000000 08:00 1327 /lib/librt-2.18.so
>>> b6ee7000-b6eee000 ---p 00006000 08:00 1327 /lib/librt-2.18.so
>>> b6eee000-b6eef000 r-xp 00005000 08:00 1327 /lib/librt-2.18.so
>>> b6eef000-b6ef0000 rwxp 00006000 08:00 1327 /lib/librt-2.18.so
>>> b6ef0000-b6f8d000 r-xp 00000000 08:00 207 /lib/libm-2.18.so
>>> b6f8d000-b6f95000 ---p 0009d000 08:00 207 /lib/libm-2.18.so
>>> b6f95000-b6f96000 r-xp 0009d000 08:00 207 /lib/libm-2.18.so
>>> b6f96000-b6f97000 rwxp 0009e000 08:00 207 /lib/libm-2.18.so
>>> b6f97000-b6fb7000 r-xp 00000000 08:00 2447 /lib/ld-2.18.so
>>> b6fb7000-b6fb8000 rwxp 00000000 00:00 0
>>> b6fb8000-b6fb9000 rwxs 00000000 00:0c 225 /dev/shm/mono.110
>>> b6fb9000-b6fba000 ---p 00000000 00:00 0
>>> b6fba000-b6fbb000 r-xp 00000000 00:00 0
>>> b6fbb000-b6fbe000 rwxp 00000000 00:00 0
>>> b6fbe000-b6fbf000 r-xp 0001f000 08:00 2447 /lib/ld-2.18.so
>>> b6fbf000-b6fc0000 rwxp 00020000 08:00 2447 /lib/ld-2.18.so
>>> bec63000-bec84000 rw-p 00000000 00:00 0 [stack]
>>> bee69000-bee6a000 r-xp 00000000 00:00 0 [sigpage]
>>> ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors]
>>>
>>> Native stacktrace:
>>>
>>>
>>> Debug info from gdb:
>>>
>>> mono_gdb_render_native_backtraces not supported on this platform,
>>> unable to find gdb or lldb
>>>
>>> =================================================================
>>> Got a SIGILL while executing native code. This usually indicates
>>> a fatal error in the mono runtime or one of the native libraries
>>> used by your application.
>>> =================================================================
>>>
>>> Aborted
>>>
>>>
>>> I've not followed too closely the latests development bits for mono 5
>>> and I'm asking you some advice to understand what's going on.
>>>
>>> Thank your for your time!
>>>
>>> --
>>> Profile: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fit.linkedin.com%2Fin%2Fcompagnucciangelo&data=02%7C01%7Cbeurba%40microsoft.com%7C45f4a2e117e24f05457c08d4a1d977cd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636311402805633277&sdata=5c%2B%2FVLvlqXKfMT%2FrWza5OzHG6rIOTizHCIx%2BNO5FPWc%3D&reserved=0
>>> _______________________________________________
>>> Mono-devel-list mailing list
>>> Mono-devel-list at lists.dot.net
>>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.dot.net%2Fmailman%2Flistinfo%2Fmono-devel-list&data=02%7C01%7Cbeurba%40microsoft.com%7C45f4a2e117e24f05457c08d4a1d977cd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636311402805633277&sdata=9BYjnZLHRW%2FzaNJWZ88dN%2BSfPka1fDh51ooKtzA2aGM%3D&reserved=0
>>
>>
>>
>> --
>> Profile: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fit.linkedin.com%2Fin%2Fcompagnucciangelo&data=02%7C01%7Cbeurba%40microsoft.com%7C843ac485cb334abb79e208d4a1f5db83%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636311524711368693&sdata=JscpGNCYRmwrNeRGtc7jza5ZRiLSC2Ll9YbpYn02hc8%3D&reserved=0
>
>
>
> --
> Profile: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fit.linkedin.com%2Fin%2Fcompagnucciangelo&data=02%7C01%7Cbeurba%40microsoft.com%7C25ae3075088c4b176de708d4a1f9c451%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636311541495053555&sdata=wYlpKZ7x0VxrFBN25TrRNW8OJt8%2FbwWMDPDvj6EaQSE%3D&reserved=0
--
Profile: http://it.linkedin.com/in/compagnucciangelo
More information about the Mono-devel-list
mailing list