[GSOC 2023] .NET Port

After more than 5 months, the previous pull request to dotnet/runtime has just been merged!

I’ve also opened a new PR, this one concerning native C/C++ code changes to the repo:

Haiku: Initial CoreCLR support by trungnt2910 · Pull Request #93907 · dotnet/runtime (github.com)

Weekly builds are still rolling, at least for one more month.

22 Likes

.NET 8 has just been released a few days ago.

Earlier today I have provided the latest weekly build for .NET 8 and .NET 9 with newly rebased code.
Release .NET 8 for Haiku x64 build 20231119.1 Release · trungnt2910/dotnet-builds (github.com)

Since I’m getting busier with other things, as planned, I will stop the weekly rebases. I will still keep the weekly builds running in case there are some breaking changes in the Haiku toolchain. However, the port will not be continuously rebased like in the past few months.

This is also a good time for anyone interested to create a recipe and package .NET 8 on HaikuPorts.

18 Likes

Hi @trungnt2910,
I’ve finally found some time to try dotnet on Haiku but I think the provided packages are broken or not aligned.
Specifically, I get an error installing the Haiku workload because

https://github.com/trungnt2910/dotnet-haiku/releases/download/0.1.0-dev.149/trungnt2910.net.sdk.haiku.manifest-9.0.100-alpha.1.0.1.0-dev.149.nupkg

can’t be found. It seems the workload is not up to date with the latest sdk?

1 Like

Yeah, the workload hasn’t been updated to be built with .NET 9.

Can you try it with .NET 8 packages instead?
Like the official dotnet-install.sh, my version at dotnet-builds supports a --channel argument.
So, to install .NET 8, you can run:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/trungnt2910/dotnet-builds/HEAD/dotnet-install.sh)" -- --install-dir /path/to/where/you/want/to/install/dotnet --channel 8.0

If you really need .NET 9 support, you will need to add the corresponding version band here:

and enable a .NET 9 build by running another command here, passing an additional argument: --runtime-version=9.0:

Thanks!
I’m ok with version 8, I’ll try that route and let you know.

My understanding is that the workload cannot be built on Haiku, is that correct?

Unfortunately, the workload does not exist for the corresponding latest SDk. The script looks for https://github.com/trungnt2910/dotnet-haiku/releases/download/0.1.0-dev.149/trungnt2910.net.sdk.haiku.manifest-8.0.101-servicing.23631.0.1.0-dev.149.nupkg.
Any thoughts?

There’s something wrong with the build number detection logic in the install-manifest.sh file in the dotnet-haiku repo.

8.0.101-whatever should have been compatible with 8.0.100.

It should be a quick fix, I’ll try to do it when I have time…

It’s not entirely impossible to build this on Haiku. What you need to do is to port the native components of CppSharp to Haiku. The changes should mostly be build-system related, as most of the code is just invoking LLVM libraries, and we already have a LLVM port on Haiku.

I’ve pushed some fixes to this issue. A few minutes after the time of writing, new packages should have been built, along with a new install-manifest.sh script.

I’ve attempted at adding net9 support, but currently this is impossible, as workload packages are currently not versioned based on runtime numbers. Therefore, trying to build net9 alongside net8 would overwrite existing packages with net9 libraries, unless further changes are made to the build system.

2 Likes

the workload has been installed correctly but I now have an issue with creating a new application of type Haiku Application (dotnet new haiku).

dotnet run
/boot/home/workspace/dotnet/haiku/haiku.csproj : error NU1102: Unable to find package Microsoft.AspNetCore.App.Ref with version (= 8.0.0-rtm.23502.22)
/boot/home/workspace/dotnet/haiku/haiku.csproj : error NU1102:   - Found 95 version(s) in nuget.org [ Nearest version: 8.0.0 ]
/boot/home/workspace/dotnet/haiku/haiku.csproj : error NU1102:   - Found 0 version(s) in dotnet_haiku_nuget

The build failed. Fix the build errors and run again.

