diff --git a/eng/Subsets.props b/eng/Subsets.props index ba8bc03906a1cb..c88f4a573ec09b 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -48,7 +48,7 @@ true - <_NativeAotSupportedOS Condition="'$(TargetOS)' != 'browser' and '$(TargetOS)' != 'haiku' and '$(TargetOS)' != 'illumos' and '$(TargetOS)' != 'netbsd' and '$(TargetOS)' != 'solaris'">true + <_NativeAotSupportedOS Condition="'$(TargetOS)' != 'browser' and '$(TargetOS)' != 'illumos' and '$(TargetOS)' != 'netbsd' and '$(TargetOS)' != 'solaris'">true <_NativeAotSupportedArch Condition="'$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'loongarch64' or '$(TargetArchitecture)' == 'riscv64' or ('$(TargetOS)' == 'windows' and '$(TargetArchitecture)' == 'x86')">true true diff --git a/src/coreclr/crossgen-corelib.proj b/src/coreclr/crossgen-corelib.proj index 069d3b7278e143..9289297f90ce5e 100644 --- a/src/coreclr/crossgen-corelib.proj +++ b/src/coreclr/crossgen-corelib.proj @@ -20,8 +20,8 @@ InvokeCrossgen2 true - - false + + false false diff --git a/src/coreclr/inc/pedecoder.h b/src/coreclr/inc/pedecoder.h index a373f90d55d3b1..44cf1e52c50184 100644 --- a/src/coreclr/inc/pedecoder.h +++ b/src/coreclr/inc/pedecoder.h @@ -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 diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 6ec997d6c237ae..8184ae074e039e 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -65,6 +65,7 @@ The .NET Foundation licenses this file to you under the MIT license. $(CrossCompileArch)-linux-$(CrossCompileAbi) $(CrossCompileArch)-alpine-linux-$(CrossCompileAbi) $(CrossCompileArch)-unknown-freebsd12 + $(CrossCompileArch)-unknown-haiku @rpath/$(NativeBinaryPrefix)$(TargetName)$(NativeBinaryExt) @@ -222,17 +223,19 @@ The .NET Foundation licenses this file to you under the MIT license. - + - + + + @@ -250,7 +253,7 @@ The .NET Foundation licenses this file to you under the MIT license. - + @@ -260,8 +263,8 @@ The .NET Foundation licenses this file to you under the MIT license. - - + + diff --git a/src/coreclr/nativeaot/Runtime/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/CMakeLists.txt index 9f3a80c702358e..1d21c535c67804 100644 --- a/src/coreclr/nativeaot/Runtime/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/CMakeLists.txt @@ -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() diff --git a/src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp b/src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp index dec55db82905fb..b04a0a562aad57 100644 --- a/src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp +++ b/src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp @@ -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 @@ -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; @@ -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; @@ -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"); diff --git a/src/coreclr/tools/Common/CommandLineHelpers.cs b/src/coreclr/tools/Common/CommandLineHelpers.cs index 5aedd6781601fe..47b7a9f66ff5b5 100644 --- a/src/coreclr/tools/Common/CommandLineHelpers.cs +++ b/src/coreclr/tools/Common/CommandLineHelpers.cs @@ -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") }; } diff --git a/src/coreclr/tools/Common/Compiler/ObjectWriter/PETargetExtensions.cs b/src/coreclr/tools/Common/Compiler/ObjectWriter/PETargetExtensions.cs index 12f992c29677b8..42fd0220f5fe1f 100644 --- a/src/coreclr/tools/Common/Compiler/ObjectWriter/PETargetExtensions.cs +++ b/src/coreclr/tools/Common/Compiler/ObjectWriter/PETargetExtensions.cs @@ -20,6 +20,7 @@ internal enum MachineOSOverride : ushort FreeBSD = 0xADC4, NetBSD = 0x1993, SunOS = 0x1992, + Haiku = 0x0B05, } /// @@ -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()); } diff --git a/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs b/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs index fc69a28bdcb977..826456b23f70cb 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs @@ -23,6 +23,7 @@ public enum TargetOS FreeBSD, NetBSD, SunOS, + Haiku, Browser, Wasi } diff --git a/src/coreclr/tools/aot/ILCompiler.Diagnostics/PerfMapWriter.cs b/src/coreclr/tools/aot/ILCompiler.Diagnostics/PerfMapWriter.cs index 16f82023ad0b57..88460dc254b515 100644 --- a/src/coreclr/tools/aot/ILCompiler.Diagnostics/PerfMapWriter.cs +++ b/src/coreclr/tools/aot/ILCompiler.Diagnostics/PerfMapWriter.cs @@ -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()) }; diff --git a/src/coreclr/tools/aot/ILCompiler.Diagnostics/ReadyToRunDiagnosticsConstants.cs b/src/coreclr/tools/aot/ILCompiler.Diagnostics/ReadyToRunDiagnosticsConstants.cs index 281349be80e52e..6d5d28eb932237 100644 --- a/src/coreclr/tools/aot/ILCompiler.Diagnostics/ReadyToRunDiagnosticsConstants.cs +++ b/src/coreclr/tools/aot/ILCompiler.Diagnostics/ReadyToRunDiagnosticsConstants.cs @@ -32,6 +32,7 @@ public enum PerfMapOSToken : uint FreeBSD = 4, NetBSD = 5, SunOS = 6, + Haiku = 7, } public enum PerfMapAbiToken : uint diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs index ef76a9abcce5bb..3588ec59956a96 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ObjectWriter/TargetExtensions.cs @@ -20,6 +20,7 @@ public enum MachineOSOverride : ushort FreeBSD = 0xADC4, NetBSD = 0x1993, SunOS = 0x1992, + Haiku = 0x0B05, } /// @@ -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()); } diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs index 13dd20c4e979be..e01fe62f236560 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs @@ -30,6 +30,7 @@ public enum OperatingSystem Linux = 0x7B79, NetBSD = 0x1993, SunOS = 0x1992, + Haiku = 0x0B05, Windows = 0, Unknown = -1 } diff --git a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/TrimmingDriver.cs b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/TrimmingDriver.cs index acf155339d2055..b56906d3dd0617 100644 --- a/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/TrimmingDriver.cs +++ b/src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCasesRunner/TrimmingDriver.cs @@ -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(); diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs index fa5340d80a13fc..25b06c9602f611 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs +++ b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs @@ -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()); diff --git a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs index 49127d3077831a..14dc419a87caa1 100644 --- a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs +++ b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs @@ -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(); diff --git a/src/coreclr/tools/r2rdump/Program.cs b/src/coreclr/tools/r2rdump/Program.cs index 7dd5f49c5a8d85..62e3f0b5b252c3 100644 --- a/src/coreclr/tools/r2rdump/Program.cs +++ b/src/coreclr/tools/r2rdump/Program.cs @@ -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); diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj index f8e03ff1dc0b71..f7b908affc2bb9 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj @@ -22,8 +22,8 @@ true - - false + + false false false