Skip to content
25 changes: 25 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,31 @@ sudo make install

Note that you only need to run `make libs` once the first time you build (or if the version of LLVM in the `lib/llvm/src` Git submodule changes).

## Haiku

You'll need additional, non-default software packages on Haiku:

- cmake
- python3.14
- libexecinfo_devel

A quick way to install those is to run following command in the Terminal:

```bash
pkgman install cmake python3.14 libexecinfo_devel
```

Once that's done, rest of the steps are similar to other operating systems:

```bash
make libs
make configure CC=gcc CXX=g++
make build
make install
```

Note that you only need to run `make libs` once the first time you build (or if the version of LLVM in the `lib/llvm/src` Git submodule changes).

## Windows

Building on Windows requires the following:
Expand Down
2 changes: 2 additions & 0 deletions benchmark/libponyc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "BSD")
target_link_libraries(libponyc.benchmarks PRIVATE execinfo)
elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "DragonFly")
target_link_libraries(libponyc.benchmarks PRIVATE execinfo atomic)
elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Haiku")
target_link_libraries(libponyc.benchmarks PRIVATE execinfo atomic gnu)
else()
target_link_libraries(libponyc.benchmarks PRIVATE atomic dl)
target_link_options(libponyc.benchmarks PRIVATE "-static-libstdc++")
Expand Down
2 changes: 2 additions & 0 deletions benchmark/libponyrt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "BSD")
elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "DragonFly")
target_link_libraries(libponyrt.benchmarks PRIVATE execinfo atomic)
target_link_options(libponyrt.benchmarks PRIVATE "-static-libstdc++")
elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Haiku")
target_link_libraries(libponyrt.benchmarks PRIVATE execinfo atomic gnu)
else()
target_link_libraries(libponyrt.benchmarks PRIVATE atomic dl)
target_link_options(libponyrt.benchmarks PRIVATE "-static-libgcc")
Expand Down
3 changes: 3 additions & 0 deletions examples/ifdef/ifdef.pony
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ actor Main
elseif linux then
// Again we know which FFI declaration to use here.
@printf("Hello Linux\n".cstring())
elseif haiku then
// Again we know which FFI declaration to use here.
@printf("Hello Haiku\n".cstring())
else
// And again we know which FFI declaration to use here.
@printf("Hello everyone else\n".cstring())
Expand Down
3 changes: 2 additions & 1 deletion packages/builtin/platform.pony
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ primitive Platform
fun openbsd(): Bool => compile_intrinsic
fun linux(): Bool => compile_intrinsic
fun osx(): Bool => compile_intrinsic
fun posix(): Bool => bsd() or linux() or osx()
fun haiku(): Bool => compile_intrinsic
fun posix(): Bool => bsd() or linux() or osx() or haiku()
fun windows(): Bool => compile_intrinsic

fun x86(): Bool => compile_intrinsic
Expand Down
22 changes: 20 additions & 2 deletions packages/builtin/string.pony
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,16 @@ actor Main
let res = @strtof(ptr.offset(index), addressof endp)
let errno: I32 = @pony_os_errno()
if (errno != 0) or (endp != ptr.offset(_size)) then
error
ifdef haiku then
// Workaround haiku bug with parsing "nan(123)": https://dev.haiku-os.org/ticket/20092
if (errno == 0) and (endp == ptr.offset(_size - 1)) and (this.at_offset(_size.isize() - 1)? == 0x29) then
res
else
error
end
else
error
end
else
res
end
Expand Down Expand Up @@ -1647,7 +1656,16 @@ actor Main
let res = @strtod(ptr.offset(index), addressof endp)
let errno: I32 = @pony_os_errno()
if (errno != 0) or (endp != ptr.offset(_size)) then
error
ifdef haiku then
// Workaround haiku bug with parsing "nan(123)": https://dev.haiku-os.org/ticket/20092
if (errno == 0) and (endp == ptr.offset(_size - 1)) and (this.at_offset(_size.isize() - 1)? == 0x29) then
res
else
error
end
else
error
end
else
res
end
Expand Down
2 changes: 2 additions & 0 deletions packages/files/_file_des.pony
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ primitive _FileDes

