diff mbox series

Adds pcre2 to base

Message ID 20220519130333.159011-1-dominick.grift@defensec.nl
State New
Headers show
Series Adds pcre2 to base | expand

Commit Message

Dominick Grift May 19, 2022, 1:03 p.m. UTC
In preparation for libselinux-3.4 (libselinux-3.4 requires pcre2)

Changes pcre2 upstream from sourceforge to github because sf is a unofficial mirror that is no longer maintained
Updates pcre2 to version 10.40

prce2 changes since version 10.37:

3103b8f Final file tidies for 10.40
13be26a Adjust code for PR100 to put declarations before code
ba6a5f1 Enable fuzzing of the JIT engine (#100)
d07c967 Fix recursion issue in JIT
4279abb pcre2test: allow using readline headers for libedit (#99)
8ff3ab2 Update README to mention autogen.sh
e612e06 JIT compiler update
64c9baa Update ChangeLog for #96
9c8abdd pcre2test: really allow using libedit when enabled (#96)
f11c268 jit: update SIMD code to latest syntax (#95)
4ca0530 Improve the code generator of recurse in JIT
03654e7 Fixed an issue affecting recursions in JIT
d4fa336 Fix incorrect value reading in JIT.
50a51cb Fixed a unicode properrty matching issue in JIT
f7a7341 Update ucd.c generation script for overlong initializer
eef5740 Remove overlooked excess initializer
dea56d2 JIT compiler update.
111cd47 Fix typo `with-match-limit_depth` -> `with-match-limit-depth` (#83)
fdd9479 Fix incorrect compiling when [Aa] etc. are quantified
419e3c6 Tidy comments
e21345d Extend unicode boolean property bitset index to 12 bit (#81)
e85a81e Correct CMakeLists.txt for MSVC debugger file names
504ff06 Fix overrun bug in recent property name parsing change
360a84e Update descriptive comments in UCD generation.
061e576 Merge scriptx and bidi fields (#78)
7f7d3e8 Documentation update for binary property support
bf35c05 Add -LP and -LS (list properties, list scripts) features to pcre2test.
68fbc19 Support boolean properties in JIT (#76)
06d3a66 Fix bug in modifier listing
87571b5 Update documentation and comments for UCD generation
838cdac Remove vestiges of previous Bidi_Class coding
628a804 Tests for new Boolean properties
ec091e2 Restore lost de-duplication
636569a Initial code for Boolean property support
81d3729 Temporary note in maint/README and update ucptestdata for changes to script numbers
f90542a Improve unicode property abbreviation support (#74)
14dbc6e jit: use correct type when checking for max value (#73)
80205ee ChangeLog entry for PR#72
04ecb26 match: Properly align heapframes for CHERI/Arm's Morello prototype (#72)
534b476 RunGrepTest: Fix tests 132 and 133 when srcdir is relative (#71)
31fb2e5 Suppress compiler fall-through warnings
435140a Fix script extension support on jit (#69)
c24047f Documentation update
e745700 Auto generate unicode property tests. (#67)
d888d36 Update script run code to work with new script extensions coding
6614b28 Implement script extension support in JIT. (#66)
afa4756 Rework script extension handling (#64)
7713f33 Add support for 4-character script abbreviations
af2637e Fix parameter types in the pcre2serialize man page (#63)
98e7d70 Refactor Python scripts for generating Unicode property data
321b559 Ignore Python cache
16c8a84 Arrange to distribute pcre2_ucptables.c
4514ddd Split generated tables from fixed tables
944f0e1 Documentation for script handling update
b297320 Revised script handling (see ChangeLog)
92d7cf1 Very minor code speed up for maximizing character property matches
1d432ee Do bidi synonyms properly
194a153 Correct comment in test
1c41a5b Fix minor issues raised by Clang sanitize
4243515 JIT support for Bidi_Control and Bidi_Class
49b29f8 Add short synonyms for Bidi_Control and Bidi_Class
30abd0a Documentation for Bidi_Control and Bidi_Class
0246c6b Add support for Bidi_Control and Bidi_Class properties
823d4ac Add bidi class and control information to Unicode property data
ba3d0ed Documentation update
4ef0c51 Interpret NULL pointer, zero length as an empty string for subjects and replacements.
7ab2769 Check for NULL replacement in pcre2_substitute()
2a294dd Add check for NULL subject to POSIX regexec().
cb854a9 Add options for NULL pointers to pcre2test.
16dccbc Update ChangeLog for latest patches
ae4e626 match: avoid crash if subject NULL and PCRE2_ZERO_TERMINATED (#53)
d24a1c9 cmake: avoid man3 glob post processing (#48)
055b7ce pcre2grep: remove JFRIEDL_DEBUG obsoleted code (#49)
4a8f5d1 Local updates consequent on ocumentation patches (PR#47).
587b942 doc: formatting/typo fixes to documentation (#47)
c8d31f1 Update ChangeLog for GitHub #52 (adf76faa)
adf76fa pcre2grep: fix build for Hurd (#52)
d144199 Revert an unintended change in JIT repeat detection. (#58)
eb42305 jit: avoid integer wraparound in stack size definition (#42)
4689060 Update ChangeLog for GitHub #37 (acc520924).
acc5209 test: avoid failing RunTest if pcre2test -S is not supported (#37)
bc70a18 Update ChangeLog for GitHub #36 (dae47509) patch.
dae4750 pcre2grep: avoid portability minefield with buffered fseek(stdin) (#36)
1ed34b9 Update version to 10.40-RC1 and fix consequent version test issue.
f19e846 Update ChangeLog for GitHub #35 fix.
7db8784 pcre2grep: correctly handle multiple passes (#35)
072717a Fix very minor typos in documentation: redundant spaces.
35fee41 Final file tidies for 10.39.
3469b13 Update docs and version info for 10.39.
29c37f9 Update ChangeLog for GitHub #32 patch.
128c503 fix building on ancient compilers (#32)
bf2c8cc Update ChangeLog for GitHub commits and generate HTML docs.
87f32b9 Add ChangeLog item for GitHub #29.
7ed39af Create ChangeLog item for issue #28 merge.
3b973eb inttypes and stdint cleanup (#30)
f5e4e10 Update to Unicode 14.0.0 (#29)
d46f186 improve on 'auto' mode for DISABLE_PERCENT_ZT (#28)
c99f073 Documentation minor text fixes.
794470b Merge branch 'master' of github.com:PhilipHazel/pcre2 Documentation update.
179c5d2 Merge pull request #27 from ltrzesniewski/fix-convert-doc
ec0755b Fix option name in pcre2convert docs
8d9e912 Update version number to 10.39-RC1.
51ec2c9 Fix incorrect detection of alternatives in first character search.
0612ed7 Update dates and tidy files for 10.38 release.
507e4dc Fix incorrect loop counter reset when setting lookbehind lengths (ClusterFuzz 38653).
dc5f966 Re-enable an optimization which was unintentionally disabled in 10.35.
8f3e11a Doc file tidies for 10.38-RC1
e2fde18 Prepare for 10.38-RC1 release
857ac92 Minor documentation update
31a4620 Add --allow-lookaround-bsk to pcre2grep
edcc076 Add test files to .gitignore
c232286 Update HTML docs.
21c2669 Lock out \K in lookaround assertions by default, but provide an option to re-enable the old behaviour, just in case.
eea410b Improve code for "starts with" optimization in the interpreters.
d5a61ee Patch to detect (and ignore) symlink loops in pcre2grep.
6c2fe9d Documentation update to clarify ovector usage with DFA matching.
5ff1daf Clarify delimiter handling in pcre2test documentation.
f4beac6 Update minimum CMake version to 3.0.0.
e1cd61c Update README.md to be identical to index.md.
6ee9921 Another tweak needed.
b8c60ce Try another URL format (all one line) for github.io.
b61aa57 Updated all the URLs to better Markdown format.
25bb9de Adjust wording for proper link - first test.
e74a9b6 We need both README.md and index.md (identical).
30036e6 Rename README.md to index.md
a8c4ef7 Another doc tidy.
c2fc6cf Revert "Remove dist-bzip2 from AM_INIT_AUTOMAKE in configure.ac because GitHub does not"
587e46b Ajust so that URLs show as live links.
d8267c2 Create README.md as a mini-overview of PCRE2.
15b692f Fix typo.
4ccef16 Update HTML docs with new URLs etc.
5c0d38b Remove dist-bzip2 from AM_INIT_AUTOMAKE in configure.ac because GitHub does not support .bz2 "assets" for releases so there is no point building it.
23c16e6 Update URLs etc for new infrastructure at GitHub/Googlegroups.
876ba43 Another update to .gitignore. Put some temporary wording in documentation about the infrastructure move.
f64fbed Updated and sorted .gitignore.
2410fbe Apply Jan-Willem Blokland's CMake patches to build both static and shared libraries, plus some other CMake extensions.
d70da76 Fix some documentation typos.
a5389db Fix invalid single character repetition issues in JIT.
3d80cf5 Add s390x to JIT targets.
900921f Minor improvement for s390x SIMD.
1951243 JIT compiler update

Signed-off-by: Dominick Grift <dominick.grift@defensec.nl>
---
Build tested on IP40xx

Once pcre2 makes it to base:
1. Remove pcre2 from packages feed
2. Update SELinux to version 3.4 in base
3. Add pcre to packages feed
4. Remove pcre from base

 package/libs/pcre2/Config.in |  30 ++++++++++
 package/libs/pcre2/Makefile  | 103 +++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)
 create mode 100644 package/libs/pcre2/Config.in
 create mode 100644 package/libs/pcre2/Makefile

Comments

Dominick Grift May 19, 2022, 4:37 p.m. UTC | #1
libselinux-3.4 added a change to encourage using pcre2 instead of pcre.

pcre has been unmaintained for quite some time but libselinux defaulted to using that.
for compatibility. Now libselinux-3.4 defaults to pcre2.

This set adds pcre2 to base, changes to official pcre2 upstream, updates pcre2 version to 10.40 and modifies pcre2 so that libselinux-3.4 can use it. When this set is merged we can update SELinux to version 3.4, remove pcre2 from the packages feed, remove legacy pcre from base and instead add it (back) to the packages feed.
Dominick Grift May 19, 2022, 4:43 p.m. UTC | #2
Dominick Grift <dominick.grift@defensec.nl> writes:

> In preparation for libselinux-3.4 (libselinux-3.4 requires pcre2)

Please ignore this patch.

>
> Changes pcre2 upstream from sourceforge to github because sf is a unofficial mirror that is no longer maintained
> Updates pcre2 to version 10.40
>
> prce2 changes since version 10.37:
>
> 3103b8f Final file tidies for 10.40
> 13be26a Adjust code for PR100 to put declarations before code
> ba6a5f1 Enable fuzzing of the JIT engine (#100)
> d07c967 Fix recursion issue in JIT
> 4279abb pcre2test: allow using readline headers for libedit (#99)
> 8ff3ab2 Update README to mention autogen.sh
> e612e06 JIT compiler update
> 64c9baa Update ChangeLog for #96
> 9c8abdd pcre2test: really allow using libedit when enabled (#96)
> f11c268 jit: update SIMD code to latest syntax (#95)
> 4ca0530 Improve the code generator of recurse in JIT
> 03654e7 Fixed an issue affecting recursions in JIT
> d4fa336 Fix incorrect value reading in JIT.
> 50a51cb Fixed a unicode properrty matching issue in JIT
> f7a7341 Update ucd.c generation script for overlong initializer
> eef5740 Remove overlooked excess initializer
> dea56d2 JIT compiler update.
> 111cd47 Fix typo `with-match-limit_depth` -> `with-match-limit-depth` (#83)
> fdd9479 Fix incorrect compiling when [Aa] etc. are quantified
> 419e3c6 Tidy comments
> e21345d Extend unicode boolean property bitset index to 12 bit (#81)
> e85a81e Correct CMakeLists.txt for MSVC debugger file names
> 504ff06 Fix overrun bug in recent property name parsing change
> 360a84e Update descriptive comments in UCD generation.
> 061e576 Merge scriptx and bidi fields (#78)
> 7f7d3e8 Documentation update for binary property support
> bf35c05 Add -LP and -LS (list properties, list scripts) features to pcre2test.
> 68fbc19 Support boolean properties in JIT (#76)
> 06d3a66 Fix bug in modifier listing
> 87571b5 Update documentation and comments for UCD generation
> 838cdac Remove vestiges of previous Bidi_Class coding
> 628a804 Tests for new Boolean properties
> ec091e2 Restore lost de-duplication
> 636569a Initial code for Boolean property support
> 81d3729 Temporary note in maint/README and update ucptestdata for changes to script numbers
> f90542a Improve unicode property abbreviation support (#74)
> 14dbc6e jit: use correct type when checking for max value (#73)
> 80205ee ChangeLog entry for PR#72
> 04ecb26 match: Properly align heapframes for CHERI/Arm's Morello prototype (#72)
> 534b476 RunGrepTest: Fix tests 132 and 133 when srcdir is relative (#71)
> 31fb2e5 Suppress compiler fall-through warnings
> 435140a Fix script extension support on jit (#69)
> c24047f Documentation update
> e745700 Auto generate unicode property tests. (#67)
> d888d36 Update script run code to work with new script extensions coding
> 6614b28 Implement script extension support in JIT. (#66)
> afa4756 Rework script extension handling (#64)
> 7713f33 Add support for 4-character script abbreviations
> af2637e Fix parameter types in the pcre2serialize man page (#63)
> 98e7d70 Refactor Python scripts for generating Unicode property data
> 321b559 Ignore Python cache
> 16c8a84 Arrange to distribute pcre2_ucptables.c
> 4514ddd Split generated tables from fixed tables
> 944f0e1 Documentation for script handling update
> b297320 Revised script handling (see ChangeLog)
> 92d7cf1 Very minor code speed up for maximizing character property matches
> 1d432ee Do bidi synonyms properly
> 194a153 Correct comment in test
> 1c41a5b Fix minor issues raised by Clang sanitize
> 4243515 JIT support for Bidi_Control and Bidi_Class
> 49b29f8 Add short synonyms for Bidi_Control and Bidi_Class
> 30abd0a Documentation for Bidi_Control and Bidi_Class
> 0246c6b Add support for Bidi_Control and Bidi_Class properties
> 823d4ac Add bidi class and control information to Unicode property data
> ba3d0ed Documentation update
> 4ef0c51 Interpret NULL pointer, zero length as an empty string for subjects and replacements.
> 7ab2769 Check for NULL replacement in pcre2_substitute()
> 2a294dd Add check for NULL subject to POSIX regexec().
> cb854a9 Add options for NULL pointers to pcre2test.
> 16dccbc Update ChangeLog for latest patches
> ae4e626 match: avoid crash if subject NULL and PCRE2_ZERO_TERMINATED (#53)
> d24a1c9 cmake: avoid man3 glob post processing (#48)
> 055b7ce pcre2grep: remove JFRIEDL_DEBUG obsoleted code (#49)
> 4a8f5d1 Local updates consequent on ocumentation patches (PR#47).
> 587b942 doc: formatting/typo fixes to documentation (#47)
> c8d31f1 Update ChangeLog for GitHub #52 (adf76faa)
> adf76fa pcre2grep: fix build for Hurd (#52)
> d144199 Revert an unintended change in JIT repeat detection. (#58)
> eb42305 jit: avoid integer wraparound in stack size definition (#42)
> 4689060 Update ChangeLog for GitHub #37 (acc520924).
> acc5209 test: avoid failing RunTest if pcre2test -S is not supported (#37)
> bc70a18 Update ChangeLog for GitHub #36 (dae47509) patch.
> dae4750 pcre2grep: avoid portability minefield with buffered fseek(stdin) (#36)
> 1ed34b9 Update version to 10.40-RC1 and fix consequent version test issue.
> f19e846 Update ChangeLog for GitHub #35 fix.
> 7db8784 pcre2grep: correctly handle multiple passes (#35)
> 072717a Fix very minor typos in documentation: redundant spaces.
> 35fee41 Final file tidies for 10.39.
> 3469b13 Update docs and version info for 10.39.
> 29c37f9 Update ChangeLog for GitHub #32 patch.
> 128c503 fix building on ancient compilers (#32)
> bf2c8cc Update ChangeLog for GitHub commits and generate HTML docs.
> 87f32b9 Add ChangeLog item for GitHub #29.
> 7ed39af Create ChangeLog item for issue #28 merge.
> 3b973eb inttypes and stdint cleanup (#30)
> f5e4e10 Update to Unicode 14.0.0 (#29)
> d46f186 improve on 'auto' mode for DISABLE_PERCENT_ZT (#28)
> c99f073 Documentation minor text fixes.
> 794470b Merge branch 'master' of github.com:PhilipHazel/pcre2 Documentation update.
> 179c5d2 Merge pull request #27 from ltrzesniewski/fix-convert-doc
> ec0755b Fix option name in pcre2convert docs
> 8d9e912 Update version number to 10.39-RC1.
> 51ec2c9 Fix incorrect detection of alternatives in first character search.
> 0612ed7 Update dates and tidy files for 10.38 release.
> 507e4dc Fix incorrect loop counter reset when setting lookbehind lengths (ClusterFuzz 38653).
> dc5f966 Re-enable an optimization which was unintentionally disabled in 10.35.
> 8f3e11a Doc file tidies for 10.38-RC1
> e2fde18 Prepare for 10.38-RC1 release
> 857ac92 Minor documentation update
> 31a4620 Add --allow-lookaround-bsk to pcre2grep
> edcc076 Add test files to .gitignore
> c232286 Update HTML docs.
> 21c2669 Lock out \K in lookaround assertions by default, but provide
> an option to re-enable the old behaviour, just in case.
> eea410b Improve code for "starts with" optimization in the interpreters.
> d5a61ee Patch to detect (and ignore) symlink loops in pcre2grep.
> 6c2fe9d Documentation update to clarify ovector usage with DFA matching.
> 5ff1daf Clarify delimiter handling in pcre2test documentation.
> f4beac6 Update minimum CMake version to 3.0.0.
> e1cd61c Update README.md to be identical to index.md.
> 6ee9921 Another tweak needed.
> b8c60ce Try another URL format (all one line) for github.io.
> b61aa57 Updated all the URLs to better Markdown format.
> 25bb9de Adjust wording for proper link - first test.
> e74a9b6 We need both README.md and index.md (identical).
> 30036e6 Rename README.md to index.md
> a8c4ef7 Another doc tidy.
> c2fc6cf Revert "Remove dist-bzip2 from AM_INIT_AUTOMAKE in configure.ac because GitHub does not"
> 587e46b Ajust so that URLs show as live links.
> d8267c2 Create README.md as a mini-overview of PCRE2.
> 15b692f Fix typo.
> 4ccef16 Update HTML docs with new URLs etc.
> 5c0d38b Remove dist-bzip2 from AM_INIT_AUTOMAKE in configure.ac
> because GitHub does not support .bz2 "assets" for releases so there is
> no point building it.
> 23c16e6 Update URLs etc for new infrastructure at GitHub/Googlegroups.
> 876ba43 Another update to .gitignore. Put some temporary wording in documentation about the infrastructure move.
> f64fbed Updated and sorted .gitignore.
> 2410fbe Apply Jan-Willem Blokland's CMake patches to build both static
> and shared libraries, plus some other CMake extensions.
> d70da76 Fix some documentation typos.
> a5389db Fix invalid single character repetition issues in JIT.
> 3d80cf5 Add s390x to JIT targets.
> 900921f Minor improvement for s390x SIMD.
> 1951243 JIT compiler update
>
> Signed-off-by: Dominick Grift <dominick.grift@defensec.nl>
> ---
> Build tested on IP40xx
>
> Once pcre2 makes it to base:
> 1. Remove pcre2 from packages feed
> 2. Update SELinux to version 3.4 in base
> 3. Add pcre to packages feed
> 4. Remove pcre from base
>
>  package/libs/pcre2/Config.in |  30 ++++++++++
>  package/libs/pcre2/Makefile  | 103 +++++++++++++++++++++++++++++++++++
>  2 files changed, 133 insertions(+)
>  create mode 100644 package/libs/pcre2/Config.in
>  create mode 100644 package/libs/pcre2/Makefile
>
> diff --git a/package/libs/pcre2/Config.in b/package/libs/pcre2/Config.in
> new file mode 100644
> index 0000000000..8777a4e84c
> --- /dev/null
> +++ b/package/libs/pcre2/Config.in
> @@ -0,0 +1,30 @@
> +config PCRE2_JIT_ENABLED
> +	bool
> +	depends on PACKAGE_libpcre2 && (aarch64 || aarch64_be || arm || i386 || i686 || x86_64 || mips || mipsel || mips64 || mips64el || powerpc || powerpc64 || powerpcle || sparc)
> +	default y if (arm || i686 || x86_64)
> +	prompt "Enable JIT compiler support"
> +	help
> +		Enable JIT (Just-In-Time) compiler support.
> +
> +		Just-in-time compiling is a heavyweight optimization that can greatly
> +		speed up pattern matching. However, it comes at the cost of extra
> +		processing before the match is performed, so it is of most benefit when
> +		the same pattern is going to be matched many times. This does not
> +		necessarily mean many calls of a matching function; if the pattern is
> +		not anchored, matching attempts may take place many times at various
> +		positions in the subject, even for a single call. Therefore, if the
> +		subject string is very long, it may still pay to use JIT even for
> +		one-off matches. JIT support is available for all of the 8-bit, 16-bit
> +		and 32-bit PCRE2 libraries and adds about 100KB to the resulting
> +		libpcre2.so. JIT support applies only to the traditional Perl-compatible
> +		matching function. It does not apply when the DFA matching function is
> +		being used.
> +
> +		Enabling this option can give an about 10x performance increase on JIT
> +		operations. It can be desireable for e.g. high performance Apache
> +		mod_rewrite or HA-Proxy reqrep operations.
> +
> +		However, JIT should _only_ be enabled on architectures that are supported.
> +		Enabling JIT on unsupported platforms will result in a compilation
> +		failure. A list of supported architectures can be found here:
> +		https://pcre.org/current/doc/html/pcre2jit.html#SEC2
> diff --git a/package/libs/pcre2/Makefile b/package/libs/pcre2/Makefile
> new file mode 100644
> index 0000000000..e68364a401
> --- /dev/null
> +++ b/package/libs/pcre2/Makefile
> @@ -0,0 +1,103 @@
> +#
> +# Copyright (C) 2017 Shane Peelar
> +#
> +# This is free software, licensed under the GNU General Public License v2.
> +# See /LICENSE for more information.
> +#
> +
> +include $(TOPDIR)/rules.mk
> +
> +PKG_NAME:=pcre2
> +PKG_VERSION:=10.40
> +PKG_RELEASE:=1
> +
> +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
> +PKG_SOURCE_URL:=https://github.com/pcre2project/pcre2/releases/download/$(PKG_NAME)-$(PKG_VERSION)
> +PKG_HASH:=14e4b83c4783933dc17e964318e6324f7cae1bc75d8f3c79bc6969f00c159d68
> +
> +PKG_MAINTAINER:=Shane Peelar <lookatyouhacker@gmail.com>
> +PKG_LICENSE:=BSD-3-Clause
> +PKG_LICENSE_FILES:=LICENCE
> +PKG_CPE_ID:=cpe:/a:pcre:pcre
> +
> +PKG_INSTALL:=1
> +PKG_BUILD_PARALLEL:=1
> +
> +PKG_CONFIG_DEPENDS:=\
> +	CONFIG_PACKAGE_libpcre2-16 \
> +	CONFIG_PACKAGE_libpcre2-32 \
> +	CONFIG_PCRE2_JIT_ENABLED
> +
> +include $(INCLUDE_DIR)/package.mk
> +include $(INCLUDE_DIR)/cmake.mk
> +include $(INCLUDE_DIR)/host-build.mk
> +
> +define Package/libpcre2/default
> +  SECTION:=libs
> +  CATEGORY:=Libraries
> +  URL:=https://www.pcre.org/
> +endef
> +
> +define Package/libpcre2/config
> +  source "$(SOURCE)/Config.in"
> +endef
> +
> +define Package/libpcre2
> +  $(call Package/libpcre2/default)
> +  TITLE:=A Perl Compatible Regular Expression library
> +endef
> +
> +define Package/libpcre2-16
> +  $(call Package/libpcre2/default)
> +  TITLE:=A Perl Compatible Regular Expression library (16bit support)
> +endef
> +
> +define Package/libpcre2-32
> +  $(call Package/libpcre2/default)
> +  TITLE:=A Perl Compatible Regular Expression library (32bit support)
> +endef
> +
> +CMAKE_OPTIONS += \
> +	-DBUILD_SHARED_LIBS=ON \
> +	-DPCRE2_BUILD_PCRE2_8=ON \
> +	-DPCRE2_BUILD_PCRE2_16=O$(if $(CONFIG_PACKAGE_libpcre2-16),N,FF) \
> +	-DPCRE2_BUILD_PCRE2_32=O$(if $(CONFIG_PACKAGE_libpcre2-32),N,FF) \
> +	-DPCRE2_DEBUG=OFF \
> +	-DPCRE2_DISABLE_PERCENT_ZT=ON \
> +	-DPCRE2_SUPPORT_JIT=O$(if $(CONFIG_PCRE2_JIT_ENABLED),N,FF) \
> +	-DPCRE2_SHOW_REPORT=OFF \
> +	-DPCRE2_BUILD_PCRE2GREP=OFF \
> +	-DPCRE2_BUILD_TESTS=OFF
> +
> +define Build/InstallDev
> +	$(call Build/InstallDev/cmake,$(1))
> +	$(SED) 	's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' $(1)/usr/bin/pcre2-config
> +	$(INSTALL_DIR) $(2)/bin
> +	$(LN) ../../usr/bin/pcre2-config $(2)/bin/pcre2-config
> +	$(INSTALL_DIR) $(1)/usr/include
> +	$(CP) $(PKG_INSTALL_DIR)/usr/include/pcre2*.h $(1)/usr/include/
> +	$(INSTALL_DIR) $(1)/usr/lib
> +	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2*.{a,so*} $(1)/usr/lib/
> +	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
> +	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libpcre2*.pc $(1)/usr/lib/pkgconfig/
> +endef
> +
> +define Package/libpcre2/install
> +	$(INSTALL_DIR) $(1)/usr/lib
> +	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-{8,posix}.so* $(1)/usr/lib/
> +endef
> +
> +define Package/libpcre2-16/install
> +	$(INSTALL_DIR) $(1)/usr/lib
> +	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-16.so* $(1)/usr/lib/
> +endef
> +
> +define Package/libpcre2-32/install
> +	$(INSTALL_DIR) $(1)/usr/lib
> +	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-32.so* $(1)/usr/lib/
> +endef
> +
> +$(eval $(call BuildPackage,libpcre2))
> +$(eval $(call BuildPackage,libpcre2-16))
> +$(eval $(call BuildPackage,libpcre2-32))
> +$(eval $(call HostBuild))
diff mbox series

Patch

diff --git a/package/libs/pcre2/Config.in b/package/libs/pcre2/Config.in
new file mode 100644
index 0000000000..8777a4e84c
--- /dev/null
+++ b/package/libs/pcre2/Config.in
@@ -0,0 +1,30 @@ 
+config PCRE2_JIT_ENABLED
+	bool
+	depends on PACKAGE_libpcre2 && (aarch64 || aarch64_be || arm || i386 || i686 || x86_64 || mips || mipsel || mips64 || mips64el || powerpc || powerpc64 || powerpcle || sparc)
+	default y if (arm || i686 || x86_64)
+	prompt "Enable JIT compiler support"
+	help
+		Enable JIT (Just-In-Time) compiler support.
+
+		Just-in-time compiling is a heavyweight optimization that can greatly
+		speed up pattern matching. However, it comes at the cost of extra
+		processing before the match is performed, so it is of most benefit when
+		the same pattern is going to be matched many times. This does not
+		necessarily mean many calls of a matching function; if the pattern is
+		not anchored, matching attempts may take place many times at various
+		positions in the subject, even for a single call. Therefore, if the
+		subject string is very long, it may still pay to use JIT even for
+		one-off matches. JIT support is available for all of the 8-bit, 16-bit
+		and 32-bit PCRE2 libraries and adds about 100KB to the resulting
+		libpcre2.so. JIT support applies only to the traditional Perl-compatible
+		matching function. It does not apply when the DFA matching function is
+		being used.
+
+		Enabling this option can give an about 10x performance increase on JIT
+		operations. It can be desireable for e.g. high performance Apache
+		mod_rewrite or HA-Proxy reqrep operations.
+
+		However, JIT should _only_ be enabled on architectures that are supported.
+		Enabling JIT on unsupported platforms will result in a compilation
+		failure. A list of supported architectures can be found here:
+		https://pcre.org/current/doc/html/pcre2jit.html#SEC2
diff --git a/package/libs/pcre2/Makefile b/package/libs/pcre2/Makefile
new file mode 100644
index 0000000000..e68364a401
--- /dev/null
+++ b/package/libs/pcre2/Makefile
@@ -0,0 +1,103 @@ 
+#
+# Copyright (C) 2017 Shane Peelar
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=pcre2
+PKG_VERSION:=10.40
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=https://github.com/pcre2project/pcre2/releases/download/$(PKG_NAME)-$(PKG_VERSION)
+PKG_HASH:=14e4b83c4783933dc17e964318e6324f7cae1bc75d8f3c79bc6969f00c159d68
+
+PKG_MAINTAINER:=Shane Peelar <lookatyouhacker@gmail.com>
+PKG_LICENSE:=BSD-3-Clause
+PKG_LICENSE_FILES:=LICENCE
+PKG_CPE_ID:=cpe:/a:pcre:pcre
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_CONFIG_DEPENDS:=\
+	CONFIG_PACKAGE_libpcre2-16 \
+	CONFIG_PACKAGE_libpcre2-32 \
+	CONFIG_PCRE2_JIT_ENABLED
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libpcre2/default
+  SECTION:=libs
+  CATEGORY:=Libraries
+  URL:=https://www.pcre.org/
+endef
+
+define Package/libpcre2/config
+  source "$(SOURCE)/Config.in"
+endef
+
+define Package/libpcre2
+  $(call Package/libpcre2/default)
+  TITLE:=A Perl Compatible Regular Expression library
+endef
+
+define Package/libpcre2-16
+  $(call Package/libpcre2/default)
+  TITLE:=A Perl Compatible Regular Expression library (16bit support)
+endef
+
+define Package/libpcre2-32
+  $(call Package/libpcre2/default)
+  TITLE:=A Perl Compatible Regular Expression library (32bit support)
+endef
+
+CMAKE_OPTIONS += \
+	-DBUILD_SHARED_LIBS=ON \
+	-DPCRE2_BUILD_PCRE2_8=ON \
+	-DPCRE2_BUILD_PCRE2_16=O$(if $(CONFIG_PACKAGE_libpcre2-16),N,FF) \
+	-DPCRE2_BUILD_PCRE2_32=O$(if $(CONFIG_PACKAGE_libpcre2-32),N,FF) \
+	-DPCRE2_DEBUG=OFF \
+	-DPCRE2_DISABLE_PERCENT_ZT=ON \
+	-DPCRE2_SUPPORT_JIT=O$(if $(CONFIG_PCRE2_JIT_ENABLED),N,FF) \
+	-DPCRE2_SHOW_REPORT=OFF \
+	-DPCRE2_BUILD_PCRE2GREP=OFF \
+	-DPCRE2_BUILD_TESTS=OFF
+
+define Build/InstallDev
+	$(call Build/InstallDev/cmake,$(1))
+	$(SED) 	's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' $(1)/usr/bin/pcre2-config
+	$(INSTALL_DIR) $(2)/bin
+	$(LN) ../../usr/bin/pcre2-config $(2)/bin/pcre2-config
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/pcre2*.h $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2*.{a,so*} $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libpcre2*.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libpcre2/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-{8,posix}.so* $(1)/usr/lib/
+endef
+
+define Package/libpcre2-16/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-16.so* $(1)/usr/lib/
+endef
+
+define Package/libpcre2-32/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-32.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libpcre2))
+$(eval $(call BuildPackage,libpcre2-16))
+$(eval $(call BuildPackage,libpcre2-32))
+$(eval $(call HostBuild))