Skip to content

Instantly share code, notes, and snippets.

Last active March 26, 2023 08:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trungnt2910/355b7e4486cbccf3c6c013981ca0d790 to your computer and use it in GitHub Desktop.
Save trungnt2910/355b7e4486cbccf3c6c013981ca0d790 to your computer and use it in GitHub Desktop.
Building .NET for Haiku

.NET cross-compilation instructions

This sets up a build environment using Haiku cross tools and a test environment using HyClone.

The guide assumes a clean Ubuntu 23.04 environment.

Install HyClone

git clone

# Haiku build deps
sudo apt install -y git nasm bc autoconf automake texinfo flex bison gawk build-essential unzip wget zip less zlib1g-dev libzstd-dev xorriso libtool python3

cd hyclone

# HyClone build
mkdir build; cd build
sudo apt install -y cmake libgmp-dev libmpfr-dev zlib1g-dev libzstd-dev
sudo make install

# Haiku rootfs setup
export HPREFIX=~/buildroot
./ \
  -S "haiku_devel" \
  -A "icu66_devel,krb5,krb5_devel,llvm12_libunwind,llvm12_libunwind_devel,openssl,openssl_devel,zlib,zlib_devel"

Test HyClone installation

export HPREFIX=~/buildroot
export HPATH=/boot/system/bin:/boot/system/non-packaged/bin
~/hyclone/build/bin/haiku_loader bash --login

A Haiku terminal session should appear.

Build .NET

.NET contains multiple components, only a few components work.

On a Linux terminal:

# if running on WSL1
export COMPlus_EnableWriteXorExecute=0

git clone
cd dotnet-runtime
# make the Haiku cross-compiler available
export PATH=$PATH:~/haiku/generated.x86_64/cross-tools-x86_64/bin
# make the Haiku sysroot available; libraries and headers will be in here
git checkout haiku-dotnet7
./ clr.runtime -arch x64 -os haiku -c debug -cross -gcc
./ mono.runtime -arch x64 -os haiku -c debug -cross -gcc
./ libs.native -arch x64 -os haiku -c debug -cross -gcc
./ host.native -arch x64 -os haiku -c debug -cross -gcc
./ clr.paltests -arch x64 -os haiku -c debug -cross -gcc

Run CoreCLR PAL tests

On a Haiku terminal session (powered by HyClone):

# Assuming you're already at /SystemRoot/home/<YOUR LINUX USER NAME>
cd dotnet-runtime
src/coreclr/pal/tests/palsuite/ artifacts/bin/coreclr/$(uname).x64.Debug/paltests

If you get something like this, then congratulations! image





Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment