Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<MonoAOTCrossCompilerSupported Condition="'$(_MonoAotCrossSupportedOS)' == 'true' and '$(_MonoAotCrossSupportedArch)' == 'true'">true</MonoAOTCrossCompilerSupported>

<!-- Determine if the NativeAOT runtime can run on the specified target. -->
<_NativeAotSupportedOS Condition="'$(TargetOS)' != 'browser' and '$(TargetOS)' != 'haiku' and '$(TargetOS)' != 'illumos' and '$(TargetOS)' != 'netbsd' and '$(TargetOS)' != 'solaris'">true</_NativeAotSupportedOS>
<_NativeAotSupportedOS Condition="'$(TargetOS)' != 'browser' and '$(TargetOS)' != 'illumos' and '$(TargetOS)' != 'netbsd' and '$(TargetOS)' != 'solaris'">true</_NativeAotSupportedOS>
<_NativeAotSupportedArch Condition="'$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'loongarch64' or '$(TargetArchitecture)' == 'riscv64' or ('$(TargetOS)' == 'windows' and '$(TargetArchitecture)' == 'x86')">true</_NativeAotSupportedArch>
<NativeAotSupported Condition="'$(_NativeAotSupportedOS)' == 'true' and '$(_NativeAotSupportedArch)' == 'true'">true</NativeAotSupported>

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<CrossgenTargetName>InvokeCrossgen2</CrossgenTargetName>

<PublishReadyToRun>true</PublishReadyToRun>
<!-- Disable crossgen on NetBSD, illumos, Solaris and Haiku for now. This can be revisited when we have full support. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</PublishReadyToRun>
<!-- Disable crossgen on NetBSD, illumos, and Solaris for now. This can be revisited when we have full support. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris'">false</PublishReadyToRun>
<!-- TODO-WASM: we will have WASM R2R after https://github.com/dotnet/runtime/issues/121257 -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'browser' or '$(TargetOS)' == 'wasi'">false</PublishReadyToRun>

Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/inc/pedecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ inline CHECK CheckOverflow(RVA value1, COUNT_T value2)
#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0x1993
#elif defined(__sun)
#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0x1992
#elif defined(__HAIKU__)
#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0x0B05
#else
#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<TargetTriple Condition="'$(CrossCompileArch)' != '' and '$(_IsAlpineExitCode)' != '0'">$(CrossCompileArch)-linux-$(CrossCompileAbi)</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' != '' and '$(_IsAlpineExitCode)' == '0'">$(CrossCompileArch)-alpine-linux-$(CrossCompileAbi)</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('freebsd')))">$(CrossCompileArch)-unknown-freebsd12</TargetTriple>
<TargetTriple Condition="'$(CrossCompileArch)' != '' and ($(CrossCompileRid.StartsWith('haiku')))">$(CrossCompileArch)-unknown-haiku</TargetTriple>

<SharedLibraryInstallName Condition="'$(SharedLibraryInstallName)' == '' and '$(_IsApplePlatform)' == 'true' and '$(NativeLib)' == 'Shared'">@rpath/$(NativeBinaryPrefix)$(TargetName)$(NativeBinaryExt)</SharedLibraryInstallName>

Expand Down Expand Up @@ -222,17 +223,19 @@ The .NET Foundation licenses this file to you under the MIT license.

