1{
2 lib,
3 stdenv,
4 fetchurl,
5 updateAutotoolsGnuConfigScriptsHook,
6 # Causes consistent segfaults on ELFv1 PPC64 when trying to use Perl regex in gnugrep
7 # https://github.com/PCRE2Project/pcre2/issues/762
8 withJitSealloc ? !(stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isAbiElfv1),
9}:
10
11stdenv.mkDerivation rec {
12 pname = "pcre2";
13 version = "10.44";
14
15 src = fetchurl {
16 url = "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-${version}/pcre2-${version}.tar.bz2";
17 hash = "sha256-008C4RPPcZOh6/J3DTrFJwiNSF1OBH7RDl0hfG713pY=";
18 };
19
20 nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ];
21
22 configureFlags = [
23 "--enable-pcre2-16"
24 "--enable-pcre2-32"
25 # only enable jit on supported platforms which excludes Apple Silicon, see https://github.com/zherczeg/sljit/issues/51
26 "--enable-jit=${if stdenv.hostPlatform.isS390x then "no" else "auto"}"
27 ]
28 # fix pcre jit in systemd units that set MemoryDenyWriteExecute=true like gitea
29 ++ lib.optional withJitSealloc "--enable-jit-sealloc";
30
31 outputs = [
32 "bin"
33 "dev"
34 "out"
35 "doc"
36 "man"
37 "devdoc"
38 ];
39
40 postFixup = ''
41 moveToOutput bin/pcre2-config "$dev"
42 '';
43
44 meta = with lib; {
45 homepage = "https://www.pcre.org/";
46 description = "Perl Compatible Regular Expressions";
47 license = licenses.bsd3;
48 maintainers = with maintainers; [ ttuegel ];
49 platforms = platforms.all;
50 pkgConfigModules = [
51 "libpcre2-posix"
52 "libpcre2-8"
53 "libpcre2-16"
54 "libpcre2-32"
55 ];
56 };
57}