[Mono-dev] Crosscompiling Mono 5.0.0.100

Bernhard Urban beurba at microsoft.com
Tue May 23 17:54:55 UTC 2017


 >      Host:          arm-buildroot-linux-gnueabi
 >      Target:        arm-buildroot-linux-gnueabi

so... you aren't actually cross-compiling, am I right?  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.

-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


More information about the Mono-devel-list mailing list