<ItemGroup>
<NativeSystemLibrary Include="stdc++" Condition="'$(LinkStandardCPlusPlusLibrary)' == 'true'" />
<NativeSystemLibrary Include="dl" />
<NativeSystemLibrary Include="dl" Condition="'$(_targetOS)' != 'haiku'" />
<NativeSystemLibrary Include="objc" Condition="'$(_IsApplePlatform)' == 'true'" />
<NativeSystemLibrary Include="swiftCore" Condition="'$(_IsApplePlatform)' == 'true'" />
<NativeSystemLibrary Include="swiftFoundation" Condition="'$(_IsApplePlatform)' == 'true'" />
<NativeSystemLibrary Include="z" Condition="'$(UseSystemZlib)' == 'true'" />
<NativeSystemLibrary Include="brotlienc;brotlidec;brotlicommon" Condition="'$(UseSystemBrotli)' == 'true'" />
<NativeSystemLibrary Include="zstd" Condition="'$(UseSystemZstd)' == 'true'" />
<NativeSystemLibrary Include="rt" Condition="'$(_IsApplePlatform)' != 'true' and '$(_linuxLibcFlavor)' != 'bionic'" />
<NativeSystemLibrary Include="rt" Condition="'$(_IsApplePlatform)' != 'true' and '$(_linuxLibcFlavor)' != 'bionic' and '$(_targetOS)' != 'haiku'" />
<NativeSystemLibrary Include="log" Condition="'$(_linuxLibcFlavor)' == 'bionic'" />
<NativeSystemLibrary Include="icucore" Condition="'$(_IsApplePlatform)' == 'true'" />
<NativeSystemLibrary Include="m" />
<NativeSystemLibrary Include="bsd" Condition="'$(_targetOS)' == 'haiku'" />
<NativeSystemLibrary Include="network" Condition="'$(_targetOS)' == 'haiku'" />
Comment thread
trungnt2910 marked this conversation as resolved.
Comment thread
trungnt2910 marked this conversation as resolved.
Comment thread
trungnt2910 marked this conversation as resolved.
<!-- See the comment in PalInterlockedCompareExchange128 for details. -->
<NativeSystemLibrary Include="atomic" Condition="'$(_targetArchitecture)' == 'riscv64' or '$(_targetArchitecture)' == 'loongarch64'" />
</ItemGroup>
Expand All @@ -250,7 +253,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<LinkerArg Include="-Wl,--build-id=sha1" Condition="'$(_IsApplePlatform)' != 'true'" />
<LinkerArg Include="-Wl,--as-needed" Condition="'$(_IsApplePlatform)' != 'true'" />
<LinkerArg Include="-Wl,-e,0x0" Condition="'$(NativeLib)' == 'Shared' and '$(_IsApplePlatform)' != 'true'" />
<LinkerArg Include="-pthread" Condition="'$(_IsApplePlatform)' != 'true'" />
<LinkerArg Include="-pthread" Condition="'$(_IsApplePlatform)' != 'true' and '$(_targetOS)' != 'haiku'" />
<LinkerArg Include="@(NativeSystemLibrary->'-l%(Identity)')" />
<LinkerArg Include="-L/usr/lib/swift" Condition="'$(_IsApplePlatform)' == 'true'" />
<LinkerArg Include="@(StaticICULibs)" Condition="'$(StaticICULinking)' == 'true'" />
Expand All @@ -260,8 +263,8 @@ The .NET Foundation licenses this file to you under the MIT license.
<LinkerArg Include="-dynamiclib" Condition="'$(_IsApplePlatform)' == 'true' and '$(NativeLib)' == 'Shared'" />
<LinkerArg Include="-shared" Condition="'$(_IsApplePlatform)' != 'true' and '$(NativeLib)' == 'Shared'" />
<!-- binskim warning BA3001 PIE disabled on executable -->
<LinkerArg Include="-pie -Wl,-pie" Condition="'$(_IsApplePlatform)' != 'true' and '$(NativeLib)' == '' and '$(StaticExecutable)' != 'true' and '$(PositionIndependentExecutable)' != 'false'" />
<LinkerArg Include="-Wl,-no-pie" Condition="'$(_IsApplePlatform)' != 'true' and '$(NativeLib)' == '' and '$(StaticExecutable)' != 'true' and '$(PositionIndependentExecutable)' == 'false'" />
<LinkerArg Include="-pie -Wl,-pie" Condition="'$(_IsApplePlatform)' != 'true' and '$(_targetOS)' != 'haiku' and '$(NativeLib)' == '' and '$(StaticExecutable)' != 'true' and '$(PositionIndependentExecutable)' != 'false'" />
<LinkerArg Include="-Wl,-no-pie" Condition="'$(_IsApplePlatform)' != 'true' and '$(_targetOS)' != 'haiku' and '$(NativeLib)' == '' and '$(StaticExecutable)' != 'true' and '$(PositionIndependentExecutable)' == 'false'" />
Comment on lines +266 to +267
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to yesterday's patch https://github.com/dotnet/runtime/pull/127392/changes#diff-0ed6f3997357a6ff6652a7509482b05370b67e8e3041eecfd89f9556e7b59313R495 -pie should work on Haiku, -fPIE was supposed to be replaced with -fPIC for executables. What was the error? I think you want to keep -Wl,-pie and -Wl,-no-pie (linker options) and separate out -pie if compiler is complaining.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the exact error here, but it had something to do with -fPIE not working with -shared.

