Hi,
I would simply use the PCRE version number to detect jit_exec at compile time:
#if (PCRE_MAJOR > 8 || (PCRE_MAJOR == 8 && PCRE_MINOR >= 32))
#define PCRE_JIT_EXEC_AVAILABLE
#endif
Regards,
Zoltan
-------- Eredeti levél --------
Feladó: Ævar Arnfjörð Bjarmason < avarab@gmail.com (Link -> mailto:avarab@gmail.com) >
Dátum: 2017 május 31 18:44:28
Tárgy: How do I support pcre1 JIT on all versions?
Címzett: Philip Hazel < pcre-dev@exim.org (Link -> mailto:pcre-dev@exim.org)
My patch to add JIT support to Git with the PCRE v1 API works all the
way down to PCRE version 7.5 (the last one I could get to compile),
but *only* if I compile the versions that support JIT with
--enable-jit, not --disable-jit.
The problem is that both PCRE_CONFIG_JIT and PCRE_STUDY_JIT_COMPILE
will be defined even when JIT support isn't enabled, so I can't use
them to check if I should ifdef a codepath that uses pcre_jit_exec()
into existence, if a newer pcre library is compiled ith --disable-jit
the git build will fail at link time since there's no such symbol.
I have a hack around this, which as far as I can tell is the only way
to do this, but I'd welcome a different way.
Ever since the JIT support was added back in 2011 these macros have
been conditionally defined:
+#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. */
+
+#define SLJIT_CONFIG_AUTO 1
+#define SLJIT_VERBOSE 0
+#define SLJIT_DEBUG 0
+
+#include "sljit/sljitLir.c"
+
+#if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED
+#error "Unsupported architecture"
+#endif
So I'm guarding code that takes that pcre_exec_jit() codepath with
`#ifdef SLJIT_CONFIG_AUTO`.
This works on all pcre versions, and I'm going to use that unless
someone tells me otherwise.
Also, please apply my patch to the pcrejit docs for a related thing:
https://bugs.exim.org/show_bug.cgi?id=2121
Depending on the follow-ups to this post I'll submit another change to
the docs to note how to support JIT on PCRE v1 with all combinations
of versions & --{disable,enable}-jit.