Haiku: Fix native component build#126701
Conversation
This contains the missing configuration updates required to build the native component for Haiku with the latest .NET source.
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
There was a problem hiding this comment.
Pull request overview
Updates native build configuration to improve compatibility with Haiku when building dotnet/runtime native components, primarily by feature-detecting pthread robust-mutex APIs and adjusting Haiku linker behavior in CMake.
Changes:
- Add CMake feature checks for
pthread_mutex_consistentandpthread_mutexattr_setrobust, and expose them viapal_config.h. - Conditionally compile robust-mutex initialization and recovery paths in
pal_crossprocessmutex.cbased on those feature macros. - Adjust Haiku CMake linker-group settings as a workaround for missing upstream CMake support.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/native/libs/System.Native/pal_crossprocessmutex.c | Guard robust mutex attr usage and EOWNERDEAD recovery logic behind feature macros. |
| src/native/libs/configure.cmake | Add configure-time detection for robust-mutex related pthread APIs. |
| src/native/libs/Common/pal_config.h.in | Export new HAVE_PTHREAD_MUTEX_* feature macros to native builds. |
| eng/native/configurecompiler.cmake | Set Haiku linker-group rescan settings and adjust Haiku linker flags. |
30de881 to
c66034d
Compare
Instead of guarding for robust mutexes in `pal_crossprocessmutex.c`, guard them in the `CMakeLists.txt` so that platforms without these can fall back to the stubbed implementation on unsupported platforms.
c66034d to
544eeec
Compare
- Remove the hard-coded OS support list for `pthread` robust mutexes in favor of the new configure-time detection flags `HAVE_PTHREAD_MUTEXATTR_SETROBUST` and `HAVE_PTHREAD_MUTEX_CONSISTENT`. - Simplify the condition by flipping the order.
| set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE) | ||
| add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>) | ||
| add_linker_flag("-Wl,--no-undefined") | ||
| add_linker_flag("-Wl,--build-id=sha1") |
There was a problem hiding this comment.
The Haiku-specific linker flags no longer include a “no undefined symbols” check (previously -Wl,--no-undefined). Dropping this makes it easier for undefined references to slip through link and fail later at runtime. If Haiku’s linker doesn’t support --no-undefined, consider using check_linker_flag() and conditionally adding it (or an equivalent like -Wl,-z,defs), so we keep the safety check when it’s supported.
| add_linker_flag("-Wl,--build-id=sha1") | |
| add_linker_flag("-Wl,--build-id=sha1") | |
| check_linker_flag(C "-Wl,--no-undefined" LINKER_SUPPORTS_NO_UNDEFINED_FLAG) | |
| if(LINKER_SUPPORTS_NO_UNDEFINED_FLAG) | |
| add_linker_flag("-Wl,--no-undefined") | |
| else() | |
| check_linker_flag(C "-Wl,-z,defs" LINKER_SUPPORTS_Z_DEFS_FLAG) | |
| if(LINKER_SUPPORTS_Z_DEFS_FLAG) | |
| add_linker_flag("-Wl,-z,defs") | |
| endif() | |
| endif() |
| if (HAVE_PTHREAD_MUTEXATTR_SETROBUST AND HAVE_PTHREAD_MUTEX_CONSISTENT) | ||
| list (APPEND NATIVE_SOURCES | ||
| pal_crossprocessmutex_unsupported.c) | ||
| pal_crossprocessmutex.c) | ||
| else() | ||
| list (APPEND NATIVE_SOURCES | ||
| pal_crossprocessmutex.c | ||
| ) | ||
| pal_crossprocessmutex_unsupported.c) | ||
| endif() |
There was a problem hiding this comment.
This changes cross-process mutex source selection from an OS allow/deny list to pure symbol detection. That means targets that were previously forced to use pal_crossprocessmutex_unsupported.c (notably Android/OpenBSD/Apple/etc.) may now build the pthread-based implementation if those symbols happen to be present, which is a behavior change and could reintroduce known platform issues. Consider keeping the explicit target exclusions (at least for the previously-denied targets) and combining them with the new HAVE_PTHREAD_MUTEX* feature checks, or add a comment explaining why the old exclusions are no longer needed.
jkotas
left a comment
There was a problem hiding this comment.
@jkoritzinsky Could you please sign off as well?
This contains the missing configuration updates required to build the native component for Haiku with the latest .NET source.
Part of #55803.