From 9ac39f6acfe96588a0f3d9285d1aa7e29cb0ea98 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 24 Sep 2026 16:03:08 -0300 Subject: [PATCH 1/5] Turn PCRE2's SLJIT dependency into its own CMake library To use it for other purposes. Signed-off-by: Juan Cruz Viotti --- CMakeLists.txt | 1 + cmake/FindPCRE2.cmake | 10 ++- cmake/FindSLJIT.cmake | 28 +++++++ ...e-generator-instead-of-including-its.patch | 73 +++++++++++++++++++ src/core/regex/CMakeLists.txt | 5 ++ vendor/pcre2/src/pcre2_jit_compile.c | 35 ++------- 6 files changed, 123 insertions(+), 29 deletions(-) create mode 100644 cmake/FindSLJIT.cmake create mode 100644 patches/pcre2/0001-Link-the-JIT-code-generator-instead-of-including-its.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d0e39f6e6..8ae4dd906b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,7 @@ if(SOURCEMETA_CORE_CRYPTO) endif() if(SOURCEMETA_CORE_REGEX) + find_package(SLJIT REQUIRED) find_package(PCRE2 REQUIRED) add_subdirectory(src/core/regex) endif() diff --git a/cmake/FindPCRE2.cmake b/cmake/FindPCRE2.cmake index 1a834de0a5..9f0c4db764 100644 --- a/cmake/FindPCRE2.cmake +++ b/cmake/FindPCRE2.cmake @@ -1,4 +1,8 @@ if(NOT PCRE2_FOUND) + # The just-in-time compiler of this library is a code generator that this + # project builds and reasons about on its own + find_package(SLJIT REQUIRED) + set(PCRE2_DIR "${PROJECT_SOURCE_DIR}/vendor/pcre2") set(PCRE2_SOURCE_DIR "${PCRE2_DIR}/src") set(PCRE2_BINARY_DIR "${PROJECT_BINARY_DIR}/pcre2") @@ -93,6 +97,10 @@ if(NOT PCRE2_FOUND) add_library(pcre2 OBJECT ${PCRE2_SOURCES}) sourcemeta_add_default_options(PRIVATE pcre2) + # Public, as the translation unit that drives the code generator has to see + # the configuration it was built with to agree on its structure layouts + target_link_libraries(pcre2 PUBLIC SLJIT::sljit) + if(SOURCEMETA_COMPILER_LLVM OR SOURCEMETA_COMPILER_GCC) target_compile_options(pcre2 PRIVATE -Wno-implicit-int-conversion) target_compile_options(pcre2 PRIVATE -Wno-sign-conversion) @@ -126,8 +134,6 @@ if(NOT PCRE2_FOUND) target_compile_definitions(pcre2 PUBLIC PCRE2_CODE_UNIT_WIDTH=8) target_compile_definitions(pcre2 PRIVATE SUPPORT_PCRE2_8=1) target_compile_definitions(pcre2 PRIVATE SUPPORT_UNICODE=1) - # The just-in-time compiler brings its own code generator in as part of one - # of its translation units, so there is no second library to build for it target_compile_definitions(pcre2 PRIVATE SUPPORT_JIT=1) # Declarations of an import from a shared library of our own build of this # one, which no longer exists, would be unresolvable on Windows diff --git a/cmake/FindSLJIT.cmake b/cmake/FindSLJIT.cmake new file mode 100644 index 0000000000..a0fc85db9a --- /dev/null +++ b/cmake/FindSLJIT.cmake @@ -0,0 +1,28 @@ +if(NOT SLJIT_FOUND) + # This code generator ships inside the regular expression library that + # brought it in, but it stands on its own and other libraries may take it + set(SLJIT_DIR "${PROJECT_SOURCE_DIR}/vendor/pcre2/deps/sljit") + set(SLJIT_SOURCE_DIR "${SLJIT_DIR}/sljit_src") + + # This library ships one source that includes every backend and allocator + # that the target architecture and platform select + # Merged into the library that uses it, so that no archive, no header and + # no CMake package of our own build of it reaches an installed consumer + add_library(sljit OBJECT "${SLJIT_SOURCE_DIR}/sljitLir.c") + sourcemeta_add_default_options(PRIVATE sljit) + + # The compiler structure that this library hands out grows extra members + # under any of the tracing, argument checking, or debugging options, so + # every translation unit that reaches for the header has to be told the + # same configuration that the library itself was built with + target_compile_definitions(sljit PUBLIC SLJIT_CONFIG_AUTO=1) + target_compile_definitions(sljit PUBLIC SLJIT_VERBOSE=0) + target_compile_definitions(sljit PUBLIC SLJIT_DEBUG=0) + + target_include_directories(sljit PUBLIC + "$") + + add_library(SLJIT::sljit ALIAS sljit) + + set(SLJIT_FOUND ON) +endif() diff --git a/patches/pcre2/0001-Link-the-JIT-code-generator-instead-of-including-its.patch b/patches/pcre2/0001-Link-the-JIT-code-generator-instead-of-including-its.patch new file mode 100644 index 0000000000..2777809609 --- /dev/null +++ b/patches/pcre2/0001-Link-the-JIT-code-generator-instead-of-including-its.patch @@ -0,0 +1,73 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Juan Cruz Viotti +Date: Wed, 24 Sep 2026 12:00:00 -0300 +Subject: [PATCH] Link the JIT code generator instead of including its source + +This file textually included the whole of sljitLir.c, which compiled the +code generator into this translation unit with internal linkage and routed +its allocations through the pcre2 general context. That makes it impossible +to treat the code generator as a dependency of its own, or to reuse it from +anywhere else in the tree. + +Include the public header instead and let the build system compile and link +the code generator separately. The configuration macros that change the +layout of struct sljit_compiler now come from the build system, so that both +sides of the interface agree on them, and the code generator falls back to +its own malloc and free rather than the pcre2 general context allocator. + +SSIZE_OF is the one name this file needs that the code generator keeps in +its implementation rather than its header. It takes a parameter, so the +build system cannot carry it as a definition, and it is reproduced here. +--- + src/pcre2_jit_compile.c | 35 ++++++++--------------------------- + 1 file changed, 8 insertions(+), 27 deletions(-) + +diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c +index 105a1dd35..de3f03133 100644 +--- a/src/pcre2_jit_compile.c ++++ b/src/pcre2_jit_compile.c +@@ -49,36 +49,17 @@ POSSIBILITY OF SUCH DAMAGE. + + #ifdef SUPPORT_JIT + +-/* All-in-one: Since we use the JIT compiler only from here, +-we just include it. This way we don't need to touch the build +-system files. */ ++/* The JIT code generator is built as a library of its own, and the build ++system sets its configuration on both sides of the interface, so that this ++translation unit and that library agree on the layout of the structures they ++pass between them. */ + +-#define SLJIT_CONFIG_AUTO 1 +-#define SLJIT_CONFIG_STATIC 1 +-#define SLJIT_VERBOSE 0 ++#include "sljitLir.h" + +-#ifdef PCRE2_DEBUG +-#define SLJIT_DEBUG 1 +-#else +-#define SLJIT_DEBUG 0 +-#endif ++/* A convenience that the code generator keeps private to its implementation, ++reproduced here in terms of the types that its header does publish. */ + +-#define SLJIT_MALLOC(size, allocator_data) pcre2_jit_malloc(size, allocator_data) +-#define SLJIT_FREE(ptr, allocator_data) pcre2_jit_free(ptr, allocator_data) +- +-static void * pcre2_jit_malloc(size_t size, void *allocator_data) +-{ +-pcre2_memctl *allocator = ((pcre2_memctl*)allocator_data); +-return allocator->malloc(size, allocator->memory_data); +-} +- +-static void pcre2_jit_free(void *ptr, void *allocator_data) +-{ +-pcre2_memctl *allocator = ((pcre2_memctl*)allocator_data); +-allocator->free(ptr, allocator->memory_data); +-} +- +-#include "../deps/sljit/sljit_src/sljitLir.c" ++#define SSIZE_OF(type) ((sljit_s32)sizeof(sljit_ ## type)) + + #if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED + #error Unsupported architecture diff --git a/src/core/regex/CMakeLists.txt b/src/core/regex/CMakeLists.txt index f10eec028c..8779843602 100644 --- a/src/core/regex/CMakeLists.txt +++ b/src/core/regex/CMakeLists.txt @@ -5,6 +5,11 @@ if(SOURCEMETA_CORE_INSTALL) sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME regex) endif() +# An object library hands its objects to the targets that name it, and a +# second object library in between only passes on usage requirements, so the +# code generator has to be named here rather than left to the library that +# actually calls into it +target_link_libraries(sourcemeta_core_regex PRIVATE SLJIT::sljit) target_link_libraries(sourcemeta_core_regex PRIVATE PCRE2::pcre2) target_link_libraries(sourcemeta_core_regex PRIVATE sourcemeta::core::text) target_link_libraries(sourcemeta_core_regex PRIVATE sourcemeta::core::unicode) diff --git a/vendor/pcre2/src/pcre2_jit_compile.c b/vendor/pcre2/src/pcre2_jit_compile.c index 105a1dd358..de3f031339 100644 --- a/vendor/pcre2/src/pcre2_jit_compile.c +++ b/vendor/pcre2/src/pcre2_jit_compile.c @@ -49,36 +49,17 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef SUPPORT_JIT -/* All-in-one: Since we use the JIT compiler only from here, -we just include it. This way we don't need to touch the build -system files. */ +/* The JIT code generator is built as a library of its own, and the build +system sets its configuration on both sides of the interface, so that this +translation unit and that library agree on the layout of the structures they +pass between them. */ -#define SLJIT_CONFIG_AUTO 1 -#define SLJIT_CONFIG_STATIC 1 -#define SLJIT_VERBOSE 0 +#include "sljitLir.h" -#ifdef PCRE2_DEBUG -#define SLJIT_DEBUG 1 -#else -#define SLJIT_DEBUG 0 -#endif - -#define SLJIT_MALLOC(size, allocator_data) pcre2_jit_malloc(size, allocator_data) -#define SLJIT_FREE(ptr, allocator_data) pcre2_jit_free(ptr, allocator_data) - -static void * pcre2_jit_malloc(size_t size, void *allocator_data) -{ -pcre2_memctl *allocator = ((pcre2_memctl*)allocator_data); -return allocator->malloc(size, allocator->memory_data); -} - -static void pcre2_jit_free(void *ptr, void *allocator_data) -{ -pcre2_memctl *allocator = ((pcre2_memctl*)allocator_data); -allocator->free(ptr, allocator->memory_data); -} +/* A convenience that the code generator keeps private to its implementation, +reproduced here in terms of the types that its header does publish. */ -#include "../deps/sljit/sljit_src/sljitLir.c" +#define SSIZE_OF(type) ((sljit_s32)sizeof(sljit_ ## type)) #if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED #error Unsupported architecture From 316fb3d097eb4f02e17d111be746ae672d59da9a Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 24 Sep 2026 16:05:29 -0300 Subject: [PATCH 2/5] Re-vendor Signed-off-by: Juan Cruz Viotti --- .../sljit/sljit_src/sljitConfigInternal.h | 8 +- .../sljit/sljit_src/sljitNativeLOONGARCH_64.c | 2 +- .../deps/sljit/sljit_src/sljitNativeMIPS_32.c | 10 -- .../sljit/sljit_src/sljitNativeMIPS_common.c | 92 +++++++++++++------ 4 files changed, 72 insertions(+), 40 deletions(-) diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitConfigInternal.h b/vendor/pcre2/deps/sljit/sljit_src/sljitConfigInternal.h index 9c222349c5..94ce68c379 100644 --- a/vendor/pcre2/deps/sljit/sljit_src/sljitConfigInternal.h +++ b/vendor/pcre2/deps/sljit/sljit_src/sljitConfigInternal.h @@ -147,7 +147,7 @@ extern "C" { #endif /***********************************************************/ -/* Intel Control-flow Enforcement Technology (CET) spport. */ +/* Intel Control-flow Enforcement Technology (CET) support.*/ /***********************************************************/ #ifdef SLJIT_CONFIG_X86 @@ -423,9 +423,15 @@ typedef double sljit_f64; #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_ZERO #elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS) +#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) +#define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT +#define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT +#define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_ZERO +#else /* SLJIT_MIPS_REV < 6 */ #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MAX_INT #define SLJIT_CONV_NAN_FLOAT SLJIT_CONV_RESULT_MAX_INT +#endif /* SLJIT_MIPS_REV >= 6 */ #elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC) #define SLJIT_CONV_MAX_FLOAT SLJIT_CONV_RESULT_MAX_INT #define SLJIT_CONV_MIN_FLOAT SLJIT_CONV_RESULT_MIN_INT diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeLOONGARCH_64.c b/vendor/pcre2/deps/sljit/sljit_src/sljitNativeLOONGARCH_64.c index 83e6e297c2..0fd09d4d04 100644 --- a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeLOONGARCH_64.c +++ b/vendor/pcre2/deps/sljit/sljit_src/sljitNativeLOONGARCH_64.c @@ -2251,7 +2251,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op_src(struct sljit_compiler *comp srcw &= 0x3; if (SLJIT_UNLIKELY(srcw)) FAIL_IF(push_inst(compiler, SLLI_D | RD(TMP_REG1) | RJ(OFFS_REG(src)) | IMM_I12(srcw))); - FAIL_IF(push_inst(compiler, ADD_D | RD(TMP_REG1) | RJ(base) | RK(TMP_REG1))); + FAIL_IF(push_inst(compiler, ADD_D | RD(TMP_REG1) | RJ(base) | RK(!srcw ? OFFS_REG(src) : TMP_REG1))); } else { if (base && srcw <= I12_MAX && srcw >= I12_MIN) return push_inst(compiler,PRELD | RJ(base) | IMM_I12(srcw)); diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_32.c b/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_32.c index 83979617d3..88f7e57b55 100644 --- a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_32.c +++ b/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_32.c @@ -35,12 +35,10 @@ static sljit_s32 emit_copysign(struct sljit_compiler *compiler, sljit_s32 op, if (!is_32) { switch (cpu_feature_list & CPU_FEATURE_FR) { -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 case CPU_FEATURE_FR: mfhc = MFHC1; mthc = MTHC1; break; -#endif /* SLJIT_MIPS_REV >= 2 */ default: src1_r |= (1 << 11); src2_r |= (1 << 11); @@ -115,10 +113,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fset64(struct sljit_compiler *comp FAIL_IF(push_inst(compiler, MTC1 | (u.bin.lo != 0 ? T(TMP_REG1) : TA(0)) | FS(freg), MOVABLE_INS)); switch (cpu_feature_list & CPU_FEATURE_FR) { -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 case CPU_FEATURE_FR: return push_inst(compiler, MTHC1 | (u.bin.hi != 0 ? T(TMP_REG2) : TA(0)) | FS(freg), MOVABLE_INS); -#endif /* SLJIT_MIPS_REV >= 2 */ default: FAIL_IF(push_inst(compiler, MTC1 | (u.bin.hi != 0 ? T(TMP_REG2) : TA(0)) | FS(freg) | (1 << 11), MOVABLE_INS)); break; @@ -153,24 +149,20 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fcopy(struct sljit_compiler *compi FAIL_IF(push_inst(compiler, MFC1 | inst, DR(reg2))); inst = FS(freg) | (1 << 11); -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 if (cpu_feature_list & CPU_FEATURE_FR) { mthc = MTHC1; mfhc = MFHC1; inst = FS(freg); } -#endif /* SLJIT_MIPS_REV >= 2 */ } inst |= T(reg); if (!is_32 && !reg2) { switch (cpu_feature_list & CPU_FEATURE_FR) { -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 case CPU_FEATURE_FR: mthc = MTHC1; mfhc = MFHC1; break; -#endif /* SLJIT_MIPS_REV >= 2 */ default: inst |= (1 << 11); break; @@ -291,11 +283,9 @@ static sljit_s32 call_with_args(struct sljit_compiler *compiler, sljit_s32 arg_t * and its starting offset must be 8 because of alignment. */ SLJIT_ASSERT((*offsets_ptr >> 2) == 2); switch (cpu_feature_list & CPU_FEATURE_FR) { -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 case CPU_FEATURE_FR: prev_ins = MFHC1 | f64_hi | FS(float_arg_count); break; -#endif /* SLJIT_MIPS_REV >= 2 */ default: prev_ins = MFC1 | f64_hi | FS(float_arg_count) | (1 << 11); break; diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_common.c b/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_common.c index 96fa342f94..9315170f30 100644 --- a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_common.c +++ b/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_common.c @@ -249,17 +249,20 @@ static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 4] = { #define LDL (HI(26)) #define LDR (HI(27)) #define LDC1 (HI(53)) +#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) +#define LL (HI(31) | LO(54)) +#define LLD (HI(31) | LO(55)) +#else /* SLJIT_MIPS_REV < 6 */ #define LL (HI(48)) #define LLD (HI(52)) +#endif /* SLJIT_MIPS_REV >= 6 */ #define LUI (HI(15)) #define LW (HI(35)) #define LWL (HI(34)) #define LWR (HI(38)) #define LWC1 (HI(49)) #define MFC1 (HI(17)) -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 #define MFHC1 (HI(17) | (3 << 21)) -#endif /* SLJIT_MIPS_REV >= 2 */ #if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) #define MOD (HI(0) | (3 << 6) | LO(26)) #define MODU (HI(0) | (3 << 6) | LO(27)) @@ -268,9 +271,7 @@ static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 4] = { #define MFLO (HI(0) | LO(18)) #endif /* SLJIT_MIPS_REV >= 6 */ #define MTC1 (HI(17) | (4 << 21)) -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 #define MTHC1 (HI(17) | (7 << 21)) -#endif /* SLJIT_MIPS_REV >= 2 */ #if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) #define MUH (HI(0) | (3 << 6) | LO(24)) #define MUHU (HI(0) | (3 << 6) | LO(25)) @@ -290,8 +291,13 @@ static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 4] = { #define ROTR (HI(0) | (1 << 21) | LO(2)) #define ROTRV (HI(0) | (1 << 6) | LO(6)) #endif /* SLJIT_MIPS_REV >= 2 */ +#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) +#define SC (HI(31) | LO(38)) +#define SCD (HI(31) | LO(39)) +#else /* SLJIT_MIPS_REV < 6 */ #define SC (HI(56)) #define SCD (HI(60)) +#endif /* SLJIT_MIPS_REV >= 6 */ #define SD (HI(63)) #define SDL (HI(44)) #define SDR (HI(45)) @@ -321,10 +327,11 @@ static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 4] = { #define XORI (HI(14)) #if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 1) -#define CLZ (HI(28) | LO(32)) #if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) -#define DCLZ (LO(18)) +#define CLZ ((1 << 6) | LO(16)) +#define DCLZ ((1 << 6) | LO(18)) #else /* SLJIT_MIPS_REV < 6 */ +#define CLZ (HI(28) | LO(32)) #define DCLZ (HI(28) | LO(36)) #define MOVF (HI(0) | (0 << 16) | LO(1)) #define MOVF_S (HI(17) | FMT_S | (0 << 16) | LO(17)) @@ -336,8 +343,13 @@ static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 4] = { #define MOVZ_S (HI(17) | FMT_S | LO(18)) #define MUL (HI(28) | LO(2)) #endif /* SLJIT_MIPS_REV >= 6 */ +#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) +#define PREF (HI(31) | LO(53)) +#define PREF_OFFSET(offset) (((sljit_ins)(offset) & 0x1ff) << 7) +#else /* SLJIT_MIPS_REV < 6 */ #define PREF (HI(51)) #define PREFX (HI(19) | LO(15)) +#endif /* SLJIT_MIPS_REV >= 6 */ #if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 #define SEB (HI(31) | (16 << 6) | LO(32)) #define SEH (HI(31) | (24 << 6) | LO(32)) @@ -442,18 +454,18 @@ static void get_cpu_features(void) #endif /* SLJIT_MIPS_REV >= 5 */ #else sljit_s32 flag = -1; -#ifndef FR_GET_FP_MODE - sljit_f64 zero = 0.0; -#else /* PR_GET_FP_MODE */ + (void)flag; +#ifdef PR_GET_FP_MODE flag = prctl(PR_GET_FP_MODE); - if (flag > 0) + if ((flag & (PR_FP_MODE_FR | PR_FP_MODE_FRE)) == PR_FP_MODE_FR) feature_list |= CPU_FEATURE_FR; -#endif /* FP_GET_PR_MODE */ +#endif /* PR_GET_FP_MODE */ #if ((defined(SLJIT_DETECT_FR) && SLJIT_DETECT_FR == 2) \ || (!defined(PR_GET_FP_MODE) && (!defined(SLJIT_DETECT_FR) || SLJIT_DETECT_FR >= 1))) \ && (defined(__GNUC__) && (defined(__mips) && __mips >= 2)) if (flag < 0) { + sljit_f64 zero = 0.0; __asm__ (".set oddspreg\n" "lwc1 $f17, %0\n" "ldc1 $f16, %1\n" @@ -871,7 +883,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type) if (!cpu_feature_list) get_cpu_features(); - return (cpu_feature_list & CPU_FEATURE_FR) != 0; + return (cpu_feature_list & (CPU_FEATURE_FPU | CPU_FEATURE_FR)) == CPU_FEATURE_FPU; #endif /* SLJIT_CONFIG_MIPS_32 && SLJIT_IS_FPU_AVAILABLE */ case SLJIT_HAS_FPU: if (!cpu_feature_list) @@ -1088,11 +1100,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compi } else if (arg_count < 4) { FAIL_IF(push_inst(compiler, MTC1 | TA(4 + arg_count) | FS(float_arg_count), MOVABLE_INS)); switch (cpu_feature_list & CPU_FEATURE_FR) { -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 case CPU_FEATURE_FR: FAIL_IF(push_inst(compiler, MTHC1 | TA(5 + arg_count) | FS(float_arg_count), MOVABLE_INS)); break; -#endif /* SLJIT_MIPS_REV >= 2 */ default: FAIL_IF(push_inst(compiler, MTC1 | TA(5 + arg_count) | FS(float_arg_count) | (1 << 11), MOVABLE_INS)); break; @@ -2124,8 +2134,8 @@ static SLJIT_INLINE sljit_s32 emit_single_op(struct sljit_compiler *compiler, sl } #if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) - FAIL_IF(push_inst(compiler, SELECT_OP(DMUL, MUL) | S(src1) | T(src2) | D(dst), DR(dst))); FAIL_IF(push_inst(compiler, SELECT_OP(DMUH, MUH) | S(src1) | T(src2) | DA(EQUAL_FLAG), EQUAL_FLAG)); + FAIL_IF(push_inst(compiler, SELECT_OP(DMUL, MUL) | S(src1) | T(src2) | D(dst), DR(dst))); #else /* SLJIT_MIPS_REV < 6 */ FAIL_IF(push_inst(compiler, SELECT_OP(DMULT, MULT) | S(src1) | T(src2), MOVABLE_INS)); FAIL_IF(push_inst(compiler, MFHI | DA(EQUAL_FLAG), EQUAL_FLAG)); @@ -2522,6 +2532,37 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_op0(struct sljit_compiler *compile static sljit_s32 emit_prefetch(struct sljit_compiler *compiler, sljit_s32 src, sljit_sw srcw) { +#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) + sljit_s32 base = src & REG_MASK; + sljit_s32 offset_reg; + + if (!(src & OFFS_REG_MASK)) { + if (srcw <= 0xff && srcw >= -0x100) + return push_inst(compiler, PREF | S(base) | PREF_OFFSET(srcw), MOVABLE_INS); + + FAIL_IF(load_immediate(compiler, DR(TMP_REG1), srcw)); + + if (base != 0) + FAIL_IF(push_inst(compiler, ADDU_W | S(base) | T(TMP_REG1) | D(TMP_REG1), DR(TMP_REG1))); + + return push_inst(compiler, PREF | S(TMP_REG1), MOVABLE_INS); + } + + srcw &= 0x3; + offset_reg = OFFS_REG(src); + + if (SLJIT_UNLIKELY(srcw != 0)) { + FAIL_IF(push_inst(compiler, SLL_W | T(offset_reg) | D(TMP_REG1) | SH_IMM(srcw), DR(TMP_REG1))); + offset_reg = TMP_REG1; + } + + if (base != 0) { + FAIL_IF(push_inst(compiler, ADDU_W | S(base) | T(offset_reg) | D(TMP_REG1), DR(TMP_REG1))); + offset_reg = TMP_REG1; + } + + return push_inst(compiler, PREF | S(offset_reg), MOVABLE_INS); +#else /* SLJIT_MIPS_REV < 6 */ if (!(src & OFFS_REG_MASK)) { if (srcw <= SIMM_MAX && srcw >= SIMM_MIN) return push_inst(compiler, PREF | S(src & REG_MASK) | IMM(srcw), MOVABLE_INS); @@ -2538,6 +2579,7 @@ static sljit_s32 emit_prefetch(struct sljit_compiler *compiler, } return push_inst(compiler, PREFX | S(src & REG_MASK) | T(OFFS_REG(src)), MOVABLE_INS); +#endif /* SLJIT_MIPS_REV >= 6 */ } #endif /* SLJIT_MIPS_REV >= 1 */ @@ -3072,11 +3114,9 @@ static SLJIT_INLINE sljit_s32 sljit_emit_fop1_conv_f64_from_uw(struct sljit_comp FAIL_IF(push_inst(compiler, LUI | T(TMP_REG2) | IMM(0x41e0), UNMOVABLE_INS)); FAIL_IF(push_inst(compiler, MTC1 | TA(0) | FS(TMP_FREG2), UNMOVABLE_INS)); switch (cpu_feature_list & CPU_FEATURE_FR) { -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 case CPU_FEATURE_FR: FAIL_IF(push_inst(compiler, MTHC1 | T(TMP_REG2) | FS(TMP_FREG2), UNMOVABLE_INS)); break; -#endif /* SLJIT_MIPS_REV >= 2 */ default: FAIL_IF(push_inst(compiler, MTC1 | T(TMP_REG2) | FS(TMP_FREG2) | (1 << 11), UNMOVABLE_INS)); #if !defined(SLJIT_MIPS_REV) || SLJIT_MIPS_REV <= 1 @@ -4129,10 +4169,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_mem(struct sljit_compiler *compile sljit_s32 reg, sljit_s32 mem, sljit_sw memw) { - sljit_s32 op = type & 0xff; - sljit_s32 flags = 0; sljit_ins ins; #if !(defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) + sljit_s32 op = type & 0xff; + sljit_s32 flags = 0; sljit_ins ins_right; #endif /* !(SLJIT_MIPS_REV >= 6) */ @@ -4278,8 +4318,6 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_mem(struct sljit_compiler *compile #endif /* SLJIT_MIPS_REV >= 6 */ } -#if !(defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) - SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fmem(struct sljit_compiler *compiler, sljit_s32 type, sljit_s32 freg, sljit_s32 mem, sljit_sw memw) @@ -4287,7 +4325,10 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fmem(struct sljit_compiler *compil CHECK_ERROR(); CHECK(check_sljit_emit_fmem(compiler, type, freg, mem, memw)); - FAIL_IF(update_mem_addr(compiler, &mem, &memw, SIMM_MAX - (type & SLJIT_32) ? 3 : 7)); +#if (defined SLJIT_MIPS_REV && SLJIT_MIPS_REV >= 6) + return sljit_emit_fmem_unaligned(compiler, type, freg, mem, memw); +#else /* !(SLJIT_MIPS_REV >= 6) */ + FAIL_IF(update_mem_addr(compiler, &mem, &memw, SIMM_MAX - ((type & SLJIT_32) ? 3 : 7))); SLJIT_ASSERT(FAST_IS_REG(mem) && mem != TMP_REG2); if (type & SLJIT_MEM_STORE) { @@ -4308,11 +4349,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fmem(struct sljit_compiler *compil FAIL_IF(push_inst(compiler, SWL | S(mem) | T(TMP_REG2) | IMM_F64_FIRST_LEFT(memw), MOVABLE_INS)); FAIL_IF(push_inst(compiler, SWR | S(mem) | T(TMP_REG2) | IMM_F64_FIRST_RIGHT(memw), MOVABLE_INS)); switch (cpu_feature_list & CPU_FEATURE_FR) { -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 case CPU_FEATURE_FR: FAIL_IF(push_inst(compiler, MFHC1 | T(TMP_REG2) | FS(freg), DR(TMP_REG2))); break; -#endif /* SLJIT_MIPS_REV >= 2 */ default: FAIL_IF(push_inst(compiler, MFC1 | T(TMP_REG2) | FS(freg) | (1 << 11), DR(TMP_REG2))); #if !defined(SLJIT_MIPS_REV) || SLJIT_MIPS_REV <= 1 @@ -4352,10 +4391,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fmem(struct sljit_compiler *compil FAIL_IF(push_inst(compiler, LWL | S(mem) | T(TMP_REG2) | IMM_F64_SECOND_LEFT(memw), DR(TMP_REG2))); FAIL_IF(push_inst(compiler, LWR | S(mem) | T(TMP_REG2) | IMM_F64_SECOND_RIGHT(memw), DR(TMP_REG2))); switch (cpu_feature_list & CPU_FEATURE_FR) { -#if defined(SLJIT_MIPS_REV) && SLJIT_MIPS_REV >= 2 case CPU_FEATURE_FR: return push_inst(compiler, MTHC1 | T(TMP_REG2) | FS(freg), MOVABLE_INS); -#endif /* SLJIT_MIPS_REV >= 2 */ default: FAIL_IF(push_inst(compiler, MTC1 | T(TMP_REG2) | FS(freg) | (1 << 11), MOVABLE_INS)); break; @@ -4370,10 +4407,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fmem(struct sljit_compiler *compil FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS)); #endif /* MIPS III */ return SLJIT_SUCCESS; +#endif /* SLJIT_MIPS_REV >= 6 */ } -#endif /* !SLJIT_MIPS_REV || SLJIT_MIPS_REV < 6 */ - #undef IMM_16_SECOND #undef IMM_16_FIRST #undef IMM_F64_SECOND_RIGHT From fb0ca2c4d51cebc1d80dce2d12f28080f62a13ed Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 24 Sep 2026 16:11:58 -0300 Subject: [PATCH 3/5] Separate library Signed-off-by: Juan Cruz Viotti --- DEPENDENCIES | 1 + cmake/FindSLJIT.cmake | 4 +--- vendor/pcre2.mask | 11 +---------- vendor/sljit.mask | 8 ++++++++ vendor/{pcre2/deps => }/sljit/LICENSE | 0 .../sljit_src/allocator_src/sljitExecAllocatorApple.c | 0 .../sljit_src/allocator_src/sljitExecAllocatorCore.c | 0 .../allocator_src/sljitExecAllocatorFreeBSD.c | 0 .../sljit_src/allocator_src/sljitExecAllocatorPosix.c | 0 .../allocator_src/sljitExecAllocatorWindows.c | 0 .../allocator_src/sljitProtExecAllocatorNetBSD.c | 0 .../allocator_src/sljitProtExecAllocatorPosix.c | 0 .../allocator_src/sljitWXExecAllocatorPosix.c | 0 .../allocator_src/sljitWXExecAllocatorWindows.c | 0 vendor/{pcre2/deps => }/sljit/sljit_src/sljitConfig.h | 0 .../{pcre2/deps => }/sljit/sljit_src/sljitConfigCPU.h | 0 .../deps => }/sljit/sljit_src/sljitConfigInternal.h | 0 vendor/{pcre2/deps => }/sljit/sljit_src/sljitLir.c | 0 vendor/{pcre2/deps => }/sljit/sljit_src/sljitLir.h | 0 .../deps => }/sljit/sljit_src/sljitNativeALPHA_64.c | 0 .../deps => }/sljit/sljit_src/sljitNativeARM_32.c | 0 .../deps => }/sljit/sljit_src/sljitNativeARM_64.c | 0 .../deps => }/sljit/sljit_src/sljitNativeARM_T2_32.c | 0 .../sljit/sljit_src/sljitNativeLOONGARCH_64.c | 0 .../deps => }/sljit/sljit_src/sljitNativeMIPS_32.c | 0 .../deps => }/sljit/sljit_src/sljitNativeMIPS_64.c | 0 .../sljit/sljit_src/sljitNativeMIPS_common.c | 0 .../deps => }/sljit/sljit_src/sljitNativePPC_32.c | 0 .../deps => }/sljit/sljit_src/sljitNativePPC_64.c | 0 .../deps => }/sljit/sljit_src/sljitNativePPC_common.c | 0 .../deps => }/sljit/sljit_src/sljitNativeRISCV_32.c | 0 .../deps => }/sljit/sljit_src/sljitNativeRISCV_64.c | 0 .../sljit/sljit_src/sljitNativeRISCV_common.c | 0 .../deps => }/sljit/sljit_src/sljitNativeS390X.c | 0 .../deps => }/sljit/sljit_src/sljitNativeX86_32.c | 0 .../deps => }/sljit/sljit_src/sljitNativeX86_64.c | 0 .../deps => }/sljit/sljit_src/sljitNativeX86_common.c | 0 .../{pcre2/deps => }/sljit/sljit_src/sljitSerialize.c | 0 vendor/{pcre2/deps => }/sljit/sljit_src/sljitUtils.c | 0 vendorpull.mask | 1 + 40 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 vendor/sljit.mask rename vendor/{pcre2/deps => }/sljit/LICENSE (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitExecAllocatorApple.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitExecAllocatorCore.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitExecAllocatorFreeBSD.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitExecAllocatorPosix.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitExecAllocatorWindows.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitProtExecAllocatorNetBSD.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitProtExecAllocatorPosix.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitWXExecAllocatorPosix.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/allocator_src/sljitWXExecAllocatorWindows.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitConfig.h (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitConfigCPU.h (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitConfigInternal.h (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitLir.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitLir.h (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeALPHA_64.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeARM_32.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeARM_64.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeARM_T2_32.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeLOONGARCH_64.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeMIPS_32.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeMIPS_64.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeMIPS_common.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativePPC_32.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativePPC_64.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativePPC_common.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeRISCV_32.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeRISCV_64.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeRISCV_common.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeS390X.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeX86_32.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeX86_64.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitNativeX86_common.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitSerialize.c (100%) rename vendor/{pcre2/deps => }/sljit/sljit_src/sljitUtils.c (100%) diff --git a/DEPENDENCIES b/DEPENDENCIES index 62765b1375..5bd8206eff 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -6,6 +6,7 @@ uritemplate-test https://github.com/uri-templates/uritemplate-test 1eb27ab4462b9 pyca-cryptography https://github.com/pyca/cryptography 9747d06e83764e7f1ea4c04daf134cb8f861700b wycheproof https://github.com/C2SP/wycheproof 6d7cccd0fcb1917368579adeeac10fe802f1b521 pcre2 https://github.com/PCRE2Project/pcre2 pcre2-10.48 +sljit https://github.com/zherczeg/sljit 3908d4c1d46764b7f86e172411e28cec3d0d601c unicodetools https://github.com/unicode-org/unicodetools final-17.0-20250910 jose-cookbook https://github.com/ietf-jose/cookbook 13692b68bfc18b99557a5b1ed311fd5077bfff04 w3c-json-ld https://github.com/w3c/json-ld-api 8654ac22b6cf4f441d2fee915ae634d36b5a8067 diff --git a/cmake/FindSLJIT.cmake b/cmake/FindSLJIT.cmake index a0fc85db9a..1529eeb7cb 100644 --- a/cmake/FindSLJIT.cmake +++ b/cmake/FindSLJIT.cmake @@ -1,7 +1,5 @@ if(NOT SLJIT_FOUND) - # This code generator ships inside the regular expression library that - # brought it in, but it stands on its own and other libraries may take it - set(SLJIT_DIR "${PROJECT_SOURCE_DIR}/vendor/pcre2/deps/sljit") + set(SLJIT_DIR "${PROJECT_SOURCE_DIR}/vendor/sljit") set(SLJIT_SOURCE_DIR "${SLJIT_DIR}/sljit_src") # This library ships one source that includes every backend and allocator diff --git a/vendor/pcre2.mask b/vendor/pcre2.mask index 68b4c4f369..62a4b4e78a 100644 --- a/vendor/pcre2.mask +++ b/vendor/pcre2.mask @@ -47,16 +47,7 @@ doc cmake maint patches -deps/sljit/.github -deps/sljit/docs/ -deps/sljit/test_src/ -deps/sljit/regex_src/ -deps/sljit/.gitignore -deps/sljit/API_CHANGES -deps/sljit/CMakeLists.txt -deps/sljit/GNUmakefile -deps/sljit/INTERNAL_CHANGES -deps/sljit/README.md +deps/sljit src/config.h.generic src/config.h.in src/libpcre2-16.sym.in diff --git a/vendor/sljit.mask b/vendor/sljit.mask new file mode 100644 index 0000000000..3f9b83681d --- /dev/null +++ b/vendor/sljit.mask @@ -0,0 +1,8 @@ +docs/ +test_src/ +regex_src/ +API_CHANGES +CMakeLists.txt +GNUmakefile +INTERNAL_CHANGES +README.md diff --git a/vendor/pcre2/deps/sljit/LICENSE b/vendor/sljit/LICENSE similarity index 100% rename from vendor/pcre2/deps/sljit/LICENSE rename to vendor/sljit/LICENSE diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorApple.c b/vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorApple.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorApple.c rename to vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorApple.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorCore.c b/vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorCore.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorCore.c rename to vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorCore.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorFreeBSD.c b/vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorFreeBSD.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorFreeBSD.c rename to vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorFreeBSD.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorPosix.c b/vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorPosix.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorPosix.c rename to vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorPosix.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorWindows.c b/vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorWindows.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitExecAllocatorWindows.c rename to vendor/sljit/sljit_src/allocator_src/sljitExecAllocatorWindows.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitProtExecAllocatorNetBSD.c b/vendor/sljit/sljit_src/allocator_src/sljitProtExecAllocatorNetBSD.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitProtExecAllocatorNetBSD.c rename to vendor/sljit/sljit_src/allocator_src/sljitProtExecAllocatorNetBSD.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitProtExecAllocatorPosix.c b/vendor/sljit/sljit_src/allocator_src/sljitProtExecAllocatorPosix.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitProtExecAllocatorPosix.c rename to vendor/sljit/sljit_src/allocator_src/sljitProtExecAllocatorPosix.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitWXExecAllocatorPosix.c b/vendor/sljit/sljit_src/allocator_src/sljitWXExecAllocatorPosix.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitWXExecAllocatorPosix.c rename to vendor/sljit/sljit_src/allocator_src/sljitWXExecAllocatorPosix.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitWXExecAllocatorWindows.c b/vendor/sljit/sljit_src/allocator_src/sljitWXExecAllocatorWindows.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/allocator_src/sljitWXExecAllocatorWindows.c rename to vendor/sljit/sljit_src/allocator_src/sljitWXExecAllocatorWindows.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitConfig.h b/vendor/sljit/sljit_src/sljitConfig.h similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitConfig.h rename to vendor/sljit/sljit_src/sljitConfig.h diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitConfigCPU.h b/vendor/sljit/sljit_src/sljitConfigCPU.h similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitConfigCPU.h rename to vendor/sljit/sljit_src/sljitConfigCPU.h diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitConfigInternal.h b/vendor/sljit/sljit_src/sljitConfigInternal.h similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitConfigInternal.h rename to vendor/sljit/sljit_src/sljitConfigInternal.h diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitLir.c b/vendor/sljit/sljit_src/sljitLir.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitLir.c rename to vendor/sljit/sljit_src/sljitLir.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitLir.h b/vendor/sljit/sljit_src/sljitLir.h similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitLir.h rename to vendor/sljit/sljit_src/sljitLir.h diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeALPHA_64.c b/vendor/sljit/sljit_src/sljitNativeALPHA_64.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeALPHA_64.c rename to vendor/sljit/sljit_src/sljitNativeALPHA_64.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeARM_32.c b/vendor/sljit/sljit_src/sljitNativeARM_32.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeARM_32.c rename to vendor/sljit/sljit_src/sljitNativeARM_32.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeARM_64.c b/vendor/sljit/sljit_src/sljitNativeARM_64.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeARM_64.c rename to vendor/sljit/sljit_src/sljitNativeARM_64.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeARM_T2_32.c b/vendor/sljit/sljit_src/sljitNativeARM_T2_32.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeARM_T2_32.c rename to vendor/sljit/sljit_src/sljitNativeARM_T2_32.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeLOONGARCH_64.c b/vendor/sljit/sljit_src/sljitNativeLOONGARCH_64.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeLOONGARCH_64.c rename to vendor/sljit/sljit_src/sljitNativeLOONGARCH_64.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_32.c b/vendor/sljit/sljit_src/sljitNativeMIPS_32.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_32.c rename to vendor/sljit/sljit_src/sljitNativeMIPS_32.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_64.c b/vendor/sljit/sljit_src/sljitNativeMIPS_64.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_64.c rename to vendor/sljit/sljit_src/sljitNativeMIPS_64.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_common.c b/vendor/sljit/sljit_src/sljitNativeMIPS_common.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeMIPS_common.c rename to vendor/sljit/sljit_src/sljitNativeMIPS_common.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativePPC_32.c b/vendor/sljit/sljit_src/sljitNativePPC_32.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativePPC_32.c rename to vendor/sljit/sljit_src/sljitNativePPC_32.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativePPC_64.c b/vendor/sljit/sljit_src/sljitNativePPC_64.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativePPC_64.c rename to vendor/sljit/sljit_src/sljitNativePPC_64.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativePPC_common.c b/vendor/sljit/sljit_src/sljitNativePPC_common.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativePPC_common.c rename to vendor/sljit/sljit_src/sljitNativePPC_common.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeRISCV_32.c b/vendor/sljit/sljit_src/sljitNativeRISCV_32.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeRISCV_32.c rename to vendor/sljit/sljit_src/sljitNativeRISCV_32.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeRISCV_64.c b/vendor/sljit/sljit_src/sljitNativeRISCV_64.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeRISCV_64.c rename to vendor/sljit/sljit_src/sljitNativeRISCV_64.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeRISCV_common.c b/vendor/sljit/sljit_src/sljitNativeRISCV_common.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeRISCV_common.c rename to vendor/sljit/sljit_src/sljitNativeRISCV_common.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeS390X.c b/vendor/sljit/sljit_src/sljitNativeS390X.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeS390X.c rename to vendor/sljit/sljit_src/sljitNativeS390X.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeX86_32.c b/vendor/sljit/sljit_src/sljitNativeX86_32.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeX86_32.c rename to vendor/sljit/sljit_src/sljitNativeX86_32.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeX86_64.c b/vendor/sljit/sljit_src/sljitNativeX86_64.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeX86_64.c rename to vendor/sljit/sljit_src/sljitNativeX86_64.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitNativeX86_common.c b/vendor/sljit/sljit_src/sljitNativeX86_common.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitNativeX86_common.c rename to vendor/sljit/sljit_src/sljitNativeX86_common.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitSerialize.c b/vendor/sljit/sljit_src/sljitSerialize.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitSerialize.c rename to vendor/sljit/sljit_src/sljitSerialize.c diff --git a/vendor/pcre2/deps/sljit/sljit_src/sljitUtils.c b/vendor/sljit/sljit_src/sljitUtils.c similarity index 100% rename from vendor/pcre2/deps/sljit/sljit_src/sljitUtils.c rename to vendor/sljit/sljit_src/sljitUtils.c diff --git a/vendorpull.mask b/vendorpull.mask index 8296796537..a2feab064e 100644 --- a/vendorpull.mask +++ b/vendorpull.mask @@ -29,6 +29,7 @@ vendor/jsontestsuite.mask vendor/referencing-suite.mask vendor/yaml.mask vendor/pcre2.mask +vendor/sljit.mask vendor/yaml-test-suite vendor/yaml-test-suite.mask vendor/uritemplate-test From 9dd8c4873a748f58a439f3ac5de9aea13a627b04 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 24 Sep 2026 16:21:53 -0300 Subject: [PATCH 4/5] Fix Signed-off-by: Juan Cruz Viotti --- cmake/FindSLJIT.cmake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmake/FindSLJIT.cmake b/cmake/FindSLJIT.cmake index 1529eeb7cb..82bd5cde49 100644 --- a/cmake/FindSLJIT.cmake +++ b/cmake/FindSLJIT.cmake @@ -17,6 +17,24 @@ if(NOT SLJIT_FOUND) target_compile_definitions(sljit PUBLIC SLJIT_VERBOSE=0) target_compile_definitions(sljit PUBLIC SLJIT_DEBUG=0) + if(SOURCEMETA_COMPILER_LLVM OR SOURCEMETA_COMPILER_GCC) + # Generated code accumulates into a trailing single-element array that is + # over-allocated and written well past its first element, so the strictest + # interpretation of what counts as a trailing flexible array would treat + # every byte this library emits as running off the end of the object + target_compile_options(sljit PRIVATE -fstrict-flex-arrays=0) + endif() + + if(SOURCEMETA_COMPILER_LLVM) + # The immediate byte of a vector lane instruction is only read back on the + # paths that set it, which the compiler cannot correlate + target_compile_options(sljit PRIVATE -Wno-conditional-uninitialized) + endif() + + if(SOURCEMETA_COMPILER_MSVC) + target_compile_options(sljit PRIVATE /wd4701) + endif() + target_include_directories(sljit PUBLIC "$") From 03ad49008afff965effc6179bb480020e3b9ef32 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 24 Sep 2026 16:24:58 -0300 Subject: [PATCH 5/5] Better Signed-off-by: Juan Cruz Viotti --- cmake/FindPCRE2.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake/FindPCRE2.cmake b/cmake/FindPCRE2.cmake index 9f0c4db764..b3e01f6678 100644 --- a/cmake/FindPCRE2.cmake +++ b/cmake/FindPCRE2.cmake @@ -1,8 +1,4 @@ if(NOT PCRE2_FOUND) - # The just-in-time compiler of this library is a code generator that this - # project builds and reasons about on its own - find_package(SLJIT REQUIRED) - set(PCRE2_DIR "${PROJECT_SOURCE_DIR}/vendor/pcre2") set(PCRE2_SOURCE_DIR "${PCRE2_DIR}/src") set(PCRE2_BINARY_DIR "${PROJECT_BINARY_DIR}/pcre2") @@ -97,6 +93,8 @@ if(NOT PCRE2_FOUND) add_library(pcre2 OBJECT ${PCRE2_SOURCES}) sourcemeta_add_default_options(PRIVATE pcre2) + # The code generator that the just-in-time compiler drives is a dependency + # of its own, which the caller is expected to have satisfied by now # Public, as the translation unit that drives the code generator has to see # the configuration it was built with to agree on its structure layouts target_link_libraries(pcre2 PUBLIC SLJIT::sljit)