rizin/subprojects/packagefiles/pcre2_cross_native/meson.build
Naren Sirigere ab82fc9fa3
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
2026-02-23 16:34:05 +00:00

109 lines
3.3 KiB
Meson

# Copy of PCRE2 library for the native version if a cross build happens.
# Because Meson currently doesn't support subprojects to be native and non-native:
# https://github.com/mesonbuild/meson/issues/10947
project('pcre2_cross_native', 'c', version: '10.47')
cc = meson.get_compiler('c')
pcre2_chartables = configure_file(input : 'src/pcre2_chartables.c.dist',
output : 'pcre2_chartables.c',
copy : true)
pcre2_h = configure_file(input : 'src/pcre2.h.generic',
output : 'pcre2.h',
copy : true)
config_h = configure_file(input : 'src/config.h.generic',
output : 'config.h',
copy : true)
libpcre2_c_args = [
'-DHAVE_CONFIG_H', # Default values from config.h
'-DHAVE_MEMMOVE',
'-DSUPPORT_UNICODE',
'-fvisibility=default',
'-DPCRE2_SYMVERS',
]
pcre2_files = [
'src/pcre2_auto_possess.c',
pcre2_chartables,
'src/pcre2_chkdint.c',
'src/pcre2_compile.c',
'src/pcre2_compile_cgroup.c',
'src/pcre2_compile_class.c',
'src/pcre2_config.c',
'src/pcre2_context.c',
'src/pcre2_convert.c',
'src/pcre2_dfa_match.c',
'src/pcre2_error.c',
'src/pcre2_extuni.c',
'src/pcre2_find_bracket.c',
'src/pcre2_maketables.c',
'src/pcre2_match.c',
'src/pcre2_match_data.c',
'src/pcre2_match_next.c',
'src/pcre2_newline.c',
'src/pcre2_ord2utf.c',
'src/pcre2_pattern_info.c',
'src/pcre2_script_run.c',
'src/pcre2_serialize.c',
'src/pcre2_string_utils.c',
'src/pcre2_study.c',
'src/pcre2_substitute.c',
'src/pcre2_substring.c',
'src/pcre2_tables.c',
'src/pcre2_ucd.c',
'src/pcre2_valid_utf.c',
'src/pcre2_xclass.c',
]
cpu_jit_supported = [ 'aarch64', 'arm', 'mips', 'mips64', 'ppc', 'ppc64', 'riscv32', 'riscv64', 's390x', 'x86', 'x86_64' ]
# 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() not in ['darwin', 'serenity']
libpcre2_c_args += ['-DSUPPORT_JIT']
pcre2_files += ['src/pcre2_jit_compile.c']
endif
if target_machine.system() == 'openbsd'
# jit compilation fails with "no more memory" if wx allocations are allowed.
libpcre2_c_args += ['-DSLJIT_WX_EXECUTABLE_ALLOCATOR']
elif target_machine.system() == 'netbsd'
# jit compilation fails with "no more memory" if wx allocations are allowed.
libpcre2_c_args += ['-DSLJIT_PROT_EXECUTABLE_ALLOCATOR']
endif
pcre2_includes = [
include_directories('.'),
include_directories('src/'),
]
libpcre2_8_cross_native = static_library('pcre2_8_cross_native', pcre2_files,
c_args: libpcre2_c_args + ['-DPCRE2_CODE_UNIT_WIDTH=8', '-DSUPPORT_PCRE2_8'],
include_directories: pcre2_includes,
install: false,
native: true,
)
libpcre2_16_cross_native = static_library('pcre2_16_cross_native', pcre2_files,
c_args: libpcre2_c_args + ['-DPCRE2_CODE_UNIT_WIDTH=16', '-DSUPPORT_PCRE2_16'],
include_directories: pcre2_includes,
install: false,
native: true,
)
libpcre2_32_cross_native = static_library('pcre2_32_cross_native', pcre2_files,
c_args: libpcre2_c_args + ['-DPCRE2_CODE_UNIT_WIDTH=32', '-DSUPPORT_PCRE2_32'],
include_directories: pcre2_includes,
install: false,
native: true,
)
pcre2_cross_native_dep = declare_dependency(
link_with: [ libpcre2_8_cross_native, libpcre2_16_cross_native, libpcre2_32_cross_native ],
include_directories: pcre2_includes
)