-shared should be passed by default by the toolchain since all Haiku executables are built as shared objects for some reason.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, during the build, it should've published crossgen2 and ilc binaries as AOT. You can copy them from published directory on Haiku machine and run <path> --help, if it prints help without any error, we are good here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~/Desktop> crossgen2 --help
The application to execute does not exist: '/boot/home/Desktop/crossgen2.dll'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~/Desktop/crossgen2/native> ./crossgen2 --help
--------------------------------------------------
Debug Assertion Violation

Message: m_pCodeManager->FindMethodInfo(m_ControlPC, &m_methodInfo)

Expression: 'ASSERT_UNCONDITIONALLY'

File: /home/runner/dotnet-runtime/src/coreclr/nativeaot/Runtime/StackFrameIterator.cpp, Line: 2194
--------------------------------------------------
Abort

This is interesting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm waiting for the other PRs (especially the approved ones) to get merged before continuing. Right now I'm running it on disposable GitHub Actions machines and it's becoming cherry-pick hell.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most are passing, except:

Running /boot/home/Desktop/haiku.x64.Debug/nativeaot/SmokeTests/HardwareIntrinsics/X64Avx512/native/X64Avx512...

The current CPU is missing one or more of the required instruction sets.
Abort
Kill Thread
/boot/home/Desktop/haiku.x64.Debug/nativeaot/SmokeTests/HardwareIntrinsics/X64Avx512/native/X64Avx512 failed with exit code 149
Running /boot/home/Desktop/haiku.x64.Debug/nativeaot/SmokeTests/HardwareIntrinsics/X64Avx512_VectorT512/native/X64Avx512_VectorT512...

The current CPU is missing one or more of the required instruction sets.
Abort
Kill Thread
/boot/home/Desktop/haiku.x64.Debug/nativeaot/SmokeTests/HardwareIntrinsics/X64Avx512_VectorT512/native/X64Avx512_VectorT512 failed with exit code 149

My CPU is:

~/Desktop/haiku.x64.Debug/nativeaot> sysinfo
Kernel name: kernel_x86_64 built on: Apr 25 2026 06:15:18 version 0x901
4 Intel 11th Gen Core™ i7-1165G7, revision 806c1 running at 1689MHz

