Skip to content

Instantly share code, notes, and snippets.

@trungnt2910
Last active March 26, 2023 08:48
Show Gist options
  • 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 https://github.com/trungnt2910/hyclone

# 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
./copy_objects.sh

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

# Haiku rootfs setup
export HPREFIX=~/buildroot
./build_hprefix.sh \
  -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
# https://github.com/dotnet/runtime/issues/70799#issuecomment-1158427454
export COMPlus_EnableWriteXorExecute=0

git clone https://github.com/trungnt2910/dotnet-runtime
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
export ROOTFS_DIR=$HPREFIX
git checkout haiku-dotnet7
./build.sh clr.runtime -arch x64 -os haiku -c debug -cross -gcc
./build.sh mono.runtime -arch x64 -os haiku -c debug -cross -gcc
./build.sh libs.native -arch x64 -os haiku -c debug -cross -gcc
./build.sh host.native -arch x64 -os haiku -c debug -cross -gcc
./build.sh 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/runpaltests.sh artifacts/bin/coreclr/$(uname).x64.Debug/paltests

If you get something like this, then congratulations! image

image

image

image

image

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