Re: [pcre-dev] How do I support pcre1 JIT on all versions?

Startseite
Nachricht löschen
Autor: Ævar Arnfjörð Bjarmason
Datum:  
To: Zoltán Herczeg
CC: Philip Hazel, pcre-dev@exim.org
Betreff: Re: [pcre-dev] How do I support pcre1 JIT on all versions?
On Thu, Jun 1, 2017 at 11:59 AM, Zoltán Herczeg <hzmester@???> wrote:
>> > 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
>> That'll only work if pcre isn't compiled with --disable-jit, if it is
>> even on the latest svn trunk linking against it results in:
>> libgit.a(grep.o): In function `pcre1match':
>> /home/avar/g/git/grep.c:411: undefined reference to `pcre_jit_exec'
>> If you look at pcre_jit_compile.c the whole structure of the file is:
>> #if defined SUPPORT_JIT
>> [...]
>> #define SLJIT_CONFIG_AUTO 1 /* ...and other macros */
>> int
>> PRIV(jit_exec)(const PUBL(extra) *extra_data, const pcre_uchar *subject,
>> [...]
>> #else /* SUPPORT_JIT */
>> [... no definition of pcre_jit_exec ...]
>> #endif
>> I.e. the pcre_jit_exec symbol won't be in the library, and thus
>> linking to it fails, so I need a macro accessible from pcre.h that
>> tells me whether it's going to be there, calling pcre_config() will be
>> too late.
>
> Oh... we have dummy functions for jit stack management, but jit_exec is
> missing from. This is a bug and bad news. Perhaps defining a weak symbol
> could help, but might be not portable enough. Falling back to pcre_exec is
> also an option.


I'm a total noob when it comes to any workarounds in the linker to
mitigate this, but googling around any weak symbol mitigation seems
very compiler/toolchain specific. I'm probably better off just
providing my own compile-time flag for "did you compile your PCRE with
JIT support?".

> Are the SLJIT macros visible outside? That is also something which shouldn't
> be :(


It's not. I was mistaken about that, that ifdef is always false
regardless of whether I compile with JIT or not, I just screwed up in
my testing and sent the E-Mail too quickly.

If I save away the include directory between --disable-jit and
--enable-jit it's exactly the same, i.e. there's no way to tell from a
macro whether pcre_exec_jit is compiled into the library.