How to build Mono on Solaris

From Genunix

Jump to: navigation, search

1 What is Mono?

Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. Sponsored by Novell, the Mono open source project has an active and enthusiastic contributing community . Its homepage is http://www.mono-project.com/Main_Page.

2 Components for Mono

  • mono: C# compiler, runtime environment etc.
  • libgdiplus: GDI+ drawing api implementation for Mono's System.Drawing.
  • xsp: Standalone web server written in C# that can be used to run your ASP.NET applications.
  • mod_mono: An Apache 1.3/2.0/2.2 module that provides ASP.NET support for Apache.
  • gtk-sharp-1.0.10: GTK1 c# binds.
  • gtk-sharp-2.4.2: GTK2(2.4) c# binds.
  • gtk-sharp-2.8.2: GTK2(2.8) c# binds.

There are other components, such as development tools. For more information please refer to its homepage.

3 Where to download

You can download Mono and component packages from page http://www.mono-project.com/Downloads.

4 Tools to build Mono

  • GNU tar to unpack the sources, as Solaris tar has problems unpacking Mono.
  • GNU build tools, such as gcc, gld, gas etc.
Notes:
  • GCC installed in the /usr/sfw/ works fine. although gld, gas etc are not included, it seems it's ok.
  • Because make included in CBE is GNU make, so it should be ok.

5 Build instructions

libgdiplus(1.1.13.6)

libgdiplus is optional, but if you need GDI+ drawing api support for Mono, you should build it.

On Sparc,

   configure, gmake, gmake check, gmake install

is ok.

On x86, you need to change the source code according to http://mail-index.netbsd.org/pkgsrc-bugs/2005/10/18/0013.html, because there are some problem when building included cairo.

Mono(1.1.13.8)

If you set your build environment properly, the build process of Mono is straight forward.

On Sparc, just

   configure, gmake, gmake check, gmake install

is ok. And when you do "gmake check", all check should passed(My test result:193 test(s) passed. 0 test(s) did not pass.), but the check process would fail after the test if you are not using gas.