CPU #0: "11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz"
        Frequency: 1689.601
        Signature: 0x0806c1; Type 0, family 6, model 140, stepping 1
        Features: 0x1f8bfbff
                FPU, VME, DE, PSE, TSC, MSR, PAE, MCE, CX8, APIC, SEP, MTRR, PGE, MCA, CMOV, PAT
                PSE36, CFLUSH, MMX, FXSTR, SSE, SSE2, SS, HTT
        Extended Features (0x00000001): 0xfffa3203
                SSE3, PCLMULDQ, SSSE3, FMA, CX16, PCID, SSE4.1, SSE4.2, x2APIC, MOVEB, POPCNT, TSC-DEADLINE, AES, XSAVE, OSXSAVE, AVX
                F16C, RDRND, HYPERVISOR
        Extended Features (0x80000001): 0x2c100800
                SCE, NX, GBPAGES, RDTSCP, 64
        Extended Features (0x00000007): 0xf1bf27eb 0x18405fce 0xbc000510
                FSGSBASE, IA32_TSC_ADJUST, BMI1, AVX2, FDP_EXCPTN_ONLY, SMEP, BMI2, Enhanced REP MOVSB/STOSB, INVPCID, No FPU DS/CS, AVX512F, AVX512DQ, RDSEED, ADX, SMAP, AVX512_IFMA
                CLFLUSHOPT, CLWB, AVX512CD, SHA, AVX512BW, AVX512VL
                AVX512_VBMI, UMIP, PKU, AVX512_VBMI2, CET_SS, GFNI, VAES, VPCLMULQDQ, AVX512_VNNI, AVX512_BITALG, AVX512_VPOPCNTDQ, RDPID, MOVDIRI, MOVDIR64B
                Fast Short REP MOV, AVX512_VP2INTERSECT, MD_CLEAR, IBRS/IBPB, STIBP, L1D_FLUSH, IA32_ARCH_CAPABILITIES, SSBD

        L2 Data cache fully associative, 1 lines/tag, 64 bytes/line
        L2 cache: 256 KB, 8-way set associative, 0 lines/tag, 64 bytes/line

        Unknown cache descriptor 0xfe
        64-byte Prefetching

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is fine, you can ignore that test. Those tests are specifically publishing with explicit <IlcInstructionSet> option. The default is SSE4.2 which covers all x64 machines manufactured since 2008. We can set <IlcInstructionSet>native</IlcInstructionSet> in csproj if aim is to run app on the same machine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit suspicious though, since I ran this on a i7-1165G7, which should support AVX-512 according to Intel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to GDB it is due to this returning 0:

uint32_t eax;
__asm(" xgetbv\n" \
: "=a"(eax) /*output in eax*/\
: "c"(0) /*inputs - 0 in ecx*/\
: "edx" /* registers that are clobbered*/
);
// check OS has enabled XMM, YMM and ZMM state support
return ((eax & 0xE6) == 0x0E6) ? 1 : 0;

So it's a Haiku issue, not an issue with this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to yesterday's patch https://github.com/dotnet/runtime/pull/127392/changes#diff-0ed6f3997357a6ff6652a7509482b05370b67e8e3041eecfd89f9556e7b59313R495 -pie should work on Haiku, -fPIE was supposed to be replaced with -fPIC for executables.

So should this be in sync with what was done in #127392 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure -pic is a no-op in Haiku since any binary (including executables) can be loaded at any address.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Therefore, replacing -fPIE with -fPIC (or passing -fPIC at all) on Haiku is redundant. If synchronization between this and #127392 is mandatory, I believe we should change the other file to not pass anything for Haiku targets instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I think @jkotas point is to keep them in sync so it can be reasoned about. If it works without those flags, then omitting on both sides sounds good. We can validate build.sh clr+libs --os haiku --cross --bootstrap with and without -gcc (it publishes crossgen2/ilc and other stuff which you can copy to vm and run --help as before to make sure binaries are executing).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: #127443.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, with the argument, it works without -gcc.

With -gcc, it fails before even calling the linker:

gcc-13 : error : unrecognized command-line option ‘--target=x86_64-unknown-haiku’ [/home/trung/dotnet-runtime/src/coreclr/tools/aot/ILCompiler/ILCompiler_publish.csproj]
/home/trung/dotnet-runtime/artifacts/bin/coreclr/haiku.x64.Debug/build/Microsoft.NETCore.Native.targets(370,5): error MSB3073: The command ""/usr/bin/gcc-13" "/home/trung/dotnet-runtime/artifacts/obj/coreclr/ILCompiler_publish/haiku.x64.Debug/native/ilc.o" -o "/home/trung/dotnet-runtime/artifacts/bin/ILCompiler_publish/x64/Debug/native/ilc" -Wl,--version-script="/home/trung/dotnet-runtime/artifacts/obj/coreclr/ILCompiler_publish/haiku.x64.Debug/native/ilc.exports" -Wl,--export-dynamic -gz=zlib /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libSystem.Native.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libSystem.IO.Compression.Native.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libSystem.Net.Security.Native.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libSystem.Security.Cryptography.Native.OpenSsl.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libbootstrapper.o /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libRuntime.ServerGC.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libeventpipe-enabled.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libRuntime.VxsortEnabled.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libstandalonegc-disabled.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libaotminipal.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libstdc++compat.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libz.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libbrotlienc.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libbrotlidec.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libbrotlicommon.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libzstd.a --sysroot="/home/trung/dotnet-rootfs" --target=x86_64-unknown-haiku -g -Wl,--build-id=sha1 -Wl,--as-needed -lm -lbsd -lnetwork -Wl,-z,relro -Wl,-z,now -Wl,--eh-frame-hdr -Wl,--discard-all -Wl,--gc-sections" exited with code 1. [/home/trung/dotnet-runtime/src/coreclr/tools/aot/ILCompiler/ILCompiler_publish.csproj]