ifdef windows then
path.set_time(atime, mtime)
elseif haiku then
path.set_time(atime, mtime)
else
var tv: (ILong, ILong, ILong, ILong) =
( atime._1.ilong(), atime._2.ilong() / 1000,
Expand Down
34 changes: 17 additions & 17 deletions packages/files/directory.pony
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ use @ponyint_o_directory[I32]()
use @ponyint_o_cloexec[I32]()
use @ponyint_at_removedir[I32]()
use @openat[I32](fd: I32, path: Pointer[U8] tag, flags: I32, ...)
if linux or bsd
if linux or bsd or haiku
use @unlinkat[I32](fd: I32, target: Pointer[U8] tag, flags: I32)
use @futimes[I32](fildes: I32, tv: Pointer[(ILong, ILong, ILong, ILong)])
if not windows
if not windows and not haiku
use @renameat[I32](fd: I32, from: Pointer[U8] tag, tofd: I32, to_path: Pointer[U8] tag)
if linux or bsd
use @symlinkat[I32](source: Pointer[U8] tag, fd: I32, dst: Pointer[U8] tag) if linux or bsd
if linux or bsd or haiku
use @symlinkat[I32](source: Pointer[U8] tag, fd: I32, dst: Pointer[U8] tag) if linux or bsd or haiku
use @futimesat[I32](fd: I32, path: Pointer[U8] tag,
timeval: Pointer[(ILong, ILong, ILong, ILong)]) if linux or bsd
use @fchownat[I32](fd: I32, path: Pointer[U8] tag, uid: U32, gid: U32, flags: I32) if linux or bsd
use @fchmodat[I32](fd: I32, path: Pointer[U8] tag, mode: U32, flag: I32) if linux or bsd
use @fchownat[I32](fd: I32, path: Pointer[U8] tag, uid: U32, gid: U32, flags: I32) if linux or bsd or haiku
use @fchmodat[I32](fd: I32, path: Pointer[U8] tag, mode: U32, flag: I32) if linux or bsd or haiku
use @mkdirat[I32](fd: I32, path: Pointer[U8] tag, mode: U32)
use @fdopendir[Pointer[_DirectoryHandle]](fd: I32) if posix
use @opendir[Pointer[_DirectoryHandle]](name: Pointer[U8] tag) if posix
Expand Down Expand Up @@ -124,7 +124,7 @@ class Directory
end

let h =
ifdef linux or bsd then
ifdef linux or bsd or haiku then
let fd =
@openat(fd', ".".cstring(),
@ponyint_o_rdonly()
Expand Down Expand Up @@ -183,7 +183,7 @@ class Directory

let path' = FilePath.from(path, target, path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
let fd' =
@openat(_fd, target.cstring(),
@ponyint_o_rdonly()
Expand All @@ -210,7 +210,7 @@ class Directory
try
let path' = FilePath.from(path, target, path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
var offset: ISize = 0

repeat
Expand Down Expand Up @@ -249,7 +249,7 @@ class Directory

let path' = FilePath.from(path, target, path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
let fd' =
@openat(_fd, target.cstring(),
@ponyint_o_rdwr()
Expand All @@ -274,7 +274,7 @@ class Directory

let path' = FilePath.from(path, target, path.caps - FileWrite)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
let fd' =
@openat(_fd, target.cstring(),
@ponyint_o_rdonly() or @ponyint_o_cloexec(),
Expand Down Expand Up @@ -330,7 +330,7 @@ class Directory

let path' = FilePath.from(path, target, path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
FileInfo._relative(_fd, path', target)?
else
FileInfo(path')?
Expand All @@ -351,7 +351,7 @@ class Directory
try
let path' = FilePath.from(path, target, path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
0 == @fchmodat(_fd, target.cstring(), mode.u32(), I32(0))
else
path'.chmod(mode)
Expand All @@ -375,7 +375,7 @@ class Directory
try
let path' = FilePath.from(path, target, path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
0 == @fchownat(_fd, target.cstring(), uid, gid, I32(0))
else
path'.chown(uid, gid)
Expand Down Expand Up @@ -442,7 +442,7 @@ class Directory
try
let path' = FilePath.from(path, link_name, path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
0 == @symlinkat(source.path.cstring(), _fd, link_name.cstring())
else
source.symlink(path')
Expand All @@ -467,7 +467,7 @@ class Directory
try
let path' = FilePath.from(path, target, path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
let fi = FileInfo(path')?

if fi.directory and not fi.symlink then
Expand Down Expand Up @@ -510,7 +510,7 @@ class Directory
let path' = FilePath.from(path, source, path.caps)?
let path'' = FilePath.from(to.path, target, to.path.caps)?

ifdef linux or bsd then
ifdef linux or bsd or haiku then
0 == @renameat(_fd, source.cstring(), to._fd, target.cstring())
else
path'.rename(path'')
Expand Down
12 changes: 9 additions & 3 deletions packages/files/file.pony
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ primitive FileExists
primitive FilePermissionDenied

primitive _EBADF
fun apply(): I32 => 9
fun apply(): I32 =>
ifdef haiku then -2147459072 // 0x80006000
else 9 end

primitive _EEXIST
fun apply(): I32 => 17
fun apply(): I32 =>
ifdef haiku then -2147459070 // 0x80006002
else 17 end

primitive _EACCES
fun apply(): I32 => 13
fun apply(): I32 =>
ifdef haiku then -2147483646 // 0x80000002
else 13 end

type FileErrNo is
( FileOK
Expand Down
4 changes: 2 additions & 2 deletions packages/net/_test.pony
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ class \nodoc\ _TestPing is UDPNotify
(_, let service) = ip.name()?

let list = if ip.ip4() then
ifdef bsd then
ifdef bsd or haiku then
DNS.ip4(auth, "", service)
else
DNS.broadcast_ip4(auth, service)
end
else
ifdef bsd then
ifdef bsd or haiku then
DNS.ip6(auth, "", service)
else
DNS.broadcast_ip6(auth, service)
Expand Down
9 changes: 8 additions & 1 deletion packages/net/tcp_connection.pony
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,14 @@ actor TCPConnection is AsioEventNotify
_shutdown = true

if _connected then
@pony_os_socket_shutdown(_fd)
// There's some bug in shutdown on Haiku, which never closes socket (it stays in timed wait forever).
// So just force hard_close there.
// TODO: remove it once Haiku OS bug is fixed.
ifdef haiku then
_shutdown_peer = true
else
@pony_os_socket_shutdown(_fd)
end
else
_shutdown_peer = true
end
Expand Down
17 changes: 13 additions & 4 deletions packages/process/_pipe.pony
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,24 @@ use @WriteFile[Bool](handle: Pointer[None], buffer: Pointer[None],
use @GetLastError[I32]() if not posix

primitive _FSETFL
fun apply(): I32 => 4
fun apply(): I32 =>
ifdef haiku then 16
else 4 end

primitive _FGETFL
fun apply(): I32 => 3
fun apply(): I32 =>
ifdef haiku then 8
else 3 end

primitive _FSETFD
fun apply(): I32 => 2
fun apply(): I32 =>
ifdef haiku then 4
else 2 end

primitive _FGETFD
fun apply(): I32 => 1
fun apply(): I32 =>
ifdef haiku then 2
else 1 end

primitive _FDCLOEXEC
fun apply(): I32 => 1
Expand All @@ -40,6 +48,7 @@ primitive _ONONBLOCK
fun apply(): I32 =>
ifdef bsd or osx then 4
elseif linux then 2048
elseif haiku then 128
else compile_error "no O_NONBLOCK" end

// The pipe has been ended.
Expand Down
Loading
Loading