On x86, you need add "--with-tls=pthread" when you do configure to avoid error

   In file included from /usr/include/link.h:35,
                    from dyn_load.c:71:
   /usr/include/libelf.h:45:2: #error "large files are not supported by libelf"
   *** Error code 1
   make: Fatal error: Command failed for target `dyn_load.lo'. 

and

   Undefined                       first referenced
    symbol                             in file
   GC_local_malloc                     ./.libs/libmonoruntime.a(reflection.o)
   GC_local_malloc_atomic              ./.libs/libmonoruntime.a(object.o)
   GC_local_gcj_fast_malloc            ./.libs/libmonoruntime.a(object.o)
   GC_local_gcj_malloc                 ./.libs/libmonoruntime.a(object.o)
   ld: fatal: Symbol referencing errors. No output written to pedump

you also need to make some modification of the source code. Here is the patch for mono

When you do "gmake check", it always fails at:

   Test run: image=[path_to_mono_source]/mono/mini/exceptions.exe, opts=

I just ignored it.

After you have installed mono, remember to add [dist_dir]/lib/pkgconfig to your $PKG_CONFIG_PATH to make sure all the packages depend on Mono can find it.


6 Applications

I tested two applications on both Solaris x86 and Solaris Sparc, F-Spot and Beagle.

F-Spot(0.1.11)

F-Spot is a full-featured personal photo management application for the GNOME desktop. It supports 16 common file types, including JPEG, GIF, TIFF, RAW. You can import your photos from a direcory ,or from your hard drive, such as camera (including PTP type) and iPod, with F-Spot. F-Spot can also view and export EXIF and XMP metadata in your images.

F-Spot requires:

  • GNOME development libraries, 2.4 or later
  • libgphoto2, 2.1.4 or later
  • libexif, 0.5.1 or later
  • Mono, 0.28 or later
  • dbus (for mono binds)
  • gtk-sharp
  • Sqlite, 2.8.6 or later
  • liblcms, 0.12 or later

GNOME development libraries, libexif and libgphoto2 is included in Solaris Nevada.

In my example, I built gtk-sharp(2.8.2), dbus(0.62), sqlite(3.3.6) and liblcms(1.15). Most of the process is straight forward, only

   ./configure --prefix=[dist_dir]; gmake; gmake check; gmake install

is needed. And only a few problems need to be noticed.

When building dbus you must use

   ./configure --prefix=[dist_dir] --enable-mono

to enable mono binds. And I changed mono/Makefile.in, mono/Makfile.am, mono/example/Makefile.in and mono/example/Makefile.am to make it use gtk-sharp-2.0 instead of gtk1-sharp, so I need not build it.

When building F-Spot, you need to install GNU gettext and

   export XGETTEXT=[path_to_gnu_xgettext]/xgettext
   export INTLTOOL_XGETTEXT=[path_to_gnu_xgettext]/xgettext

before you do configure, or else "gmake check" would fail becase system default xgettext is not compatible with F-Spot. And you should delete the code which calls prctl(used to set process's name) in the source code(in src/main.cs), because prctl is not supported on Solaris(Maybe we can use setrctl to replace it).

After the installation, you should edit [dest_dir]/bin/f-sport and change #!/bin/sh to #!/bin/bash.

On both x86 and Sparc, F-Spot can run and GUI works fine.But every time I want to import a directory it crashes on Sparc. On x86 it is more stable with a few crashes.

Beagle(0.2.5)

Beagle is a search tool that ransacks your personal information space to find whatever you're looking for. Beagle can search in many different domains. Using Beagle, you can easily find:

  • documents
  • emails
  • web history
  • IM/IRC conversations
  • source code
  • images
  • music/video files
  • applications

Beagle requires a lot of packages too. But if you build F-Sport first you need only build gmime before build Beagle.

When building gmime, you must use

   ./configure --prefix=[dist_dir] --enable-mono

to enable mono binds. You also need to edit the source file of gmime. Here is the patch for gmime.

When you build Beagle, you need to edit the configure file to add surpport for Solaris and modify source files. Here is the patch for beagle.

After apply the patch, you can configure, gmake, gmake check and gmake install.

Before run beagle daemon, you need to

   export BEAGLE_EXERCISE_THE_DOG=1

Then run beagled --bg. After indexes are built, you can run beagle-search(GUI) or beagle-query(command line) to search.

On x86, beagle works pretty good.

On Sparc, Beagle can not run becasue of SIGSEGV while executing native code.

Notes:
  • Beagle would produce very large log file in %HOME/.beagle on Solaris, so you can delete them to save disk space.

7 Problem need to be noticed when build mono with SUN Studio

Forte is not supported by Mono right now, so if you want to build Mono with it you need to notie:

  • Compiler predfined macros must be changed. For examle, change
   #ifdef (__i386__)

to

   #if defined(__i386__) || defined(__i386)
  • Inline assembly formation must be changed to SUN compiler compatible formation. For example, change
   int have_cpuid = 0;
   __asm__  __volatile__ (
              "pushfl\n"
              "popl %%eax\n"
              "movl %%eax, %%edx\n"
              "xorl $0x200000, %%eax\n"
              "pushl %%eax\n"
              "popfl\n"
              "pushfl\n"
              "popl %%eax\n"
              "xorl %%edx, %%eax\n"
              "andl $0x200000, %%eax\n"
              "movl %%eax, %0"
              : "=r" (have_cpuid)
              :
              : "%eax", "%edx"
      );

to

   int have_cpuid = 0;
   __asm ("\n\
           pushfl\n\
           popl %eax\n\
           movl %eax, %edx\n\
           xorl $0x200000, %eax\n\
           push %eax\n\
           popfl\n\
           pushfl\n\
           popl %eax\n\
           xorl %edx, %eax\n\
           andl $0x200000, %eax\n\
           movl %eax, -8(%ebp)\n");

Question: Must I use ebp(esp) and offset to reference have_cpuid?

  • __builtin_frame_address must be supported.
  • etc.


8 Usefull resources

Personal tools