Build FAILED.

gcc-13 : error : unrecognized command-line option ‘--target=x86_64-unknown-haiku’ [/home/trung/dotnet-runtime/src/coreclr/tools/aot/ILCompiler/ILCompiler_publish.csproj]
/home/trung/dotnet-runtime/artifacts/bin/coreclr/haiku.x64.Debug/build/Microsoft.NETCore.Native.targets(370,5): error MSB3073: The command ""/usr/bin/gcc-13" "/home/trung/dotnet-runtime/artifacts/obj/coreclr/ILCompiler_publish/haiku.x64.Debug/native/ilc.o" -o "/home/trung/dotnet-runtime/artifacts/bin/ILCompiler_publish/x64/Debug/native/ilc" -Wl,--version-script="/home/trung/dotnet-runtime/artifacts/obj/coreclr/ILCompiler_publish/haiku.x64.Debug/native/ilc.exports" -Wl,--export-dynamic -gz=zlib /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libSystem.Native.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libSystem.IO.Compression.Native.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libSystem.Net.Security.Native.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libSystem.Security.Cryptography.Native.OpenSsl.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libbootstrapper.o /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libRuntime.ServerGC.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libeventpipe-enabled.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libRuntime.VxsortEnabled.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libstandalonegc-disabled.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libaotminipal.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/aotsdk/libstdc++compat.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libz.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libbrotlienc.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libbrotlidec.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libbrotlicommon.a /home/trung/dotnet-runtime/artifacts/bootstrap/haiku-x64/microsoft.netcore.app/lib/runtimes/haiku-x64/native/libzstd.a --sysroot="/home/trung/dotnet-rootfs" --target=x86_64-unknown-haiku -g -Wl,--build-id=sha1 -Wl,--as-needed -lm -lbsd -lnetwork -Wl,-z,relro -Wl,-z,now -Wl,--eh-frame-hdr -Wl,--discard-all -Wl,--gc-sections" exited with code 1. [/home/trung/dotnet-runtime/src/coreclr/tools/aot/ILCompiler/ILCompiler_publish.csproj]
    0 Warning(s)
    2 Error(s)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can ignore gcc error. We support clang or gcc for "host=target" and host clang and gcc with sysroot for cross / "host!=target". In case of haiku (and illumos), we are using gcc from sysroot built for host, it's different than using host gcc with target=<rootfs toolchain>. Unless you see people using this setup in wild, we don't support it as it stands.

Copy link
Copy Markdown
Member

@am11 am11 Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's actually more simpler, we don't support cross (when target!=host) PublishAot with gcc, period. 😅

#78559

<!-- binskim warning BA3010 The GNU_RELRO segment is missing -->
<LinkerArg Include="-Wl,-z,relro" Condition="'$(_IsApplePlatform)' != 'true'" />
<!-- binskim warning BA3011 The BIND_NOW flag is missing -->
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/nativeaot/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ else()
add_definitions(-D_LIBUNWIND_IS_NATIVE_ONLY)

if(CLR_CMAKE_TARGET_HAIKU)
add_definitions(-D_LIBUNWIND_USE_HAIKU_BSD_LIB=1)
add_definitions(-DPT_GNU_EH_FRAME=PT_EH_FRAME)
endif()

Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ void InitializeCurrentProcessCpuCount()
g_RhNumberOfProcessors = count;
}

