[PATCH 1/4] pcre2: adds pcre2 to base

Daniel Golle daniel at makrotopia.org
Thu May 19 10:31:44 PDT 2022


On Thu, May 19, 2022 at 06:37:28PM +0200, Dominick Grift wrote:
> libselinux-3.4 requires pcre2
> 
> Signed-off-by: Dominick Grift <dominick.grift at defensec.nl>
> ---
>  package/libs/pcre2/Config.in | 30 ++++++++++++
>  package/libs/pcre2/Makefile  | 92 ++++++++++++++++++++++++++++++++++++
>  2 files changed, 122 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)

Can you explain the choice of architectures for which you are
suggesting to enable JIT by default?
Wouldn't e.g. aarch64 benefit just as well?

> +	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..4e75a1cda9
> --- /dev/null
> +++ b/package/libs/pcre2/Makefile
> @@ -0,0 +1,92 @@
> +#
> +# 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.37
> +PKG_RELEASE:=$(AUTORELEASE)
> +
> +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
> +PKG_SOURCE_URL:=@SF/pcre/$(PKG_NAME)/$(PKG_VERSION)
> +PKG_HASH:=4d95a96e8b80529893b4562be12648d798b957b1ba1aae39606bbc2ab956d270
> +
> +PKG_MAINTAINER:=Shane Peelar <lookatyouhacker at gmail.com>
> +PKG_LICENSE:=BSD-3-Clause
> +PKG_LICENSE_FILES:=LICENCE
> +PKG_CPE_ID:=cpe:/a:pcre:pcre
> +
> +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
> +
> +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
> +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))
> -- 
> 2.36.1
> 



More information about the openwrt-devel mailing list