Apparently AspNetCore is a hard coded dependency. This also happens with other templates like “console”.
Am I missing something?

The way .NET SDK builds work is that it copies the existing SDK and updates a few files.
The existing SDK fetched by the CI script is some beta one used by the .NET team, and therefore is bundled with beta packages.

A proper, complete build script should replace these versions with the ones that are actually shipped:

My dotnet-builds repo also simulates this:

However, since we do not ship ASP.NET Core, the beta version in the development SDK is left unchanged. This causes problems when the SDK on Haiku tries to load framework packages during the first build.

Adding Microsoft’s beta feeds for .NET 8 might resolve this issue:

dotnet nuget add source --name dotnet8 "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json"

If this does fix the problem, let me know so that I could update the corresponding instructions.

Hi @trungnt2910,
that seemed to solve the dependency issue and the application can be built correctly but an error occurs at runtime:

Unhandled exception. System.TypeLoadException: Could not load type 'Haiku.App.BApplication' from assembly 'haiku, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Abort
Kill Thread

Here’s the crash report:

Debug information for team /boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/haiku (3150):
CPU(s): 8x Intel Core™ i7-8650U
Memory: 23.88 GiB total, 1.78 GiB used
Haiku revision: hrev57465 Dec 19 2023 07:03:08 (x86_64)

