From 3698fb8902969d4290e09d936c4ad4c913870186 Mon Sep 17 00:00:00 2001
From: Trung Nguyen <57174311+trungnt2910@users.noreply.github.com>
Date: Sun, 7 May 2023 15:21:21 +1000
Subject: [PATCH] Haiku: Configuration support
Added more support for configuration for Haiku cross-compile
builds.
---
src/coreclr/.nuget/Directory.Build.props | 5 ++-
src/coreclr/crossgen-corelib.proj | 2 +-
src/coreclr/debug/createdump/CMakeLists.txt | 2 +-
src/coreclr/debug/dbgutil/CMakeLists.txt | 4 +--
src/coreclr/dlls/mscordac/CMakeLists.txt | 8 ++---
src/coreclr/dlls/mscordbi/CMakeLists.txt | 10 ++++--
.../dlls/mscoree/coreclr/CMakeLists.txt | 8 +++--
src/coreclr/ilasm/CMakeLists.txt | 4 +--
src/coreclr/ildasm/exe/CMakeLists.txt | 4 +--
src/coreclr/nativeaot/Runtime/CMakeLists.txt | 4 +++
.../nativeaot/Runtime/unix/config.h.in | 1 +
.../nativeaot/Runtime/unix/configure.cmake | 12 +++++--
src/coreclr/pal/src/CMakeLists.txt | 33 ++++++++++++-------
src/coreclr/pal/src/config.h.in | 4 +++
src/coreclr/pal/src/configure.cmake | 24 +++++++++++---
.../pal_sxs/test1/CMakeLists.txt | 4 +--
src/coreclr/scripts/coreclr_arguments.py | 6 ++--
.../aot/crossgen2/crossgen2_publish.csproj | 6 ++--
.../pkg/projects/netcoreappRIDs.props | 1 +
.../Microsoft.NETCore.App.Runtime.props | 4 +--
.../src/runtime.json | 11 +++++++
.../src/System.Net.Http.csproj | 2 +-
.../src/System.Net.NetworkInformation.csproj | 7 ++--
.../src/System.Net.Security.csproj | 2 +-
.../System.Private.CoreLib.Shared.projitems | 1 +
...time.Serialization.Formatters.Tests.csproj | 2 +-
src/mono/CMakeLists.txt | 10 ++++++
src/mono/cmake/configure.cmake | 4 +++
src/mono/mono.proj | 13 ++++++--
src/mono/mono/mini/CMakeLists.txt | 4 ++-
.../corehost/apphost/static/CMakeLists.txt | 4 +++
src/native/libs/CMakeLists.txt | 2 +-
src/native/libs/Common/pal_config.h.in | 5 +++
.../CMakeLists.txt | 4 +--
.../System.IO.Ports.Native/CMakeLists.txt | 8 ++++-
.../libs/System.Native/extra_libs.cmake | 2 ++
.../CMakeLists.txt | 5 +--
.../extra_libs.cmake | 6 ++--
src/native/libs/configure.cmake | 28 +++++++++++++++-
src/native/libs/verify-entrypoints.sh | 5 ++-
src/tests/Directory.Build.props | 2 +-
.../JIT/Directed/StructABI/StructABI.csproj | 2 +-
src/tests/profiler/native/CMakeLists.txt | 2 +-
43 files changed, 210 insertions(+), 67 deletions(-)
diff --git a/src/coreclr/.nuget/Directory.Build.props b/src/coreclr/.nuget/Directory.Build.props
index 885f7f1073985..dbfb7764131e7 100644
--- a/src/coreclr/.nuget/Directory.Build.props
+++ b/src/coreclr/.nuget/Directory.Build.props
@@ -33,7 +33,7 @@
transport packages to flow dependencies anymore -->
false
- windows;osx;android;linux;freebsd;netbsd;illumos;solaris
+ windows;osx;android;linux;freebsd;netbsd;illumos;solaris;haiku
;$(SupportedPackageOSGroups);
<_isSupportedOSGroup>true
@@ -105,6 +105,9 @@
+
+
+
x86
diff --git a/src/coreclr/crossgen-corelib.proj b/src/coreclr/crossgen-corelib.proj
index 12d2f17ddcc51..1c63c777c7ebf 100644
--- a/src/coreclr/crossgen-corelib.proj
+++ b/src/coreclr/crossgen-corelib.proj
@@ -22,7 +22,7 @@
true
- false
+ false
false
false
diff --git a/src/coreclr/debug/createdump/CMakeLists.txt b/src/coreclr/debug/createdump/CMakeLists.txt
index c108586ca0510..0d8ed0c19d458 100644
--- a/src/coreclr/debug/createdump/CMakeLists.txt
+++ b/src/coreclr/debug/createdump/CMakeLists.txt
@@ -101,7 +101,7 @@ endif(CLR_CMAKE_HOST_OSX)
createdump_static
corguids
dbgutil
- dl
+ ${CMAKE_DL_LIBS}
)
endif(CLR_CMAKE_HOST_WIN32)
diff --git a/src/coreclr/debug/dbgutil/CMakeLists.txt b/src/coreclr/debug/dbgutil/CMakeLists.txt
index 100a399ad4fbf..2d8e02b07fc7f 100644
--- a/src/coreclr/debug/dbgutil/CMakeLists.txt
+++ b/src/coreclr/debug/dbgutil/CMakeLists.txt
@@ -19,11 +19,11 @@ set(DBGUTIL_SOURCES
dbgutil.cpp
)
-if(CLR_CMAKE_TARGET_LINUX)
+if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_HAIKU)
list(APPEND DBGUTIL_SOURCES
elfreader.cpp
)
-endif(CLR_CMAKE_TARGET_LINUX)
+endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_HAIKU)
if(CLR_CMAKE_TARGET_OSX)
list(APPEND DBGUTIL_SOURCES
diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt
index ea49cb0ad4098..239dc9466d401 100644
--- a/src/coreclr/dlls/mscordac/CMakeLists.txt
+++ b/src/coreclr/dlls/mscordac/CMakeLists.txt
@@ -31,9 +31,9 @@ else(CLR_CMAKE_HOST_WIN32)
# Add dependency on export file
add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE})
- if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+ if(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
- endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+ endif(CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
if(CORECLR_SET_RPATH AND CLR_CMAKE_HOST_OSX AND CLR_CMAKE_HOST_ARCH_ARM64)
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
@@ -80,7 +80,7 @@ else(CLR_CMAKE_HOST_WIN32)
list(APPEND CLR_DAC_SOURCES libredefines.S)
endif(CLR_CMAKE_HOST_LINUX)
- if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
# This option is necessary to ensure that the overloaded delete operator defined inside
# of the utilcode will be used instead of the standard library delete operator.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic")
@@ -93,7 +93,7 @@ else(CLR_CMAKE_HOST_WIN32)
# These options are used to force every object to be included even if it's unused.
set(START_WHOLE_ARCHIVE -Wl,--whole-archive)
set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive)
- endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+ endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
set_exports_linker_option(${EXPORTS_FILE})
endif(CLR_CMAKE_HOST_WIN32)
diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt
index 1940f64e94b09..fce244c50d717 100644
--- a/src/coreclr/dlls/mscordbi/CMakeLists.txt
+++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt
@@ -45,11 +45,11 @@ else(CLR_CMAKE_HOST_WIN32)
set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordbi.exports)
generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
- if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
# This option is necessary to ensure that the overloaded new/delete operators defined inside
# of the utilcode will be used instead of the standard library delete operator.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic")
- endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+ endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
set_exports_linker_option(${EXPORTS_FILE})
endif(CLR_CMAKE_HOST_WIN32)
@@ -101,6 +101,12 @@ elseif(CLR_CMAKE_HOST_UNIX)
mscordaccore
)
+ if(CLR_CMAKE_HOST_HAIKU)
+ list(APPEND COREDBI_LIBRARIES
+ network
+ )
+ endif(CLR_CMAKE_HOST_HAIKU)
+
# Before llvm 16, lld was setting `--undefined-version` by default. The default was
# flipped to `--no-undefined-version` in lld 16, so we will explicitly set it to
# `--undefined-version` for our use-case.
diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
index 84e4b42284a52..2e2a8bf87eccd 100644
--- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
+++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
@@ -35,7 +35,7 @@ else(CLR_CMAKE_HOST_WIN32)
set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/coreclr.exports)
generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
- if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS)
+ if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS OR CLR_CMAKE_HOST_HAIKU)
# This option is necessary to ensure that the overloaded delete operator defined inside
# of the utilcode will be used instead of the standard library delete operator.
add_linker_flag("-Wl,-Bsymbolic")
@@ -48,7 +48,7 @@ else(CLR_CMAKE_HOST_WIN32)
# These options are used to force every object to be included even if it's unused.
set(START_WHOLE_ARCHIVE -Wl,--whole-archive)
set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive)
- endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS)
+ endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS OR CLR_CMAKE_HOST_HAIKU)
if(CLR_CMAKE_TARGET_OSX)
# These options are used to force every object to be included even if it's unused.
@@ -147,6 +147,10 @@ elseif(CLR_CMAKE_TARGET_SUNOS)
list(APPEND CORECLR_LIBRARIES
socket
)
+elseif(CLR_CMAKE_TARGET_HAIKU)
+ list(APPEND CORECLR_LIBRARIES
+ network
+ )
endif(CLR_CMAKE_TARGET_LINUX)
if(FEATURE_PERFTRACING)
diff --git a/src/coreclr/ilasm/CMakeLists.txt b/src/coreclr/ilasm/CMakeLists.txt
index 5102243fccde3..cca2c6da1858e 100644
--- a/src/coreclr/ilasm/CMakeLists.txt
+++ b/src/coreclr/ilasm/CMakeLists.txt
@@ -54,7 +54,7 @@ if(CLR_CMAKE_HOST_UNIX)
set_source_files_properties( prebuilt/asmparse.cpp PROPERTIES COMPILE_FLAGS "-O0" )
endif(CLR_CMAKE_HOST_UNIX)
-if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
# This option is necessary to ensure that the overloaded delete operator defined inside
# of the utilcode will be used instead of the standard library delete operator.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic")
@@ -63,7 +63,7 @@ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CL
# ensure proper resolving of circular references between a subset of the libraries.
set(START_LIBRARY_GROUP -Wl,--start-group)
set(END_LIBRARY_GROUP -Wl,--end-group)
-endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
add_executable_clr(ilasm
${ILASM_SOURCES}
diff --git a/src/coreclr/ildasm/exe/CMakeLists.txt b/src/coreclr/ildasm/exe/CMakeLists.txt
index a8d629a9200bb..fd5daaaa1525b 100644
--- a/src/coreclr/ildasm/exe/CMakeLists.txt
+++ b/src/coreclr/ildasm/exe/CMakeLists.txt
@@ -47,7 +47,7 @@ if (CLR_CMAKE_TARGET_WIN32)
list(APPEND ILDASM_SOURCES ${ILDASM_HEADERS})
endif(CLR_CMAKE_TARGET_WIN32)
-if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
# This option is necessary to ensure that the overloaded delete operator defined inside
# of the utilcode will be used instead of the standard library delete operator.
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic")
@@ -56,7 +56,7 @@ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CL
# ensure proper resolving of circular references between a subset of the libraries.
set(START_LIBRARY_GROUP -Wl,--start-group)
set(END_LIBRARY_GROUP -Wl,--end-group)
-endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS)
+endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_FREEBSD OR CLR_CMAKE_HOST_NETBSD OR CLR_CMAKE_HOST_SUNOS OR CLR_CMAKE_HOST_HAIKU)
add_executable_clr(ildasm
${ILDASM_SOURCES}
diff --git a/src/coreclr/nativeaot/Runtime/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/CMakeLists.txt
index 2784cdbb4db60..ac383acfb6bd6 100644
--- a/src/coreclr/nativeaot/Runtime/CMakeLists.txt
+++ b/src/coreclr/nativeaot/Runtime/CMakeLists.txt
@@ -141,6 +141,10 @@ else()
# Compile unwinding only for the current compilation target architecture
add_definitions(-D_LIBUNWIND_IS_NATIVE_ONLY)
+ if(CLR_CMAKE_TARGET_HAIKU)
+ add_definitions(-DPT_GNU_EH_FRAME=PT_EH_FRAME)
+ endif()
+
list(APPEND COMMON_RUNTIME_SOURCES
unix/PalRedhawkUnix.cpp
unix/PalCreateDump.cpp
diff --git a/src/coreclr/nativeaot/Runtime/unix/config.h.in b/src/coreclr/nativeaot/Runtime/unix/config.h.in
index 75cb486352766..d5505b760c1f6 100644
--- a/src/coreclr/nativeaot/Runtime/unix/config.h.in
+++ b/src/coreclr/nativeaot/Runtime/unix/config.h.in
@@ -2,6 +2,7 @@
#define _PAL_CONFIG_H_INCLUDED 1
#cmakedefine01 HAVE_AUXV_HWCAP_H
+#cmakedefine01 HAVE_UCONTEXT_H
#cmakedefine01 HAVE_PRCTL_H
#cmakedefine01 HAVE_PR_SET_PTRACER
diff --git a/src/coreclr/nativeaot/Runtime/unix/configure.cmake b/src/coreclr/nativeaot/Runtime/unix/configure.cmake
index 570a771869550..39ce650e54a6d 100644
--- a/src/coreclr/nativeaot/Runtime/unix/configure.cmake
+++ b/src/coreclr/nativeaot/Runtime/unix/configure.cmake
@@ -35,8 +35,16 @@ check_library_exists(${PTHREAD_LIBRARY} pthread_getthreadid_np "" HAVE_PTHREAD_G
check_function_exists(clock_nanosleep HAVE_CLOCK_NANOSLEEP)
-check_struct_has_member ("ucontext_t" uc_mcontext.gregs[0] ucontext.h HAVE_GREGSET_T)
-check_struct_has_member ("ucontext_t" uc_mcontext.__gregs[0] ucontext.h HAVE___GREGSET_T)
+check_include_files(ucontext.h HAVE_UCONTEXT_H)
+
+if (HAVE_UCONTEXT_H)
+ set(UCONTEXT_T_HEADER ucontext.h)
+else ()
+ set(UCONTEXT_T_HEADER signal.h)
+endif ()
+
+check_struct_has_member ("ucontext_t" uc_mcontext.gregs[0] ${UCONTEXT_T_HEADER} HAVE_GREGSET_T)
+check_struct_has_member ("ucontext_t" uc_mcontext.__gregs[0] ${UCONTEXT_T_HEADER} HAVE___GREGSET_T)
set(CMAKE_EXTRA_INCLUDE_FILES)
set(CMAKE_EXTRA_INCLUDE_FILES signal.h)
diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt
index 0fe6c0f04e590..cd49a2c9c58d8 100644
--- a/src/coreclr/pal/src/CMakeLists.txt
+++ b/src/coreclr/pal/src/CMakeLists.txt
@@ -1,7 +1,8 @@
-if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD)
+if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_HAIKU)
# On OSX and *BSD, we use the libunwind that's part of the OS
+ # On Haiku, we used a special port of libunwind
set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1)
-endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD)
+endif(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_HAIKU)
if(NOT DEFINED ENV{ROOTFS_DIR})
include_directories(SYSTEM /usr/local/include)
@@ -97,6 +98,10 @@ if(CLR_CMAKE_TARGET_LINUX_MUSL)
add_definitions(-DENSURE_PRIMARY_STACK_SIZE)
endif(CLR_CMAKE_TARGET_LINUX_MUSL)
+if(CLR_CMAKE_TARGET_HAIKU)
+ add_definitions(-D_GNU_SOURCE)
+endif(CLR_CMAKE_TARGET_HAIKU)
+
# turn off capability to remove unused functions (which was enabled in debug build with sanitizers)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--no-gc-sections")
@@ -230,6 +235,13 @@ if(CLR_CMAKE_TARGET_OSX)
${LIBUNWIND_DAC_OBJECTS}
)
+ target_include_directories(coreclrpal_dac PUBLIC
+ ${CLR_SRC_NATIVE_DIR}/external/libunwind/include
+ ${CLR_SRC_NATIVE_DIR}/external/libunwind/include/tdep
+ ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind/include
+ ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind/include/tdep
+ )
+
target_compile_definitions(coreclrpal_dac PUBLIC -DUNW_REMOTE_ONLY)
else()
if(NOT FEATURE_CROSSBITNESS)
@@ -239,15 +251,6 @@ else()
endif(NOT FEATURE_CROSSBITNESS)
endif(CLR_CMAKE_TARGET_OSX)
-if(NOT FEATURE_CROSSBITNESS)
- target_include_directories(coreclrpal_dac PUBLIC
- ${CLR_SRC_NATIVE_DIR}/external/libunwind/include
- ${CLR_SRC_NATIVE_DIR}/external/libunwind/include/tdep
- ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind/include
- ${CLR_ARTIFACTS_OBJ_DIR}/external/libunwind/include/tdep
- )
-endif(NOT FEATURE_CROSSBITNESS)
-
# There is only one function exported in 'tracepointprovider.cpp' namely 'PAL_InitializeTracing',
# which is guarded with '#if defined(__linux__)'. On macOS, Xcode issues the following warning:
#
@@ -286,6 +289,14 @@ if(CLR_CMAKE_TARGET_FREEBSD)
)
endif(CLR_CMAKE_TARGET_FREEBSD)
+if(CLR_CMAKE_TARGET_HAIKU)
+ target_link_libraries(coreclrpal
+ PUBLIC
+ bsd
+ ${UNWIND_LIBS}
+ )
+endif(CLR_CMAKE_TARGET_HAIKU)
+
if(CLR_CMAKE_TARGET_LINUX)
# On Android, we don't need to link with gcc_s, pthread and rt
if(NOT CLR_CMAKE_TARGET_ANDROID)
diff --git a/src/coreclr/pal/src/config.h.in b/src/coreclr/pal/src/config.h.in
index e52db481c01c8..b5ddd025f3eb1 100644
--- a/src/coreclr/pal/src/config.h.in
+++ b/src/coreclr/pal/src/config.h.in
@@ -22,6 +22,10 @@
#cmakedefine01 HAVE_PTHREAD_NP_H
#cmakedefine01 HAVE_AUXV_HWCAP_H
#cmakedefine01 HAVE_SYS_PTRACE_H
+#cmakedefine01 HAVE_SYS_UCONTEXT_H
+#cmakedefine01 HAVE_SYS_USER_H
+#cmakedefine01 HAVE_SYS_MOUNT_H
+#cmakedefine01 HAVE_UCONTEXT_H
#cmakedefine01 HAVE_GETAUXVAL
#cmakedefine01 HAVE_KQUEUE
diff --git a/src/coreclr/pal/src/configure.cmake b/src/coreclr/pal/src/configure.cmake
index 5366932629c62..b8cdb3a4df413 100644
--- a/src/coreclr/pal/src/configure.cmake
+++ b/src/coreclr/pal/src/configure.cmake
@@ -48,6 +48,10 @@ check_include_files(semaphore.h HAVE_SEMAPHORE_H)
check_include_files(sys/prctl.h HAVE_PRCTL_H)
check_include_files("sys/auxv.h;asm/hwcap.h" HAVE_AUXV_HWCAP_H)
check_include_files("sys/ptrace.h" HAVE_SYS_PTRACE_H)
+check_include_files("sys/ucontext.h" HAVE_SYS_UCONTEXT_H)
+check_include_files("sys/user.h" HAVE_SYS_USER_H)
+check_include_files("sys/mount.h" HAVE_SYS_MOUNT_H)
+check_include_files(ucontext.h HAVE_UCONTEXT_H)
check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
@@ -79,7 +83,12 @@ set(CMAKE_REQUIRED_LIBRARIES)
check_function_exists(sysctlbyname HAVE_SYSCTLBYNAME)
check_include_files(gnu/lib-names.h HAVE_GNU_LIBNAMES_H)
-check_function_exists(kqueue HAVE_KQUEUE)
+if(CLR_CMAKE_TARGET_HAIKU)
+ # kqueue is broken on Haiku and does not provide the required information in the data field.
+ set(HAVE_KQUEUE 0)
+else()
+ check_function_exists(kqueue HAVE_KQUEUE)
+endif()
check_library_exists(c sched_getaffinity "" HAVE_SCHED_GETAFFINITY)
check_library_exists(c sched_setaffinity "" HAVE_SCHED_SETAFFINITY)
@@ -158,9 +167,11 @@ set(CMAKE_EXTRA_INCLUDE_FILES)
set(CMAKE_EXTRA_INCLUDE_FILES asm/ptrace.h)
check_type_size("struct pt_regs" PT_REGS)
set(CMAKE_EXTRA_INCLUDE_FILES)
-set(CMAKE_EXTRA_INCLUDE_FILES signal.h)
-set(CMAKE_EXTRA_INCLUDE_FILES)
-set(CMAKE_EXTRA_INCLUDE_FILES ucontext.h)
+if(HAVE_UCONTEXT_H)
+ set(CMAKE_EXTRA_INCLUDE_FILES ucontext.h)
+else()
+ set(CMAKE_EXTRA_INCLUDE_FILES signal.h)
+endif()
check_type_size(ucontext_t UCONTEXT_T)
set(CMAKE_EXTRA_INCLUDE_FILES)
set(CMAKE_EXTRA_INCLUDE_FILES pthread.h)
@@ -1245,6 +1256,11 @@ elseif(CLR_CMAKE_TARGET_SUNOS)
set(PAL_PT_READ_D PT_READ_D)
set(PAL_PT_WRITE_D PT_WRITE_D)
set(HAS_FTRUNCATE_LENGTH_ISSUE 0)
+elseif(CLR_CMAKE_TARGET_HAIKU)
+ # Haiku does not have ptrace.
+ set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
+ set(HAS_FTRUNCATE_LENGTH_ISSUE 0)
+ set(HAVE_SCHED_OTHER_ASSIGNABLE 1)
else() # Anything else is Linux
if(NOT HAVE_LTTNG_TRACEPOINT_H AND FEATURE_EVENT_TRACE)
unset(HAVE_LTTNG_TRACEPOINT_H CACHE)
diff --git a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt
index a272bdb58bb43..1e653ecab83a9 100644
--- a/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt
+++ b/src/coreclr/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt
@@ -11,10 +11,10 @@ if(CORECLR_SET_RPATH)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "@loader_path")
endif(CLR_CMAKE_HOST_OSX)
- if(CLR_CMAKE_HOST_LINUX)
+ if(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_HAIKU)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
- endif(CLR_CMAKE_HOST_LINUX)
+ endif(CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_HAIKU)
endif(CORECLR_SET_RPATH)
# Test DLL1
diff --git a/src/coreclr/scripts/coreclr_arguments.py b/src/coreclr/scripts/coreclr_arguments.py
index 4bea9477b8391..c49781bef715b 100644
--- a/src/coreclr/scripts/coreclr_arguments.py
+++ b/src/coreclr/scripts/coreclr_arguments.py
@@ -65,7 +65,7 @@ def __init__(self,
self.valid_arches = ["x64", "x86", "arm", "arm64", "loongarch64", "riscv64", "wasm"]
self.valid_build_types = ["Debug", "Checked", "Release"]
- self.valid_host_os = ["windows", "osx", "linux", "illumos", "solaris", "browser", "android", "wasi"]
+ self.valid_host_os = ["windows", "osx", "linux", "illumos", "solaris", "haiku", "browser", "android", "wasi"]
self.__initialize__(args)
@@ -175,7 +175,7 @@ def verify(self,
def provide_default_host_os():
""" Return a string representing the current host operating system.
- Returns one of: linux, osx, windows, illumos, solaris
+ Returns one of: linux, osx, windows, illumos, solaris, haiku
"""
if sys.platform == "linux" or sys.platform == "linux2":
@@ -187,6 +187,8 @@ def provide_default_host_os():
elif sys.platform.startswith("sunos"):
is_illumos = ('illumos' in subprocess.Popen(["uname", "-o"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].decode('utf-8'))
return 'illumos' if is_illumos else 'solaris'
+ elif sys.platform == "haiku":
+ return "haiku"
else:
print("Unknown OS: %s" % sys.platform)
sys.exit(1)
diff --git a/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj b/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj
index 0c3042ed1dbf1..97a8fa26af2be 100644
--- a/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj
+++ b/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj
@@ -18,15 +18,15 @@
true
true
-
- false
+
+ false
false
true
-
+
diff --git a/src/installer/pkg/projects/netcoreappRIDs.props b/src/installer/pkg/projects/netcoreappRIDs.props
index 4c73b3dcb3c2b..b0f62cee619de 100644
--- a/src/installer/pkg/projects/netcoreappRIDs.props
+++ b/src/installer/pkg/projects/netcoreappRIDs.props
@@ -13,6 +13,7 @@
+
x86
diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props
index 7b4f7b877ee74..8781e78e60c99 100644
--- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props
+++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props
@@ -7,8 +7,8 @@
true
false
-
- false
+
+ false
false
diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json
index 16c038598af93..5356b513ba080 100644
--- a/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json
+++ b/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json
@@ -1728,6 +1728,17 @@
"linux-x64"
]
},
+ "haiku": {
+ "#import": [
+ "unix"
+ ]
+ },
+ "haiku-x64": {
+ "#import": [
+ "haiku",
+ "unix-x64"
+ ]
+ },
"illumos": {
"#import": [
"unix"
diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj
index 67909e99ba391..18a3725ae8d06 100644
--- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj
+++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj
@@ -1,6 +1,6 @@
- $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-solaris;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)
+ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-maccatalyst;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-wasi;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-solaris;$(NetCoreAppCurrent)-haiku;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)
true
$(DefineConstants);HTTP_DLL
true
diff --git a/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj b/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj
index 3cf6d5f597f67..cab844490dd80 100644
--- a/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj
+++ b/src/libraries/System.Net.NetworkInformation/src/System.Net.NetworkInformation.csproj
@@ -1,7 +1,7 @@
true
- $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-solaris;$(NetCoreAppCurrent)
+ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-solaris;$(NetCoreAppCurrent)-haiku;$(NetCoreAppCurrent)
@@ -27,7 +27,7 @@
-
+
@@ -194,7 +194,7 @@
-
+
@@ -202,6 +202,7 @@
+
diff --git a/src/libraries/System.Net.Security/src/System.Net.Security.csproj b/src/libraries/System.Net.Security/src/System.Net.Security.csproj
index a06dbd79b8f67..c504b1639e8f5 100644
--- a/src/libraries/System.Net.Security/src/System.Net.Security.csproj
+++ b/src/libraries/System.Net.Security/src/System.Net.Security.csproj
@@ -1,7 +1,7 @@
true
- $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)
+ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-haiku;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)
$(DefineConstants);PRODUCT
diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
index db2751834350a..4524cdd128b64 100644
--- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
+++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
@@ -44,6 +44,7 @@
$(DefineConstants);TARGET_NETBSD
$(DefineConstants);TARGET_ILLUMOS
$(DefineConstants);TARGET_SOLARIS
+ $(DefineConstants);TARGET_HAIKU
diff --git a/src/libraries/System.Runtime.Serialization.Formatters/tests/System.Runtime.Serialization.Formatters.Tests.csproj b/src/libraries/System.Runtime.Serialization.Formatters/tests/System.Runtime.Serialization.Formatters.Tests.csproj
index cd1cf2dc3e3ef..a521f40739da6 100644
--- a/src/libraries/System.Runtime.Serialization.Formatters/tests/System.Runtime.Serialization.Formatters.Tests.csproj
+++ b/src/libraries/System.Runtime.Serialization.Formatters/tests/System.Runtime.Serialization.Formatters.Tests.csproj
@@ -2,7 +2,7 @@
true
true
- $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-solaris;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetFrameworkCurrent)
+ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-freebsd;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-solaris;$(NetCoreAppCurrent)-haiku;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-osx;$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetFrameworkCurrent)
diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt
index 6909e62fcf0bd..d82f1627eabdb 100644
--- a/src/mono/CMakeLists.txt
+++ b/src/mono/CMakeLists.txt
@@ -304,6 +304,10 @@ elseif(CLR_CMAKE_HOST_OS STREQUAL "sunos")
add_definitions(-DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP -DHOST_SOLARIS -D__EXTENSIONS__ -D_XPG4_2)
elseif(CLR_CMAKE_HOST_OS STREQUAL "freebsd")
set(HOST_FREEBSD 1)
+elseif(CLR_CMAKE_HOST_OS STREQUAL "haiku")
+ set(HOST_HAIKU 1)
+ add_definitions(-D_GNU_SOURCE -D_BSD_SOURCE -D_REENTRANT)
+ add_definitions(-D_THREAD_SAFE)
else()
message(FATAL_ERROR "Host '${CLR_CMAKE_HOST_OS}' not supported.")
endif()
@@ -368,6 +372,9 @@ elseif(TARGET_SYSTEM_NAME STREQUAL "sunos")
elseif(TARGET_SYSTEM_NAME STREQUAL "freebsd")
set(TARGET_UNIX 1)
set(TARGET_FREEBSD 1)
+elseif(TARGET_SYSTEM_NAME STREQUAL "haiku")
+ set(TARGET_UNIX 1)
+ set(TARGET_HAIKU 1)
else()
message(FATAL_ERROR "Target '${TARGET_SYSTEM_NAME}' not supported.")
endif()
@@ -759,6 +766,9 @@ elseif(TARGET_FREEBSD)
set(HAVE_SYS_ICU 1)
set(ICU_INCLUDEDIR "${CROSS_ROOTFS}/usr/local/include")
set(ICU_LIBDIR "${CROSS_ROOTFS}/usr/local/lib")
+elseif(HOST_HAIKU)
+ set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations")
+ set(HAVE_SYS_ICU 1)
else()
message(FATAL_ERROR "Unknown host")
endif()
diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake
index e213783fa28b1..07d707981c864 100644
--- a/src/mono/cmake/configure.cmake
+++ b/src/mono/cmake/configure.cmake
@@ -22,6 +22,10 @@ if(HOST_SOLARIS)
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DGC_SOLARIS_THREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_MMAP -DUSE_MUNMAP -DHOST_SOLARIS -D__EXTENSIONS__ -D_XPG4_2")
endif()
+if(HOST_HAIKU)
+ set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_REENTRANT -D_GNU_SOURCE -D_BSD_SOURCE -D_POSIX_PTHREAD_SEMANTICS")
+endif()
+
if(HOST_WASI)
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WASI_EMULATED_PROCESS_CLOCKS -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN")
endif()
diff --git a/src/mono/mono.proj b/src/mono/mono.proj
index 26c7c470b3447..9c6659cacbba7 100644
--- a/src/mono/mono.proj
+++ b/src/mono/mono.proj
@@ -207,7 +207,7 @@
%(_ActualVersionLines.Identity)
%(_ExpectedVersionLines.Identity)
-
@@ -306,6 +306,13 @@
<_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)/lib/pkgconfig" />
+
+
+ <_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$(CrossToolchainFile)" />
+ <_MonoBuildEnv Include="TARGET_BUILD_ARCH=x64" />
+ <_MonoBuildEnv Include="PKG_CONFIG_PATH=$(MonoCrossDir)/boot/system/lib/pkgconfig" />
+
+
<_MonoCMakeArgs Include="-DCMAKE_TOOLCHAIN_FILE=$(CrossToolchainFile)" />
@@ -433,8 +440,8 @@
-
<_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'wasi', 'include').Replace('\','/'))$(EscapedQuoteW)"/>
diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt
index cca4fea9ca493..33561468dc273 100644
--- a/src/mono/mono/mini/CMakeLists.txt
+++ b/src/mono/mono/mini/CMakeLists.txt
@@ -31,6 +31,8 @@ elseif(HOST_SOLARIS)
set(OS_LIBS socket pthread m ${CMAKE_DL_LIBS})
elseif(HOST_FREEBSD)
set(OS_LIBS pthread m)
+elseif(HOST_HAIKU)
+ set(OS_LIBS network)
endif()
#
@@ -280,7 +282,7 @@ set(posix_sources
if(HOST_DARWIN)
set(os_sources "${darwin_sources};${posix_sources}")
-elseif(HOST_LINUX OR HOST_SOLARIS OR HOST_FREEBSD)
+elseif(HOST_LINUX OR HOST_SOLARIS OR HOST_FREEBSD OR HOST_HAIKU)
set(os_sources "${posix_sources}")
elseif(HOST_WIN32)
set(os_sources "${windows_sources}")
diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt
index 0a3d432e4bbf9..7a14c7c92ed66 100644
--- a/src/native/corehost/apphost/static/CMakeLists.txt
+++ b/src/native/corehost/apphost/static/CMakeLists.txt
@@ -215,6 +215,10 @@ elseif (CLR_CMAKE_TARGET_SUNOS)
LIST(APPEND NATIVE_LIBS
socket
)
+elseif (CLR_CMAKE_TARGET_HAIKU)
+ LIST(APPEND NATIVE_LIBS
+ network
+ )
endif(CLR_CMAKE_TARGET_APPLE)
# On *BSD, we always use the libunwind that's part of the OS
diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt
index 49be22629d41e..3957a83fc46f3 100644
--- a/src/native/libs/CMakeLists.txt
+++ b/src/native/libs/CMakeLists.txt
@@ -92,7 +92,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
add_definitions(-D__APPLE_USE_RFC_3542)
endif ()
- if (CLR_CMAKE_TARGET_LINUX)
+ if (CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_HAIKU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
endif ()
else ()
diff --git a/src/native/libs/Common/pal_config.h.in b/src/native/libs/Common/pal_config.h.in
index 42837a9a557d0..c4843bf8712df 100644
--- a/src/native/libs/Common/pal_config.h.in
+++ b/src/native/libs/Common/pal_config.h.in
@@ -32,6 +32,7 @@
#cmakedefine01 HAVE_MNTINFO
#cmakedefine01 HAVE_STATFS_FSTYPENAME
#cmakedefine01 HAVE_STATVFS_FSTYPENAME
+#cmakedefine01 HAVE_STATVFS_BASETYPE
#cmakedefine01 HAVE_NON_LEGACY_STATFS
#cmakedefine01 HAVE_STRCPY_S
#cmakedefine01 HAVE_STRLCPY
@@ -94,6 +95,7 @@
#cmakedefine01 HAVE_NETPACKET_PACKET_H
#cmakedefine01 HAVE_NET_IF_ARP_H
#cmakedefine01 HAVE_SYS_MNTENT_H
+#cmakedefine01 HAVE_MNTENT_H
#cmakedefine01 HAVE_NET_IFMEDIA_H
#cmakedefine01 HAVE_IOS_NET_IFMEDIA_H
#cmakedefine01 HAVE_LINUX_RTNETLINK_H
@@ -134,6 +136,7 @@
#cmakedefine01 HAVE_TERMIOS_H
#cmakedefine01 HAVE_DLFCN_H
#cmakedefine01 HAVE_PTHREAD_H
+#cmakedefine01 HAVE_SYS_STATFS_H
#cmakedefine01 HAVE_SYS_STATVFS_H
#cmakedefine01 HAVE_NET_IF_H
#cmakedefine01 HAVE_SYS_PROCINFO_H
@@ -147,6 +150,8 @@
#cmakedefine01 HAVE_MAKEDEV_SYSMACROSH
#cmakedefine01 HAVE_GETGRGID_R
#cmakedefine01 HAVE_TERMIOS2
+#cmakedefine01 HAVE_DIRENT_NAME_SIZE
+#cmakedefine01 DIRENT_NAME_SIZE
#ifndef HOST_WASI
#cmakedefine01 HAVE_GETRUSAGE
diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt
index 25f91b4cfab08..edfe1fe1457e8 100644
--- a/src/native/libs/System.Globalization.Native/CMakeLists.txt
+++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt
@@ -129,7 +129,7 @@ if (GEN_SHARED_LIB)
target_link_libraries(System.Globalization.Native
PRIVATE
- dl
+ ${CMAKE_DL_LIBS}
${FOUNDATION}
)
@@ -148,7 +148,7 @@ endif()
install (TARGETS System.Globalization.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs)
-if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_LINUX_MUSL)
+if(NOT CLR_CMAKE_TARGET_APPLE AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_LINUX_MUSL AND NOT CLR_CMAKE_TARGET_HAIKU)
if (GEN_SHARED_LIB)
add_custom_command(TARGET System.Globalization.Native POST_BUILD
COMMENT "Verifying System.Globalization.Native.so dependencies"
diff --git a/src/native/libs/System.IO.Ports.Native/CMakeLists.txt b/src/native/libs/System.IO.Ports.Native/CMakeLists.txt
index 8c548a548273a..a53be1dd8c9b7 100644
--- a/src/native/libs/System.IO.Ports.Native/CMakeLists.txt
+++ b/src/native/libs/System.IO.Ports.Native/CMakeLists.txt
@@ -9,13 +9,19 @@ if (HAVE_TERMIOS2)
list (APPEND PORTS_SOURCES pal_termios2.c)
endif ()
-
if (GEN_SHARED_LIB)
add_library(System.IO.Ports.Native
SHARED
${PORTS_SOURCES}
${VERSION_FILE_PATH}
)
+
+ if (CLR_CMAKE_TARGET_HAIKU)
+ target_link_libraries(System.IO.Ports.Native
+ PRIVATE
+ -lnetwork
+ )
+ endif()
endif()
add_library(System.IO.Ports.Native-Static
diff --git a/src/native/libs/System.Native/extra_libs.cmake b/src/native/libs/System.Native/extra_libs.cmake
index b0fe86b69f4cc..59568825464fd 100644
--- a/src/native/libs/System.Native/extra_libs.cmake
+++ b/src/native/libs/System.Native/extra_libs.cmake
@@ -8,6 +8,8 @@ macro(append_extra_system_libs NativeLibsExtra)
list(APPEND ${NativeLibsExtra} ${INOTIFY_LIBRARY})
elseif (CLR_CMAKE_TARGET_SUNOS)
list(APPEND ${NativeLibsExtra} socket)
+ elseif (CLR_CMAKE_TARGET_HAIKU)
+ list (APPEND ${NativeLibsExtra} network bsd)
endif ()
if (CLR_CMAKE_TARGET_APPLE)
diff --git a/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt b/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt
index f99016281ab39..fdba16b705fbf 100644
--- a/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt
+++ b/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt
@@ -98,12 +98,13 @@ set_target_properties(System.Security.Cryptography.Native.OpenSsl-Static PROPERT
if (GEN_SHARED_LIB)
if (FEATURE_DISTRO_AGNOSTIC_SSL)
- # on macOS and Alpine the link step fails with undefined symbols, and the script doesn't run.
+ # on macOS, Haiku, and Alpine the link step fails with undefined symbols, and the script
+ # doesn't run.
# if the build succeeds, the script would succeed, except it uses a Linux-only command.
#
# on Linux, the build will succeed with undefined symbols, then the script reports them
# and fails the build for us.
- if (NOT APPLE AND NOT CLR_CMAKE_TARGET_LINUX_MUSL)
+ if (NOT APPLE AND NOT CLR_CMAKE_TARGET_LINUX_MUSL AND NOT CLR_CMAKE_TARGET_HAIKU)
add_custom_command(TARGET System.Security.Cryptography.Native.OpenSsl POST_BUILD
COMMENT "Verifying System.Security.Cryptography.Native.OpenSsl.so dependencies"
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-so.sh
diff --git a/src/native/libs/System.Security.Cryptography.Native/extra_libs.cmake b/src/native/libs/System.Security.Cryptography.Native/extra_libs.cmake
index be1d86d62266a..2af0ab2250467 100644
--- a/src/native/libs/System.Security.Cryptography.Native/extra_libs.cmake
+++ b/src/native/libs/System.Security.Cryptography.Native/extra_libs.cmake
@@ -28,11 +28,11 @@ macro(append_extra_cryptography_libs NativeLibsExtra)
if(NOT OPENSSL_FOUND)
message(FATAL_ERROR "!!! Cannot find libssl and System.Security.Cryptography.Native cannot build without it. Try installing libssl-dev (on Linux, but this may vary by distro) or openssl (on macOS) !!!. See the requirements document for your specific operating system: https://github.com/dotnet/runtime/tree/main/docs/workflow/requirements.")
endif(NOT OPENSSL_FOUND)
-
-
+
+
if (FEATURE_DISTRO_AGNOSTIC_SSL OR CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST)
# Link with libdl.so to get the dlopen / dlsym / dlclose
- list(APPEND ${NativeLibsExtra} dl)
+ list(APPEND ${NativeLibsExtra} ${CMAKE_DL_LIBS})
else()
list(APPEND ${NativeLibsExtra} ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})
endif()
diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake
index 4cb8790262129..52e9048c03075 100644
--- a/src/native/libs/configure.cmake
+++ b/src/native/libs/configure.cmake
@@ -353,6 +353,18 @@ check_struct_has_member(
"sys/mount.h"
HAVE_STATVFS_FSTYPENAME)
+check_struct_has_member(
+ "struct statvfs"
+ f_basetype
+ "sys/statvfs.h"
+ HAVE_STATVFS_BASETYPE)
+
+set(CMAKE_EXTRA_INCLUDE_FILES dirent.h)
+check_type_size(
+ "((struct dirent*)0)->d_name"
+ DIRENT_NAME_SIZE)
+set(CMAKE_EXTRA_INCLUDE_FILES)
+
# statfs: Find whether this struct exists
if (HAVE_STATFS_FSTYPENAME OR HAVE_STATVFS_FSTYPENAME)
set (STATFS_INCLUDES sys/mount.h)
@@ -498,10 +510,16 @@ check_symbol_exists(
sys/socket.h
HAVE_ACCEPT4)
+set(PREVIOUS_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+if(CLR_CMAKE_TARGET_HAIKU)
+ set(CMAKE_REQUIRED_LIBRARIES "bsd")
+endif()
+
check_symbol_exists(
kqueue
"sys/types.h;sys/event.h"
HAVE_KQUEUE)
+set(CMAKE_REQUIRED_LIBRARIES ${PREVIOUS_CMAKE_REQUIRED_LIBRARIES})
check_symbol_exists(
disconnectx
@@ -925,6 +943,10 @@ check_include_files(
"pthread.h"
HAVE_PTHREAD_H)
+check_include_files(
+ "sys/statfs.h"
+ HAVE_SYS_STATFS_H)
+
if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
set(HAVE_IOS_NET_ROUTE_H 1)
set(HAVE_IOS_NET_IFMEDIA_H 1)
@@ -986,6 +1008,10 @@ check_include_files(
"sys/mntent.h"
HAVE_SYS_MNTENT_H)
+check_include_files(
+ "mntent.h"
+ HAVE_MNTENT_H)
+
check_include_files(
"stdint.h;net/if_media.h"
HAVE_NET_IFMEDIA_H)
@@ -1145,7 +1171,7 @@ check_symbol_exists(
sys/sysmacros.h
HAVE_MAKEDEV_SYSMACROSH)
-if (NOT HAVE_MAKEDEV_FILEH AND NOT HAVE_MAKEDEV_SYSMACROSH AND NOT CLR_CMAKE_TARGET_WASI)
+if (NOT HAVE_MAKEDEV_FILEH AND NOT HAVE_MAKEDEV_SYSMACROSH AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_HAIKU)
message(FATAL_ERROR "Cannot find the makedev function on this platform.")
endif()
diff --git a/src/native/libs/verify-entrypoints.sh b/src/native/libs/verify-entrypoints.sh
index d85e40075e676..9e89a5abb5d7f 100755
--- a/src/native/libs/verify-entrypoints.sh
+++ b/src/native/libs/verify-entrypoints.sh
@@ -18,6 +18,9 @@ for line in $($nmCommand $1); do
init) ;;
fini) ;;
etext) ;;
+ # _chk_fail & _stack_chk_fail are present in Haiku builds
+ _chk_fail) ;;
+ _stack_chk_fail) ;;
PROCEDURE_LINKAGE_TABLE_) ;;
*) dllList+=(${BASH_REMATCH[1]});;
esac
@@ -36,7 +39,7 @@ diffList=$(echo -n ${entriesList[@]} ${dllList[@]} | tr " " "\n" | sort | uniq -
if [ -n "$diffList" ]; then
echo "ERROR: $2 file did not match entries exported from $1" >&2
- echo "DIFFERENCES FOUND: " >&2
+ echo "DIFFERENCES FOUND: " >&2
echo $diffList | tr " " "," >&2
exit 2
fi
diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props
index fbd2172408146..6bbd6bd247fba 100644
--- a/src/tests/Directory.Build.props
+++ b/src/tests/Directory.Build.props
@@ -149,7 +149,7 @@
- true
+ true
C#
F#
IL
diff --git a/src/tests/JIT/Directed/StructABI/StructABI.csproj b/src/tests/JIT/Directed/StructABI/StructABI.csproj
index 4a7b9d274aa4e..4aa1a87036287 100644
--- a/src/tests/JIT/Directed/StructABI/StructABI.csproj
+++ b/src/tests/JIT/Directed/StructABI/StructABI.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/src/tests/profiler/native/CMakeLists.txt b/src/tests/profiler/native/CMakeLists.txt
index 59a753c56c91c..8d915a9d75033 100644
--- a/src/tests/profiler/native/CMakeLists.txt
+++ b/src/tests/profiler/native/CMakeLists.txt
@@ -48,7 +48,7 @@ add_library(Profiler SHARED ${SOURCES})
if(WIN32)
set(DEPENDENCIES Advapi32.lib oleaut32.lib Ole32.lib)
else(WIN32)
- set(DEPENDENCIES pthread dl)
+ set(DEPENDENCIES pthread ${CMAKE_DL_LIBS})
endif(WIN32)
target_link_libraries(Profiler PUBLIC ${DEPENDENCIES})