Skip to content

HAIKU IMPLEMENTATION#819

Open
yug105 wants to merge 49 commits into
metacall:developfrom
yug105:haiku-metacall-v1
Open

HAIKU IMPLEMENTATION#819
yug105 wants to merge 49 commits into
metacall:developfrom
yug105:haiku-metacall-v1

Conversation

@yug105

@yug105 yug105 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds Haiku platform support: build, CI workflow, and fixes across dynlink, portability, threading, build scripts, CMake, and tests

Changes

Build system

  • tools/metacall-environment.sh + tools/metacall-configure.sh — added Haiku OS detection using uname -s and the Haiku dependency install step via pkgman:

    cmake
    git
    make
    wget
    getconf
    gcc_syslibs_devel
    
  • cmake/CompileOptions.cmake — include the beos OS family in the Unix/macOS compile-options branch so Haiku gets the same hardening/flags treatment

  • cmake/Portability.cmake — removed/commented out the old _GENERATE_EXPORT_HEADER workaround that forced WIN32=1 on Haiku; modern CMake export headers work on Haiku without it

Platform #if coverage — Haiku added to existing platform guards

  • source/format/include/format/format_specifier.h — Haiku has <unistd.h> / POSIX format macros; without this, format specifiers fell into the unsupported branch

  • source/metacall/include/metacall/metacall_fork.h + source/metacall/source/metacall_fork.c — Haiku has POSIX fork() / pid_t, so it joins the Unix fork-safety path. This is what metacall-fork-test exercises, now passing

  • source/metacall/source/metacall_link.c — Haiku has <dlfcn.h>, joins the Unix dlsym() hook path

  • source/threading/include/threading/threading_mutex.h — Haiku has pthreads; use pthread_mutex like the BSDs

  • source/portability/include/portability/portability_path.h — Haiku branch defining PORTABILITY_PATH_SIZE as PATH_MAX with the right headers

  • source/portability/include/portability/portability_executable_path.h — Haiku typedef for the path-length type (size_t)

Haiku-native API corrections

  • source/threading/source/threading_thread_id.c — two fixes:

    • the header is <kernel/OS.h>, not the BeOS-era <be/kernel/OS.h>
    • the current-thread API is find_thread(NULL); thread_get_current_thread_id() is a private/internal function not in Haiku's public headers

CI (haiku-test.yml)

  • New workflow running debug, relwithdebinfo, and release on a Haiku VM via cross-platform-actions

  • Configures debug_server with:

    default_action report
    

    On Haiku, a crashing process doesn't die; debug_server suspends it waiting for a debugger, so in headless CI every crash looks like an infinite hang.

    With this setting, crashes terminate immediately and write a crash report with a stack trace, which the workflow dumps into the log.

Missing symbol at load time (portability / metacall CMakeLists)

  • dl_iterate_phdr() lives in Haiku's libbsd.so, not libroot

  • Haiku's runtime_loader binds all symbols eagerly, so any binary touching the portability code aborted at load with B_MISSING_SYMBOL / exit code 4, with no output

  • Linked bsd on Haiku in both the portability library and the MetaCall unity build

dynlink_impl_beos.cBIND_SELF

  • load_add_on() never deduplicates: calling it on the running executable loads a second copy of the image and re-runs all its static constructors, matching BeOS replicant semantics

  • Replaced the BIND_SELF path with dlopen(NULL), which on Haiku returns the global scope without loading anything — matching the Unix implementation's semantics

  • Symbol lookup branches to dlsym() for the self handle

portability_executable_path.c

  • Had no Haiku branch, so *length was returned uninitialized

  • This caused an out-of-bounds read in portability_path_get_name() and a segfault in dynlink-test

  • Added a branch using get_next_image_info() to find the B_APP_IMAGE path

serial_test.cpp

  • Added __HAIKU__ to the expected pointer-format #if

  • Haiku's %p prints 0xa7ef2, same as Linux

plthook (plthook_detour/CMakeLists.txt)

  • Haiku support for PLT hooking — fixes detour-test and metacall-fork-test

  • Currently fetches from my fork: yug105/plthook, branch haiku-support

@viferga

viferga commented Jun 18, 2026

Copy link
Copy Markdown
Member

Let's review this next week. @yug105 meanwhile you can try to implement it in metacall/plthook-poc so we can ensure the issues are metacall related and not plthook related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants