Ubuntu 18.04 で mono + llvm をmakeしてみる


Ubuntu 18.04 で mono + llvm をmakeしてみる

目的

Ubuntu 18.04 Ubuntu 18.04 に mono + llvm をsrcからmake & installしてみる

コンパイル用のパッケージを追加する


$ sudo apt install gcc
$ sudo apt install gcc-7-locales gcc-multilib make autoconf automake libtool
  flex bison gcc-doc gcc-7-multilib gcc-7-doc libgcc1-dbg libgomp1-dbglibitm1-dbg
  libatomic1-dbg libasan4-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg
  libmpx2-dbg libquadmath0-dbg glibc-doc
$ sudo apt install cmake
$ sudo apt install cmake-doc ninja-build
$ sudo apt install build-essential

ソースをダウンロードする


$ git clone git://github.com/mono/llvm.git
$ git clone --recursive [email protected]:mono/mono

LLVMのコンパイル用のdirを作成後コンパイルする


$ mkdir build
$ cd build
$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE ../llvm
$ make
$ sudo make install

monoをコンパイルする


$ cd mono
$ ./autogen.sh --with-sgen=yes --enable-llvm --with-wasm=yes --with-winaot=yes
$ make
$ sudo make install

$ mono -V
Mono JIT compiler version 6.13.0 
Copyright (C) Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          yes(610)
        Suspend:       hybrid
        GC:            sgen (concurrent by default)

テストコード

using System;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        Console.WriteLine ("Hello World!");
    }
}

$ csc hello.cs
$ mono hello.exe
Hello World!

参考にしたのは以下のサイト

mono/mono
Mono LLVM
Building LLVM with CMake