#if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
#if defined(TARGET_LINUX) || defined(TARGET_ANDROID) || defined(TARGET_HAIKU)
static pthread_key_t key;
#endif

Expand Down Expand Up @@ -548,7 +548,7 @@ bool PalInit()
}
#endif

#if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
#if defined(TARGET_LINUX) || defined(TARGET_ANDROID) || defined(TARGET_HAIKU)
if (pthread_key_create(&key, RuntimeThreadShutdown) != 0)
{
return false;
Expand All @@ -558,7 +558,7 @@ bool PalInit()
return true;
}

#if !defined(TARGET_LINUX) && !defined(TARGET_ANDROID)
#if !defined(TARGET_LINUX) && !defined(TARGET_ANDROID) && !defined(TARGET_HAIKU)
struct TlsDestructionMonitor
{
void* m_thread = nullptr;
Expand Down Expand Up @@ -604,7 +604,7 @@ FCIMPLEND
// thread - thread to attach
void PalAttachThread(void* thread)
{
#if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
#if defined(TARGET_LINUX) || defined(TARGET_ANDROID) || defined(TARGET_HAIKU)
if (pthread_setspecific(key, thread) != 0)
{
_ASSERTE(!"pthread_setspecific failed");
Expand Down
15 changes: 4 additions & 11 deletions src/coreclr/tools/Common/CommandLineHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,16 @@ public static TargetOS GetTargetOS(string token)
return TargetOS.OSX;
else if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
return TargetOS.FreeBSD;
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("HAIKU")))
return TargetOS.Haiku;

throw new NotImplementedException();
}

return token.ToLowerInvariant() switch
{
"linux" => TargetOS.Linux,
"win" or "windows" => TargetOS.Windows,
"osx" => TargetOS.OSX,
"freebsd" => TargetOS.FreeBSD,
"maccatalyst" => TargetOS.MacCatalyst,
"iossimulator" => TargetOS.iOSSimulator,
"ios" => TargetOS.iOS,
"tvossimulator" => TargetOS.tvOSSimulator,
"tvos" => TargetOS.tvOS,
"browser" => TargetOS.Browser,
"wasi" => TargetOS.Wasi,
"win" => TargetOS.Windows,
_ when Enum.TryParse(token, ignoreCase: true, out TargetOS os) => os,
_ => throw new CommandLineException($"Target OS '{token}' is not supported")
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal enum MachineOSOverride : ushort
FreeBSD = 0xADC4,
NetBSD = 0x1993,
SunOS = 0x1992,
Haiku = 0x0B05,
}

