Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haiku: Configuration support #86391

Merged
merged 1 commit into from
Oct 24, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/coreclr/.nuget/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
transport packages to flow dependencies anymore -->
<CreatePackedPackage Condition="'$(CreatePackedPackage)' == ''">false</CreatePackedPackage>

<SupportedPackageOSGroups Condition="'$(SupportedPackageOSGroups)' == ''">windows;osx;android;linux;freebsd;netbsd;illumos;solaris</SupportedPackageOSGroups>
<SupportedPackageOSGroups Condition="'$(SupportedPackageOSGroups)' == ''">windows;osx;android;linux;freebsd;netbsd;illumos;solaris;haiku</SupportedPackageOSGroups>
<SupportedPackageOSGroups>;$(SupportedPackageOSGroups);</SupportedPackageOSGroups>

<_isSupportedOSGroup>true</_isSupportedOSGroup>
Expand Down Expand Up @@ -105,6 +105,9 @@
<ItemGroup Condition="$(SupportedPackageOSGroups.Contains(';solaris;'))">
<OfficialBuildRID Include="solaris-x64" />
</ItemGroup>
<ItemGroup Condition="$(SupportedPackageOSGroups.Contains(';haiku;'))">
<OfficialBuildRID Include="haiku-x64" />
</ItemGroup>
Comment on lines +108 to +110
Copy link
Member

Choose a reason for hiding this comment

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

@agocke and @elinor-fung Are we creating new RIDs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without creating a separate RID for Haiku, builds would fail.

This is a result of #90695, which makes certain build components unable to recognize the Haiku RID and therefore cannot resolve some references properly when cross-compiled from an official SDK:

/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.cs(6,88): error CS0234: The type or namespace name 'ZLibException' does not exist in the namespace 'System.IO.Compression' (are you missing an assembly reference?) [/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.csproj]
##vso[task.logissue type=error;sourcepath=/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.cs;linenumber=6;columnnumber=88;code=CS0234;](NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'ZLibException' does not exist in the namespace 'System.IO.Compression' (are you missing an assembly reference?)
/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.cs(7,77): error CS0234: The type or namespace name 'CookieVariant' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.csproj]
##vso[task.logissue type=error;sourcepath=/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.cs;linenumber=7;columnnumber=77;code=CS0234;](NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'CookieVariant' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.cs(8,77): error CS0234: The type or namespace name 'PathList' does not exist in the namespace 'System.Net' (are you missing an assembly reference?) [/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.csproj]
##vso[task.logissue type=error;sourcepath=/home/runner/work/dotnet-builds/dotnet-builds/runtime/src/libraries/shims/System/src/System.cs;linenumber=8;columnnumber=77;code=CS0234;](NETCORE_ENGINEERING_TELEMETRY=Build) The type or namespace name 'PathList' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
  System.Net.Http -> /home/runner/work/dotnet-builds/dotnet-builds/runtime/artifacts/bin/System.Net.Http/Debug/net8.0-haiku/System.Net.Http.dll
  netstandard -> /home/runner/work/dotnet-builds/dotnet-builds/runtime/artifacts/bin/netstandard/Debug/net8.0-haiku/netstandard.dll

Build FAILED.

Copy link
Member

Choose a reason for hiding this comment

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

Are we creating new RIDs?

Yes - for the new base OSes: dotnet/designs#260 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

The new base OSes would be added to the trimmed down 'portable' RID graph (dotnet/sdk#34279) that is in sdk now: https://github.com/dotnet/sdk/blob/main/src/Layout/redist/PortableRuntimeIdentifierGraph.json

The idea is that the sdk is the source of truth for the RID graph that gets used for build / nuget restore and the large runtime.json file in runtime is frozen / no longer updated.

Copy link
Member

Choose a reason for hiding this comment

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

so the process for adding a new OS now is updating the RID graph in dotnet/sdk and then waiting until we pick it up in dotnet/runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've rebased this branch to match the upstream main branch (which contains #92211).

I've also removed the version-specific Haiku RIDs from runtime.json. Should I remove all Haiku RIDs from that graph altogether though?

Copy link
Member

Choose a reason for hiding this comment

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

The old graph is probably staying around for .NET 9 (#92211 (comment)) so it's best to keep haiku in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's best to keep haiku in it.

Just haiku, or also the versioned one (haiku.1 for Haiku R1)?

Copy link
Member

Choose a reason for hiding this comment

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

Just haiku. During a non-portable build, haiku.1 will be automatically added to both graphs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR still keeps haiku, so I guess things should work.

<ItemGroup Condition="$(SupportedPackageOSGroups.Contains(';windows;'))">
<OfficialBuildRID Include="win-x86">
<Platform>x86</Platform>
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<PropertyGroup>
<BuildDll>true</BuildDll>
<BuildDll Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris'">false</BuildDll>
<BuildDll Condition="'$(TargetOS)' == 'netbsd' or '$(TargetOS)' == 'illumos' or '$(TargetOS)' == 'solaris' or '$(TargetOS)' == 'haiku'">false</BuildDll>
<BuildDll Condition="'$(TargetArchitecture)' == 'riscv64'">false</BuildDll>

<BuildPdb>false</BuildPdb>
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/createdump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ endif(CLR_CMAKE_HOST_OSX)
createdump_static
corguids
dbgutil
dl
${CMAKE_DL_LIBS}
)

endif(CLR_CMAKE_HOST_WIN32)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/dbgutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions src/coreclr/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/ilasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/ildasm/exe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/nativeaot/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,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
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/nativeaot/Runtime/unix/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/coreclr/nativeaot/Runtime/unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 22 additions & 11 deletions src/coreclr/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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)
Expand All @@ -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:
#
Expand Down Expand Up @@ -281,6 +284,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)
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/pal/src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions src/coreclr/pal/src/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/scripts/coreclr_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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":
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<PropertyGroup Condition="'$(NativeAotSupported)' != 'true'">
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</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>
<!-- 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 FreeBSD when cross building from Linux. -->
<PublishReadyToRun Condition="'$(TargetOS)' == 'freebsd' and '$(CrossBuild)' == 'true'">false</PublishReadyToRun>
<PublishReadyToRunComposite>true</PublishReadyToRunComposite>
Expand Down
1 change: 1 addition & 0 deletions src/installer/pkg/projects/netcoreappRIDs.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<!-- <OfficialBuildRID Include="netbsd-x64" /> -->
<!-- <OfficialBuildRID Include="illumos-x64" /> -->
<!-- <OfficialBuildRID Include="solaris-x64" /> -->
<!-- <OfficialBuildRID Include="haiku-x64" /> -->
<OfficialBuildRID Include="win-x86">
<Platform>x86</Platform>
</OfficialBuildRID>
Expand Down