Skip to content
Merged
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
32 changes: 31 additions & 1 deletion eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,38 @@ elseif(CLR_CMAKE_HOST_APPLE)
endif()
endif()
elseif(CLR_CMAKE_HOST_HAIKU)
# Haiku uses the GNU toolchain, which supports WHOLE_ARCHIVE, but only CMake 3.31.0+ recognizes this.
if(CMAKE_VERSION VERSION_LESS 3.31)
if(NOT DEFINED _CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
execute_process(COMMAND "${CMAKE_LINKER}" --help
OUTPUT_VARIABLE __linker_help
ERROR_VARIABLE __linker_help)
if(__linker_help MATCHES "--push-state" AND __linker_help MATCHES "--pop-state")
set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED TRUE CACHE INTERNAL "linker supports push/pop state")
else()
set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED FALSE CACHE INTERNAL "linker supports push/pop state")
endif()
unset(__linker_help)
Comment thread
jkoritzinsky marked this conversation as resolved.
endif()
if(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--push-state,--whole-archive"
"<LINK_ITEM>"
"LINKER:--pop-state")
else()
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--whole-archive"
"<LINK_ITEM>"
"LINKER:--no-whole-archive")
endif()
set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT)
Comment thread
jkoritzinsky marked this conversation as resolved.
endif()
# Haiku uses the GNU toolchain, which supports RESCAN, but only CMake 4.4.0+ recognizes this.
if(CMAKE_VERSION VERSION_LESS 4.4)
set(CMAKE_LINK_GROUP_USING_RESCAN "LINKER:--start-group" "LINKER:--end-group")
set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE)
Comment thread
jkoritzinsky marked this conversation as resolved.
endif()
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
Comment thread
jkoritzinsky marked this conversation as resolved.
add_linker_flag("-Wl,--no-undefined")
add_linker_flag("-Wl,--build-id=sha1")
Comment thread
jkoritzinsky marked this conversation as resolved.
endif()

#------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions src/libraries/System.Private.CoreLib/src/System/OperatingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ internal static bool IsOpenBSD() =>
false;
#endif

/// <summary>
/// Indicates whether the current application is running on Haiku.
/// </summary>
[NonVersionable]
internal static bool IsHaiku() =>
#if TARGET_HAIKU
true;
#else
false;
#endif

/// <summary>
/// Indicates whether the current application is running on Android.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ internal abstract class NamedMutexProcessDataBase(SharedMemoryProcessDataHeader<
// On FreeBSD, pthread process-shared robust mutexes cannot be placed in shared memory mapped
// independently by the processes involved. See https://github.com/dotnet/runtime/issues/10519.
// On OpenBSD, cross process mutexes are not supported in the pthread implementation. See https://github.com/dotnet/runtime/pull/125089.
private static bool UsePThreadMutexes => !OperatingSystem.IsApplePlatform() && !OperatingSystem.IsFreeBSD() && !OperatingSystem.IsOpenBSD();
// On Haiku, robust mutexes are WIP. See https://github.com/dotnet/runtime/pull/126701#issuecomment-4334338213.
private static bool UsePThreadMutexes => !OperatingSystem.IsApplePlatform() && !OperatingSystem.IsFreeBSD() && !OperatingSystem.IsOpenBSD() && !OperatingSystem.IsHaiku();

private readonly SharedMemoryProcessDataHeader<NamedMutexProcessDataBase> _processDataHeader = header;
protected nuint _lockCount;
Expand Down
6 changes: 5 additions & 1 deletion src/native/libs/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ else() # WASI
)
endif()

if (CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI OR CLR_CMAKE_TARGET_OPENBSD)
if (CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI OR CLR_CMAKE_TARGET_OPENBSD OR CLR_CMAKE_TARGET_HAIKU)
# These platforms do not support robust mutexes.
# Keep an OS list instead of CMake configure checks since we also need to synchronize this with
# the compile-time guards on the managed code side at
# src/libraries/System.Private.CoreLib/src/System/Threading/NamedMutex.Unix.cs.
list (APPEND NATIVE_SOURCES
pal_crossprocessmutex_unsupported.c)
else()
Expand Down
Loading