/// <summary>
Expand Down Expand Up @@ -125,6 +126,9 @@ public static MachineOSOverride MachineOSOverrideFromTarget(this TargetDetails t
case TargetOS.NetBSD:
return MachineOSOverride.NetBSD;

case TargetOS.Haiku:
return MachineOSOverride.Haiku;

default:
throw new NotImplementedException(target.OperatingSystem.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum TargetOS
FreeBSD,
NetBSD,
SunOS,
Haiku,
Browser,
Wasi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private static PerfmapTokensForTarget TranslateTargetDetailsToPerfmapConstants(T
TargetOS.FreeBSD => PerfMapOSToken.FreeBSD,
TargetOS.NetBSD => PerfMapOSToken.NetBSD,
TargetOS.SunOS => PerfMapOSToken.SunOS,
TargetOS.Haiku => PerfMapOSToken.Haiku,
_ => throw new NotImplementedException(details.OperatingSystem.ToString())
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public enum PerfMapOSToken : uint
FreeBSD = 4,
NetBSD = 5,
SunOS = 6,
Haiku = 7,
}

public enum PerfMapAbiToken : uint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum MachineOSOverride : ushort
FreeBSD = 0xADC4,
NetBSD = 0x1993,
SunOS = 0x1992,
Haiku = 0x0B05,
}

/// <summary>
Expand Down Expand Up @@ -125,6 +126,9 @@ public static MachineOSOverride MachineOSOverrideFromTarget(this TargetDetails t
case TargetOS.NetBSD:
return MachineOSOverride.NetBSD;

case TargetOS.Haiku:
return MachineOSOverride.Haiku;

default:
throw new NotImplementedException(target.OperatingSystem.ToString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum OperatingSystem
Linux = 0x7B79,
NetBSD = 0x1993,
SunOS = 0x1992,
Haiku = 0x0B05,
Windows = 0,
Unknown = -1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ public static void ComputeDefaultOptions(out TargetOS os, out TargetArchitecture
os = TargetOS.OSX;
else if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
os = TargetOS.FreeBSD;
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("HAIKU")))
os = TargetOS.Haiku;
else
throw new NotImplementedException();

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public static void PrintExtendedHelp(ParseResult _)
"considered to be input files. If no input files begin with '--' then this option is not necessary.\n");

string[] ValidArchitectures = new string[] { "arm", "arm64", "x86", "x64", "riscv64", "loongarch64" };
string[] ValidOS = new string[] { "windows", "linux", "freebsd", "osx", "maccatalyst", "ios", "iossimulator", "tvos", "tvossimulator" };
string[] ValidOS = new string[] { "windows", "linux", "freebsd", "haiku", "osx", "maccatalyst", "ios", "iossimulator", "tvos", "tvossimulator" };

Console.WriteLine("Valid switches for {0} are: '{1}'. The default value is '{2}'\n", "--targetos", string.Join("', '", ValidOS), Helpers.GetTargetOS(null).ToString().ToLowerInvariant());

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public static void PrintExtendedHelp(ParseResult _)
Console.WriteLine();

string[] ValidArchitectures = ["arm", "armel", "arm64", "x86", "x64", "riscv64", "loongarch64", "wasm"];
string[] ValidOS = ["windows", "linux", "osx", "ios", "iossimulator", "maccatalyst", "browser"];
string[] ValidOS = ["windows", "linux", "haiku", "osx", "ios", "iossimulator", "maccatalyst", "browser"];

Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--targetos", String.Join("', '", ValidOS), Helpers.GetTargetOS(null).ToString().ToLowerInvariant()));
Console.WriteLine();
Expand Down
8 changes: 3 additions & 5 deletions src/coreclr/tools/r2rdump/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,12 @@ public void Dump(ReadyToRunReader r2r)
Machine.RiscV64 => TargetArchitecture.RiscV64,
_ => throw new NotImplementedException(r2r.Machine.ToString()),
};
string osToken = r2r.OperatingSystem.ToString();
TargetOS os = r2r.OperatingSystem switch
{
OperatingSystem.Windows => TargetOS.Windows,
OperatingSystem.Linux => TargetOS.Linux,
OperatingSystem.Apple => TargetOS.OSX,
OperatingSystem.FreeBSD => TargetOS.FreeBSD,
OperatingSystem.NetBSD => TargetOS.FreeBSD,
_ => throw new NotImplementedException(r2r.OperatingSystem.ToString()),
_ when Enum.TryParse(osToken, ignoreCase: true, out TargetOS parsedOs) => parsedOs,
_ => throw new NotImplementedException(osToken),
};
TargetDetails details = new(architecture, os, TargetAbi.NativeAot);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

<PropertyGroup>
<PublishReadyToRun>true</PublishReadyToRun>
<!-- Disable crossgen on NetBSD, illumos, Solaris and Haiku for now. This can be revisited when we have full support. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</PublishReadyToRun>
<!-- Disable crossgen on NetBSD, illumos, and Solaris for now. This can be revisited when we have full support. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris'">false</PublishReadyToRun>
<!-- TODO-WASM: we will have WASM R2R after https://github.com/dotnet/runtime/issues/121257 -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'browser' or '$(TargetOS)' == 'wasi'">false</PublishReadyToRun>
<PublishReadyToRun Condition="'$(StageTwoBuild)'=='true'">false</PublishReadyToRun>
Expand Down