Active Threads:
	thread 3151: pthread func 
	thread 3152: pthread func 
	thread 3153: pthread func 
	thread 3154: pthread func 
	thread 3155: pthread func 
	thread 3157: team 3150 debug task 
	thread 3150: haiku (main)
		state: Call (abort() called)

		Frame		IP			Function Name
		-----------------------------------------------
		00000000	0x19c4a30e0a7	_kern_debugger + 0x7 
			Disassembly:
				_kern_debugger:
				0x0000019c4a30e0a0:   48c7c0e9000000  mov $0xe9, %rax
				0x0000019c4a30e0a7:             0f05  syscall  <--

		0x7ff51615eb60	0x19c4a305b55	abort + 0x4a 
		0x7ff51615eb70	0x185178cd11c	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libcoreclr.so + 0x59311c 
		0x7ff51615eb90	0x185178cd492	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libcoreclr.so + 0x593492 
		0x7ff51615ecc0	0x185173a09ed	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libcoreclr.so + 0x669ed 
		0x7ff51615ed20	0x185173f8d00	coreclr_execute_assembly + 0xc0 
		0x7ff51615ee00	0x115c0655353	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libhostpolicy.so + 0x30353 
		0x7ff51615eeb0	0x115c0655c47	corehost_main + 0x177 
		0x7ff51615efe0	0x2d53b4355f	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libhostfxr.so + 0x1b55f 
		0x7ff51615f100	0x2d53b4417a	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libhostfxr.so + 0x1c17a 
		0x7ff51615f190	0x2d53b37ecb	hostfxr_main_startupinfo + 0x9b 
		0x7ff51615f270	0x14b2a87fea9	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/haiku + 0xeea9 
		0x7ff51615f2d0	0x14b2a874b6e	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/haiku + 0x3b6e 
		0x7ff51615f300	0x14b2a874d3e	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/haiku + 0x3d3e 
		0x7ff51615f340	0x1af42fefab3	runtime_loader + 0x113 
		00000000	0x7fff3176b258	commpage_thread_exit + 0 

		Registers:
			  rip:	0x0000019c4a30e0a9
			  rsp:	0x00007ff51615eb28
			  rbp:	0x00007ff51615eb50
			  rax:	0x00000000000000e9
			  rbx:	0x0000000000000006
			  rcx:	0x0000019c4a30e0a9
			  rdx:	0x00007ff51615e62f
			  rsi:	0x0000019c4a3a406f
			  rdi:	0x0000019c4a3a5a08
			   r8:	0x0000000000000000
			   r9:	0x0000000000000000
			  r10:	0x0000000000000000
			  r11:	0x0000000000000206
			  r12:	0x0000000000000000
			  r13:	0x0000000000000000
			  r14:	0x00001097333afd90
			  r15:	0x0000000000000000
			   cs:	0x002b
			   ds:	0x0000
			   es:	0x0000
			   fs:	0x0000
			   gs:	0x0000
			   ss:	0x0023
			  st0:	0
			  st1:	0
			  st2:	0
			  st3:	0
			  st4:	0
			  st5:	0
			  st6:	0
			  st7:	0
			  mm0:	{0, 0, 0, 0}
			  mm1:	{0, 0, 0, 0}
			  mm2:	{0, 0, 0, 0}
			  mm3:	{0, 0, 0, 0}
			  mm4:	{0, 0, 0, 0}
			  mm5:	{0, 0, 0, 0}
			  mm6:	{0, 0, 0, 0}
			  mm7:	{0, 0, 0, 0}
			 ymm0:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm1:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm2:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm3:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm4:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm5:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm6:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm7:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm8:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			 ymm9:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			ymm10:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			ymm11:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			ymm12:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			ymm13:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			ymm14:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
			ymm15:	{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Loaded Images:
	ID		Text Base	Text End	Data Base	Data End	Type	Name
	--------------------------------------------------------------------------------
	12817	0x29bf149000	0x29bf160000	0x29bf160000	0x29bf161000	lib    	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libSystem.Native.so
	12810	0x2d53b28000	0x2d53b87000	0x2d53b87000	0x2d53b88000	lib    	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libhostfxr.so
	12820	0x677b7a6000	0x677badf000	0x677badf000	0x677bafa000	lib    	/boot/system/lib/libicui18n.so.73.2
	12819	0x68cda39000	0x68cda3a000	0x68cda3a000	0x68cda3b000	lib    	/boot/system/lib/libicudata.so.73.2
	12818	0xacd0156000	0xacd034a000	0xacd034a000	0xacd0362000	lib    	/boot/system/lib/libicuuc.so.73.2
	12816	0xb6d7ed4000	0xb6d81e2000	0xb6d81e2000	0xb6d8232000	lib    	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libclrjit.so
	12813	0xe292747000	0xe29279a000	0xe29299a000	0xe2929a3000	lib    	/boot/system/non-packaged/lib/libnetwork.so
	12807	0xf2a6aad000	0xf2a6ce0000	0xf2a6ce0000	0xf2a6cf6000	lib    	/boot/system/lib/libstdc++.so.6.0.32
	12811	0x115c0625000	0x115c0689000	0x115c0689000	0x115c068a000	lib    	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libhostpolicy.so
	12809	0x130d28a3000	0x130d28c2000	0x130d28c2000	0x130d28c3000	lib    	/boot/system/lib/libgcc_s.so.1
	12806	0x14b2a871000	0x14b2a88b000	0x14b2a88b000	0x14b2a88c000	app    	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/haiku
	12812	0x1851733a000	0x18517a07000	0x18517a07000	0x18517a8c000	lib    	/boot/home/workspace/dotnet/haiku/bin/Debug/net8.0-haiku/haiku-x64/libcoreclr.so
	12808	0x19c4a2ce000	0x19c4a3de000	0x19c4a3de000	0x19c4a3f4000	lib    	/boot/system/lib/libroot.so
	12805	0x1af42fe0000	0x1af42ffd000	0x1af42ffd000	0x1af42ffe000	lib    	/boot/system/runtime_loader
	12815	0x207dd783000	0x207dd797000	0x207dd797000	0x207dd798000	lib    	/boot/system/lib/libunwind.so.1.0
	12814	0x25eb3663000	0x25eb366e000	0x25eb366e000	0x25eb366f000	lib    	/boot/system/lib/libbsd.so
	12804	0x7fff3176b000	0x7fff31773000	0x00000000	0x00000000	system 	commpage

Areas:
	ID		Base		End			Size (KiB)	Protection	Locking			Name
	--------------------------------------------------------------------------------
	35157	0x29bf149000	0x29bf160000	        92	r-x        	none          	libSystem.Native.so_seg0ro
	35158	0x29bf160000	0x29bf161000	         4	rw-        	none          	libSystem.Native.so_seg1rw
	35109	0x2d53b28000	0x2d53b87000	       380	r-x        	none          	libhostfxr.so_seg0ro
	35110	0x2d53b87000	0x2d53b88000	         4	rw-        	none          	libhostfxr.so_seg1rw
	35095	0x535c9b0000	0x535c9c0000	        64	rw-        	none          	rld heap
	35096	0x5690165000	0x5690166000	         4	rw-cS      	none          	_rld_debug_
	35168	0x677b7a6000	0x677badf000	      3300	r-x        	none          	libicui18n.so.73.2_seg0ro
	35169	0x677badf000	0x677baf9000	       104	rw-        	none          	libicui18n.so.73.2_seg1rw
	35170	0x677baf9000	0x677bafa000	         4	rw-        	none          	libicui18n.so.73.2_seg2rw
	35166	0x68cda39000	0x68cda3a000	         4	r-x        	none          	libicudata.so.73.2_seg0ro
	35167	0x68cda3a000	0x68cda3b000	         4	rw-        	none          	libicudata.so.73.2_seg1rw
	35107	0x68e0d95000	0x68e0da5000	        64	rw-        	none          	rld heap
	35126	0x913bd88000	0x913bd8e000	        24	rw-        	none          	libcoreclr.so mmap area
	35163	0xacd0156000	0xacd034a000	      2000	r-x        	none          	libicuuc.so.73.2_seg0ro
	35164	0xacd034a000	0xacd0361000	        92	rw-        	none          	libicuuc.so.73.2_seg1rw
	35165	0xacd0361000	0xacd0362000	         4	rw-        	none          	libicuuc.so.73.2_seg2rw
	35127	0xae3146c000	0xae31475000	        36	rw-        	none          	libcoreclr.so mmap area
	35149	0xb6d7ed4000	0xb6d81e2000	      3128	r-x        	none          	libclrjit.so_seg0ro
	35150	0xb6d81e2000	0xb6d81fb000	       100	rw-        	none          	libclrjit.so_seg1rw
	35151	0xb6d81fb000	0xb6d8232000	       220	rw-        	none          	libclrjit.so_seg2rw
	35128	0xd901051000	0xd901052000	         4	rw-        	none          	libcoreclr.so mmap area
	35131	0xda15526000	0xda1552c000	        24	rw-        	none          	libcoreclr.so mmap area
	35132	0xe15fdd8000	0xe15fdd9000	         4	rw-        	none          	libcoreclr.so mmap area
	35133	0xe26abb0000	0xe26abc0000	        64	           	none          	libcoreclr.so mmap area
	35136	0xe275468000	0xe27546e000	        24	rw-        	none          	libcoreclr.so mmap area
	35139	0xe278ade000	0xe278ae4000	        24	rw-        	none          	libcoreclr.so mmap area
	35116	0xe292747000	0xe29279a000	       332	r-x        	none          	libnetwork.so_seg0ro
	35117	0xe29299a000	0xe29299d000	        12	rw-        	none          	libnetwork.so_seg1rw
	35118	0xe29299d000	0xe2929a3000	        24	rw-        	none          	libnetwork.so_seg2rw
	35099	0xf2a6aad000	0xf2a6ce0000	      2252	r-x        	none          	libstdc++.so.6.0.32_seg0ro
	35100	0xf2a6ce0000	0xf2a6cee000	        56	rw-        	none          	libstdc++.so.6.0.32_seg1rw
	35101	0xf2a6cee000	0xf2a6cf6000	        32	rw-        	none          	libstdc++.so.6.0.32_seg2rw
	35111	0x115c0625000	0x115c0689000	       400	r-x        	none          	libhostpolicy.so_seg0ro
	35112	0x115c0689000	0x115c068a000	         4	rw-        	none          	libhostpolicy.so_seg1rw
	35105	0x130d28a3000	0x130d28c2000	       124	r-x        	none          	libgcc_s.so.1_seg0ro
	35106	0x130d28c2000	0x130d28c3000	         4	rw-        	none          	libgcc_s.so.1_seg1rw
	35097	0x14b2a871000	0x14b2a88b000	       104	r-x        	none          	haiku_seg0ro
	35098	0x14b2a88b000	0x14b2a88c000	         4	rw-        	none          	haiku_seg1rw
	35123	0x1849834a000	0x184983b0000	       408	           	none          	libcoreclr.so mmap area
	35148	0x184983b2000	0x18498a60000	      6840	           	none          	libcoreclr.so mmap area
	35161	0x18498a62000	0x1851733a000	   2073440	           	none          	libcoreclr.so mmap area
	35113	0x1851733a000	0x18517a07000	      6964	r-x        	none          	libcoreclr.so_seg0ro
	35114	0x18517a07000	0x18517a40000	       228	rw-        	none          	libcoreclr.so_seg1rw
	35115	0x18517a40000	0x18517a8c000	       304	rw-        	none          	libcoreclr.so_seg2rw
	35102	0x19c4a2ce000	0x19c4a3de000	      1088	r-x        	none          	libroot.so_seg0ro
	35103	0x19c4a3de000	0x19c4a3ec000	        56	rw-        	none          	libroot.so_seg1rw
	35104	0x19c4a3ec000	0x19c4a3f4000	        32	rw-        	none          	libroot.so_seg2rw
	35093	0x1af42fe0000	0x1af42ffd000	       116	r-x        	none          	runtime_loader_seg0ro
	35094	0x1af42ffd000	0x1af42ffe000	         4	rw-        	none          	runtime_loader_seg1rw
	35140	0x1c4ab3f0000	0x204ab3f0000	 268435456	           	none          	libcoreclr.so mmap area
	35141	0x20557dbb000	0x205ec8e2000	   2436252	           	none          	libcoreclr.so mmap area
	35145	0x2072e530000	0x2072e536000	        24	rw-        	none          	libcoreclr.so mmap area
	35146	0x2076ea14000	0x2076ee65000	      4420	r--S       	none          	libcoreclr.so mmap area
	35152	0x207c2dc4000	0x207c31c4000	      4096	           	none          	libcoreclr.so mmap area
	35153	0x207d598a000	0x207d599a000	        64	rw-        	none          	libcoreclr.so mmap area
	35159	0x207dca1f000	0x207dca21000	         8	r--S       	none          	libcoreclr.so mmap area
	35162	0x207dcf16000	0x207dcf1f000	        36	r--S       	none          	libcoreclr.so mmap area
	35171	0x207dcf7f000	0x207dcf97000	        96	rw-        	none          	rld heap
	35172	0x207dd3fb000	0x207dd413000	        96	rw-        	none          	rld heap
	35121	0x207dd783000	0x207dd797000	        80	r-x        	none          	libunwind.so.1.0_seg0ro
	35122	0x207dd797000	0x207dd798000	         4	rw-        	none          	libunwind.so.1.0_seg1rw
	35173	0x24de71fd000	0x24de9089000	     31280	r--S       	none          	libicuuc.so.73 mmap area
	35119	0x25eb3663000	0x25eb366e000	        44	r-x        	none          	libbsd.so_seg0ro
	35120	0x25eb366e000	0x25eb366f000	         4	rw-        	none          	libbsd.so_seg1rw
	35108	0x109733314000	0x1097336b4000	      3712	rw-        	none          	heap
	35135	0x7f2759d15000	0x7f2759d5a000	       276	rw-s       	none          	pthread func_3153_stack
	35130	0x7f3aea4a7000	0x7f3aea4ec000	       276	rw-s       	none          	pthread func_3152_stack
	35125	0x7f86f626e000	0x7f86f62b3000	       276	rw-s       	none          	pthread func_3151_stack
	35090	0x7fa005ad3000	0x7fa005ad7000	        16	rw-k       	full          	user area
	35144	0x7fda98ac7000	0x7fda98b0c000	       276	rw-s       	none          	pthread func_3155_stack
	35138	0x7fe7ad509000	0x7fe7ad54e000	       276	rw-s       	none          	pthread func_3154_stack
	35091	0x7ff51515c000	0x7ff516162000	     16408	rw-s       	none          	haiku_3150_stack
	35092	0x7fff3176b000	0x7fff31773000	        32	r-xSk      	full          	commpage

Protection Flags: r - read, w - write, x - execute, s - stack, o - overcommit, c - cloneable, S - shared, k - kernel

Semaphores:
	ID		Count	Last Holder	Name
	------------------------------------------------------------

I think it would be better to open an issue on GitHub, in which repo do you want me to open it?

dotnet-haiku, since it is specifically related to the workload.

If this issue is also present in pure old .NET console apps, then trungnt2910/dotnet-builds or trungnt2910/dotnet-runtime might be better places.

Sadly, a crash report like that would not help much with a managed .NET exception.

After continuing on GitHub, can you please attach a .zip file containing your application project, including the generated bin and obj folder?

My two theories are:

  • The workload correctly included reference libraries, but somehow messed up the runtime parts, making them not present when the application is run, or
  • The binding generators somehow failed to detect BApplication due to recent changes in Haiku headers.

I have reinstalled the latest build and the workload. Now a template console app runs but the haiku app fails with the very same error as before.
Installing 8.0 on top of a broken 9.0 was not a good idea, after all. It’s now the turn of your second theory, then.
As per your request, I’ve opened an issue here.

Actually, after installing the haiku workload the console application executable helloworld does not run anymore. It fails with the error:

You must install .NET to run this application.

App: /boot/home/workspace/dotnet/helloworld/bin/Debug/net8.0/helloworld
Architecture: x64
App host version: 8.0.1
.NET location: Not found

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=haiku-x64&os=haiku.1&apphost_version=8.0.1

Via dotnet run it works as already stated.

I’ve never tested with running the executable before. It probably has some issues with finding the system .NET installation, since 1. You are installing it to a non-standard directory and 2. Haiku does not follow UNIX directory conventions anyway.

If you really need to run something using the executable, a self-contained deployment might work, but it would take hundreds of megabytes for a single application.

A dotnet executable relies on the env variable DOTNET_ROOT to locate the runtime.

export DOTNET_ROOT=/boot/system/non-packaged/bin/dotnet

or whatever the path is, worked for me.
I was under the impression that it worked before installing the Haiku workload but I need to reinstall everything from scratch to check.

If it’s not exported by default, I’d suggest to add this to the installation script.

54 posts were split to a new topic: .NET bindings to the Haiku API

Latest builds are failing with this error:

  [  7%] Building CXX object inc/CMakeFiles/corguids.dir/__/pal/prebuilt/idl/cordebug_i.cpp.o
  In file included from /home/runner/work/dotnet-builds/dotnet-builds/runtime/src/coreclr/pal/inc/rt/palrt.h:630,
                   from /home/runner/work/dotnet-builds/dotnet-builds/runtime/src/coreclr/pal/inc/rt/rpc.h:15,
                   from /home/runner/work/dotnet-builds/dotnet-builds/runtime/src/coreclr/pal/prebuilt/idl/cordebug_i.cpp:29:
  /home/runner/work/dotnet-builds/dotnet-builds/runtime/src/coreclr/pal/inc/rt/safecrt.h:1093:16: error: conflicting declaration of C function 'size_t wcsnlen(const WCHAR*, size_t)'
   1093 | size_t __cdecl wcsnlen(const WCHAR *inString, size_t inMaxSize);
        |                ^~~~~~~
  In file included from /home/runner/work/dotnet-builds/dotnet-builds/dotnet-rootfs/boot/system/develop/headers/posix/wctype.h:10,
                   from /home/runner/work/dotnet-builds/dotnet-builds/runtime/src/coreclr/pal/inc/pal.h:51,
                   from /home/runner/work/dotnet-builds/dotnet-builds/runtime/src/coreclr/pal/inc/rt/palrt.h:136:
  /home/runner/work/dotnet-builds/dotnet-builds/dotnet-rootfs/boot/system/develop/headers/posix/wchar.h:122:17: note: previous declaration 'size_t wcsnlen(const wchar_t*, size_t)'
    122 | extern size_t   wcsnlen(const wchar_t *wcs, size_t maxLength);
        |                 ^~~~~~~
  /home/runner/work/dotnet-builds/dotnet-builds/runtime/src/coreclr/pal/inc/rt/safecrt.h:1098:16: error: conflicting declaration of C function 'size_t wcsnlen(const WCHAR*, size_t)'
   1098 | size_t __cdecl wcsnlen(const WCHAR *inString, size_t inMaxSize)
        |                ^~~~~~~
  /home/runner/work/dotnet-builds/dotnet-builds/dotnet-rootfs/boot/system/develop/headers/posix/wchar.h:122:17: note: previous declaration 'size_t wcsnlen(const wchar_t*, size_t)'
    122 | extern size_t   wcsnlen(const wchar_t *wcs, size_t maxLength);
        |                 ^~~~~~~
  make[2]: *** [inc/CMakeFiles/corguids.dir/build.make:76: inc/CMakeFiles/corguids.dir/__/pal/prebuilt/idl/cordebug_i.cpp.o] Error 1
  make[1]: *** [CMakeFiles/Makefile2:3250: inc/CMakeFiles/corguids.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....

Seems like whoever included wctype.h did not expect wchar.h to be included as well.

This is the minimally reproducible example of the issue:

#include <stdint.h>
#include <stddef.h>
#include <wctype.h>

extern "C"
{
typedef char16_t WCHAR;
#define __cdecl

size_t __cdecl wcsnlen(const WCHAR *inString, size_t inMaxSize)
{
    size_t n;

    /* Note that we do not check if s == nullptr, because we do not
     * return errno_t...
     */

    for (n = 0; n < inMaxSize && *inString; n++, inString++)
        ;

    return n;
}


}

int main()
{
    auto x = L"Test";
    return wcsnlen((const WCHAR*)x, 3) - 3;
}

Compiling on Linux and Haiku gives different results:

trung@DESKTOP-5OCA2N2:~$ g++ test.cpp -o test
trung@DESKTOP-5OCA2N2:~$ haiku_loader g++ test.cpp -o test
test.cpp:49:16: error: conflicting declaration of C function 'size_t wcsnlen(const WCHAR*, size_t)'
   49 | size_t __cdecl wcsnlen(const WCHAR *inString, size_t inMaxSize)
      |                ^~~~~~~
In file included from /boot/system/develop/headers/posix/wctype.h:10,
                 from test.cpp:42:
/boot/system/develop/headers/posix/wchar.h:122:17: note: previous declaration 'size_t wcsnlen(const wchar_t*, size_t)'
  122 | extern size_t   wcsnlen(const wchar_t *wcs, size_t maxLength);
      |                 ^~~~~~~
test.cpp: In function 'int main()':
test.cpp:69:20: error: cannot convert 'const WCHAR*' {aka 'const char16_t*'} to 'const wchar_t*'
   69 |     return wcsnlen((const WCHAR*)x, 3) - 3;
      |                    ^~~~~~~~~~~~~~~
      |                    |
      |                    const WCHAR* {aka const char16_t*}
/boot/system/develop/headers/posix/wchar.h:122:40: note:   initializing argument 1 of 'size_t wcsnlen(const wchar_t*, size_t)'
  122 | extern size_t   wcsnlen(const wchar_t *wcs, size_t maxLength);
      |                         ~~~~~~~~~~~~~~~^~~
trung@DESKTOP-5OCA2N2:~$