Add SerenityOS Support (#5905)

* Add serenity to librt whitelist

This patch adds serenity to the list of operating systems that dont require librt to be explicity linked

* Disable PCRE2 JIT compilation

* Remove resolve_heap_tcache implementation

Serenity doesn't implement thread caching in its memory allocator, so tcache resolution is not applicable.

* Define rz_sys_pipe as pipe2 for serenity

* Add serenity identifier to rz_types.h

Define serenity as __UNIX__ like, and set RZ_SYS_OS to 'serenity' if __serenity__ identifier is defined

* Add zlib dependency for libzip
This commit is contained in:
Naren Sirigere 2026-02-23 22:04:05 +05:30 committed by GitHub
parent 17e19ac887
commit ab82fc9fa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21 additions and 5 deletions

View file

@ -890,6 +890,7 @@ static void resolve_tcache_perthread(RZ_NONNULL RzCore *core, const RzHeapConfig
}
}
#if !defined(__serenity__)
RZ_API RZ_OWN bool resolve_heap_tcache(RZ_NONNULL RzCore *core, ut64 arena_base, const RzHeapConfig *config) {
RzDebug *dbg = core->dbg;
@ -904,6 +905,7 @@ RZ_API RZ_OWN bool resolve_heap_tcache(RZ_NONNULL RzCore *core, ut64 arena_base,
return true;
}
#endif
void print_heap_chunk(RzCore *core, ut64 chunk, const RzHeapConfig *config) {
RzConsPrintablePalette *pal = &rz_cons_singleton()->context->pal;
@ -2534,9 +2536,11 @@ RZ_IPI RzCmdStatus rz_cmd_heap_tcache_print_handler(RzCore *core, int argc, cons
return RZ_CMD_STATUS_ERROR;
}
#if !defined(__serenity__)
if (!resolve_heap_tcache(core, m_arena, &config)) {
return RZ_CMD_STATUS_ERROR;
}
#endif
return RZ_CMD_STATUS_OK;
}

View file

@ -127,7 +127,7 @@ extern "C" {
#define __WINDOWS__ 1
#endif
#if defined(EMSCRIPTEN) || defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__) || defined(__QNX__) || defined(__sun) || defined(__HAIKU__)
#if defined(EMSCRIPTEN) || defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__) || defined(__QNX__) || defined(__sun) || defined(__HAIKU__) || defined(__serenity__)
#define __BSD__ 0
#define __UNIX__ 1
#endif
@ -601,6 +601,8 @@ typedef enum {
#define RZ_SYS_OS "freebsd"
#elif defined(__HAIKU__)
#define RZ_SYS_OS "haiku"
#elif defined(__serenity__)
#define RZ_SYS_OS "serenity"
#else
#define RZ_SYS_OS "unknown"
#endif

View file

@ -57,6 +57,9 @@ RZ_API int rz_sys_getpid(void);
#if !HAVE_PIPE || (__UNIX__ && HAVE_PIPE)
RZ_API int rz_sys_pipe(int pipefd[2], bool close_on_exec);
RZ_API int rz_sys_pipe_close(int fd);
#elif defined(__serenity__)
#define rz_sys_pipe pipe2
#define rz_sys_pipe_close close
#else
#define rz_sys_pipe pipe
#define rz_sys_pipe_close close

View file

@ -213,7 +213,7 @@ endif
# Handle PCRE2
cpu_jit_supported = [ 'aarch64', 'arm', 'mips', 'mips64', 'ppc', 'ppc64', 'riscv32', 'riscv64', 's390x', 'x86', 'x86_64' ]
pcre2_jit_supported = target_machine.cpu_family() in cpu_jit_supported and cc.get_id() != 'tcc' and target_machine.system() != 'darwin'
pcre2_jit_supported = target_machine.cpu_family() in cpu_jit_supported and cc.get_id() != 'tcc' and target_machine.system() not in ['darwin', 'serenity']
if pcre2_jit_supported
add_project_arguments(['-DSUPPORTS_PCRE2_JIT'], language: 'c')
endif
@ -394,7 +394,7 @@ foreach it : ccs
if not it_cc.has_function('clock_gettime', prefix: '#include <time.h>') and it_cc.has_header_symbol('features.h', '__GLIBC__')
it_lrt = it_cc.find_library('rt', required: true, static: is_static_build)
endif
have_lrt = not ['windows', 'darwin', 'openbsd', 'android', 'haiku'].contains(it_machine.system())
have_lrt = not ['windows', 'darwin', 'openbsd', 'android', 'haiku', 'serenity'].contains(it_machine.system())
if have_lrt and not it_lrt.found()
it_lrt = it_cc.find_library('rt', required: true, static: is_static_build)
endif
@ -674,6 +674,13 @@ if not libzip_dep.found()
libzip_dep = libzip_proj.get_variable('libzip_dep')
endif
if host_machine.system() == 'serenity' and libzip_dep.found()
zlib_dep = dependency('zlib', required: true, static: is_static_build)
libzip_dep = declare_dependency(
dependencies: [libzip_dep, zlib_dep]
)
endif
# handle zstd dependency
r = run_command(py3_exe, check_meson_subproject_py, 'zstd', check: false)
if r.returncode() == 1 and get_option('subprojects_check')

View file

@ -64,7 +64,7 @@ cpu_jit_supported = [ 'aarch64', 'arm', 'mips', 'mips64', 'ppc', 'ppc64', 'riscv
# tcc doesn't support the MSVC asm syntax PCRE2 uses (`__asm { ... }`).
# Darwin kernel not as well, because of forbidden wx memory.
# It is used in the JIT compiler code.
if cc.get_id() != 'tcc' and target_machine.cpu_family() in cpu_jit_supported and target_machine.system() != 'darwin'
if cc.get_id() != 'tcc' and target_machine.cpu_family() in cpu_jit_supported and target_machine.system() not in ['darwin', 'serenity']
libpcre2_c_args += ['-DSUPPORT_JIT']
pcre2_files += ['src/pcre2_jit_compile.c']
endif

View file

@ -64,7 +64,7 @@ cpu_jit_supported = [ 'aarch64', 'arm', 'mips', 'mips64', 'ppc', 'ppc64', 'riscv
# tcc doesn't support the MSVC asm syntax PCRE2 uses (`__asm { ... }`).
# Darwin kernel not as well, because of forbidden wx memory.
# It is used in the JIT compiler code.
if cc.get_id() != 'tcc' and target_machine.cpu_family() in cpu_jit_supported and target_machine.system() != 'darwin'
if cc.get_id() != 'tcc' and target_machine.cpu_family() in cpu_jit_supported and target_machine.system() not in ['darwin', 'serenity']
libpcre2_c_args += ['-DSUPPORT_JIT']
pcre2_files += ['src/pcre2_jit_compile.c']
endif