What changed, and why it matters
This commit adds build and runtime support for the Haiku operating system to the XMRig cryptocurrency miner. It is a straightforward portability patch: it teaches the build system to recognize Haiku, adjusts compiler flags, adds Haiku to existing OS-specific code branches for byte swapping and thread affinity, and provides Haiku-specific memory allocation fallbacks. There is no indication of any security vulnerability being fixed or introduced.
No security action required. Treat as a normal platform-portability commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff introduces Haiku OS support across CMake build scripts and C++ source files. Changes include: (1) cmake/flags.cmake links statically only against libgcc on Haiku instead of libgcc+libstdc++; (2) cmake/os.cmake defines XMRIG_OS_HAIKU and adds the corresponding preprocessor macro; (3) src/3rdparty/libethash/endian.h uses Haiku’s bswap32/bswap64 for byte order operations; (4) src/base/kernel/Platform_unix.cpp includes Haiku in the no-op setThreadAffinity path when hwloc is disabled; (5) src/crypto/common/VirtualMemory_unix.cpp reports huge pages as unavailable, uses a plain mmap with PROT_EXEC for executable memory, and returns nullptr for large-page allocations on Haiku; (6) src/version.h reports ‘Haiku’ as the OS string. No security-relevant behavior changes are evident for existing supported platforms.
Changed components
cmake/flags.cmakecmake/os.cmakesrc/3rdparty/libethash/endian.hsrc/base/kernel/Platform_unix.cppsrc/crypto/common/VirtualMemory_unix.cppsrc/version.hInspect captured patch +15 / −4
diff --git a/cmake/flags.cmake b/cmake/flags.cmake
index 3b711ac..a36d182 100644
--- a/cmake/flags.cmake
+++ b/cmake/flags.cmake
@@ -46,6 +46,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -Wl,--large-address-aware")
endif()
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif()
diff --git a/cmake/os.cmake b/cmake/os.cmake
index 7496119..3025e0c 100644
--- a/cmake/os.cmake
+++ b/cmake/os.cmake
@@ -19,6 +19,8 @@ else()
set(XMRIG_OS_FREEBSD ON)
elseif(CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
set(XMRIG_OS_OPENBSD ON)
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
+ set(XMRIG_OS_HAIKU ON)
endif()
endif()
@@ -47,6 +49,8 @@ elseif(XMRIG_OS_UNIX)
add_definitions(-DXMRIG_OS_FREEBSD)
elseif (XMRIG_OS_OPENBSD)
add_definitions(-DXMRIG_OS_OPENBSD)
+ elseif (XMRIG_OS_HAIKU)
+ add_definitions(-DXMRIG_OS_HAIKU)
endif()
endif()
diff --git a/src/3rdparty/libethash/endian.h b/src/3rdparty/libethash/endian.h
index f960d74..deb5762 100644
--- a/src/3rdparty/libethash/endian.h
+++ b/src/3rdparty/libethash/endian.h
@@ -31,7 +31,7 @@
#include <libkern/OSByteOrder.h>
#define ethash_swap_u32(input_) OSSwapInt32(input_)
#define ethash_swap_u64(input_) OSSwapInt64(input_)
-#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__HAIKU__)
#define ethash_swap_u32(input_) bswap32(input_)
#define ethash_swap_u64(input_) bswap64(input_)
#elif defined(__OpenBSD__)
diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp
index 0bfa4ff..e53fe58 100644
--- a/src/base/kernel/Platform_unix.cpp
+++ b/src/base/kernel/Platform_unix.cpp
@@ -71,7 +71,7 @@ char *xmrig::Platform::createUserAgent()
#ifndef XMRIG_FEATURE_HWLOC
-#if defined(__DragonFly__) || defined(XMRIG_OS_OPENBSD)
+#if defined(__DragonFly__) || defined(XMRIG_OS_OPENBSD) || defined(XMRIG_OS_HAIKU)
bool xmrig::Platform::setThreadAffinity(uint64_t cpu_id)
{
diff --git a/src/crypto/common/VirtualMemory_unix.cpp b/src/crypto/common/VirtualMemory_unix.cpp
index 003b92e..fa9a3cc 100644
--- a/src/crypto/common/VirtualMemory_unix.cpp
+++ b/src/crypto/common/VirtualMemory_unix.cpp
@@ -86,7 +86,7 @@ bool xmrig::VirtualMemory::isHugepagesAvailable()
{
# ifdef XMRIG_OS_LINUX
return std::ifstream("/proc/sys/vm/nr_hugepages").good() || std::ifstream("/sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages").good();
-# elif defined(XMRIG_OS_MACOS) && defined(XMRIG_ARM)
+# elif defined(XMRIG_OS_MACOS) && defined(XMRIG_ARM) || defined(XMRIG_OS_HAIKU)
return false;
# else
return true;
@@ -156,7 +156,8 @@ void *xmrig::VirtualMemory::allocateExecutableMemory(size_t size, bool hugePages
if (!mem) {
mem = mmap(0, size, PROT_READ | PROT_WRITE | SECURE_PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
}
-
+# elif defined(XMRIG_OS_HAIKU)
+ void *mem = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
# else
void *mem = nullptr;
@@ -181,6 +182,8 @@ void *xmrig::VirtualMemory::allocateLargePagesMemory(size_t size)
void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0);
# elif defined(XMRIG_OS_FREEBSD)
void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0);
+# elif defined(XMRIG_OS_HAIKU)
+ void *mem = nullptr;
# else
void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE | hugePagesFlag(hugePageSize()), 0, 0);
# endif
diff --git a/src/version.h b/src/version.h
index ce36b0a..15a7135 100644
--- a/src/version.h
+++ b/src/version.h
@@ -66,6 +66,8 @@
# define APP_OS "FreeBSD"
#elif defined XMRIG_OS_OPENBSD
# define APP_OS "OpenBSD"
+#elif defined XMRIG_OS_HAIKU
+# define APP_OS "Haiku"
#else
# define APP_OS "Unknown OS"
#endif
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.