From 86d00149577ae2f4f7b0c0e6b479362267a5ed3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Fri, 20 May 2022 14:59:27 +0100 Subject: [PATCH] [PCRE2] Update to v10.40 (#4924) --- P/PCRE2/build_tarballs.jl | 16 +- .../patches/sljit-apple-silicon-support.patch | 244 ------------------ .../bundled/patches/sljit-nomprotect.patch | 17 -- 3 files changed, 4 insertions(+), 273 deletions(-) delete mode 100644 P/PCRE2/bundled/patches/sljit-apple-silicon-support.patch delete mode 100644 P/PCRE2/bundled/patches/sljit-nomprotect.patch diff --git a/P/PCRE2/build_tarballs.jl b/P/PCRE2/build_tarballs.jl index 461afdca848..b9743198751 100644 --- a/P/PCRE2/build_tarballs.jl +++ b/P/PCRE2/build_tarballs.jl @@ -3,13 +3,12 @@ using BinaryBuilder name = "PCRE2" -version = v"10.36" +version = v"10.40" # Collection of sources required to complete build sources = [ - ArchiveSource("https://github.com/PhilipHazel/pcre2/archive/refs/tags/pcre2-$(version.major).$(version.minor).tar.gz", - "4975181fa486a595fc2de1ebce85793412d631e0ac006a7906f854caf62c9745"), - DirectorySource("./bundled"), + ArchiveSource("https://github.com/PCRE2Project/pcre2/releases/download/pcre2-$(version.major).$(version.minor)/pcre2-$(version.major).$(version.minor).tar.gz", + "ded42661cab30ada2e72ebff9e725e745b4b16ce831993635136f2ef86177724"), ] # Bash recipe for building across all platforms @@ -19,16 +18,9 @@ cd $WORKSPACE/srcdir/pcre2-*/ # Update configure scripts update_configure_scripts -# NOTE: this step may be removed if we switch to release tarballs in the future. -./autogen.sh - # Force optimization export CFLAGS="${CFLAGS} -O3" -# Apply patches -atomic_patch -d src/sljit -p2 ${WORKSPACE}/srcdir/patches/sljit-apple-silicon-support.patch -atomic_patch -d src/sljit -p2 ${WORKSPACE}/srcdir/patches/sljit-nomprotect.patch - ./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} \ --disable-static \ --enable-jit \ @@ -61,4 +53,4 @@ products = [ dependencies = Dependency[ ] -build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6") +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.9") diff --git a/P/PCRE2/bundled/patches/sljit-apple-silicon-support.patch b/P/PCRE2/bundled/patches/sljit-apple-silicon-support.patch deleted file mode 100644 index 3aff832ca08..00000000000 --- a/P/PCRE2/bundled/patches/sljit-apple-silicon-support.patch +++ /dev/null @@ -1,244 +0,0 @@ -From e87e1ccf93768238db3d6e28d0272980dba707fa Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= -Date: Mon, 30 Nov 2020 01:35:13 -0800 -Subject: [PATCH] macos: add BigSur support to execalloc (#90) - -Apple Silicon requires that pages that will hold JIT code are -marked with MAP_JIT (even if not using the hardened runtime) -and that a call be made to a pthread function before writing -to them, so a special exception could be made to the current -thread[1]; add support for both. - -since the allocator keeps the metadata about chunk/block in the -executable pages, all functions that modify that metadata will -also need to be updated. - -note that since there is no need for an accurate pointer range -with the apple implementation, NULL is passed for the pointers. - -historically, adding MAP_JIT was only recommended when the hardened -runtime was being used as it adds several undocumented restrictions -(like not being able to use JIT pages accross fork()) so the -new codepath won't be used if running in Intel. - -Tested-by: @Keno -Fixes: #51 - -[1] https://developer.apple.com/documentation/apple_silicon/porting_just-in-time_compilers_to_apple_silicon?language=objc ---- - sljit_src/sljitExecAllocator.c | 113 ++++++++++++++++++--------------- - 1 file changed, 63 insertions(+), 50 deletions(-) - -diff --git a/sljit_src/sljitExecAllocator.c b/sljit_src/sljitExecAllocator.c -index 61a32f2..2e1c138 100644 ---- a/sljit_src/sljitExecAllocator.c -+++ b/sljit_src/sljitExecAllocator.c -@@ -79,6 +79,7 @@ - */ - - #ifdef _WIN32 -+#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) - - static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - { -@@ -91,65 +92,76 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) - VirtualFree(chunk, 0, MEM_RELEASE); - } - --#else -- --#ifdef __APPLE__ --#ifdef MAP_ANON --/* Configures TARGET_OS_OSX when appropriate */ --#include -- --#if TARGET_OS_OSX && defined(MAP_JIT) --#include --#endif /* TARGET_OS_OSX && MAP_JIT */ -- --#ifdef MAP_JIT -+#else /* POSIX */ - -+#if defined(__APPLE__) && defined(MAP_JIT) - /* - On macOS systems, returns MAP_JIT if it is defined _and_ we're running on a -- version where it's OK to have more than one JIT block. -+ version where it's OK to have more than one JIT block or where MAP_JIT is -+ required. - On non-macOS systems, returns MAP_JIT if it is defined. - */ -+#include -+#if TARGET_OS_OSX -+#if defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86 -+#ifdef MAP_ANON -+#include -+#include -+ -+#define SLJIT_MAP_JIT (get_map_jit_flag()) -+ - static SLJIT_INLINE int get_map_jit_flag() - { --#if TARGET_OS_OSX -- sljit_sw page_size = get_page_alignment() + 1; -+ sljit_sw page_size; - void *ptr; -+ struct utsname name; - static int map_jit_flag = -1; - -- /* -- The following code is thread safe because multiple initialization -- sets map_jit_flag to the same value and the code has no side-effects. -- Changing the kernel version witout system restart is (very) unlikely. -- */ -- if (map_jit_flag == -1) { -- struct utsname name; -- -+ if (map_jit_flag < 0) { - map_jit_flag = 0; - uname(&name); - -- /* Kernel version for 10.14.0 (Mojave) */ -+ /* Kernel version for 10.14.0 (Mojave) or later */ - if (atoi(name.release) >= 18) { -+ page_size = get_page_alignment() + 1; - /* Only use MAP_JIT if a hardened runtime is used */ -+ ptr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, -+ MAP_PRIVATE | MAP_ANON, -1, 0); - -- ptr = mmap(NULL, page_size, PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); -- -- if (ptr == MAP_FAILED) { -- map_jit_flag = MAP_JIT; -- } else { -+ if (ptr != MAP_FAILED) - munmap(ptr, page_size); -- } -+ else -+ map_jit_flag = MAP_JIT; - } - } -- - return map_jit_flag; --#else /* !TARGET_OS_OSX */ -- return MAP_JIT; --#endif /* TARGET_OS_OSX */ - } -- --#endif /* MAP_JIT */ - #endif /* MAP_ANON */ --#endif /* __APPLE__ */ -+#else /* !SLJIT_CONFIG_X86 */ -+#if !(defined SLJIT_CONFIG_ARM && SLJIT_CONFIG_ARM) -+#error Unsupported architecture -+#endif /* SLJIT_CONFIG_ARM */ -+#include -+ -+#define SLJIT_MAP_JIT (MAP_JIT) -+#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) \ -+ apple_update_wx_flags(enable_exec) -+ -+static SLJIT_INLINE void apple_update_wx_flags(sljit_s32 enable_exec) -+{ -+ pthread_jit_write_protect_np(enable_exec); -+} -+#endif /* SLJIT_CONFIG_X86 */ -+#else /* !TARGET_OS_OSX */ -+#define SLJIT_MAP_JIT (MAP_JIT) -+#endif /* TARGET_OS_OSX */ -+#endif /* __APPLE__ && MAP_JIT */ -+#ifndef SLJIT_UPDATE_WX_FLAGS -+#define SLJIT_UPDATE_WX_FLAGS(from, to, enable_exec) -+#endif /* !SLJIT_UPDATE_WX_FLAGS */ -+#ifndef SLJIT_MAP_JIT -+#define SLJIT_MAP_JIT (0) -+#endif /* !SLJIT_MAP_JIT */ - - static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - { -@@ -157,12 +169,7 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - const int prot = PROT_READ | PROT_WRITE | PROT_EXEC; - - #ifdef MAP_ANON -- -- int flags = MAP_PRIVATE | MAP_ANON; -- --#ifdef MAP_JIT -- flags |= get_map_jit_flag(); --#endif -+ int flags = MAP_PRIVATE | MAP_ANON | SLJIT_MAP_JIT; - - retval = mmap(NULL, size, prot, flags, -1, 0); - #else /* !MAP_ANON */ -@@ -173,14 +180,15 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - #endif /* MAP_ANON */ - - if (retval == MAP_FAILED) -- retval = NULL; -- else { -- if (mprotect(retval, size, prot) < 0) { -- munmap(retval, size); -- retval = NULL; -- } -+ return NULL; -+ -+ if (mprotect(retval, size, prot) < 0) { -+ munmap(retval, size); -+ return NULL; - } - -+ SLJIT_UPDATE_WX_FLAGS(retval, (uint8_t *)retval + size, 0); -+ - return retval; - } - -@@ -189,7 +197,7 @@ static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) - munmap(chunk, size); - } - --#endif -+#endif /* windows */ - - /* --------------------------------------------------------------------- */ - /* Common functions */ -@@ -261,6 +269,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) - while (free_block) { - if (free_block->size >= size) { - chunk_size = free_block->size; -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); - if (chunk_size > size + 64) { - /* We just cut a block from the end of the free block. */ - chunk_size -= size; -@@ -326,6 +335,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr) - allocated_size -= header->size; - - /* Connecting free blocks together if possible. */ -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); - - /* If header->prev_size == 0, free_block will equal to header. - In this case, free_block->header.size will be > 0. */ -@@ -358,6 +368,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr) - } - } - -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 1); - SLJIT_ALLOCATOR_UNLOCK(); - } - -@@ -367,6 +378,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void) - struct free_block* next_free_block; - - SLJIT_ALLOCATOR_LOCK(); -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 0); - - free_block = free_blocks; - while (free_block) { -@@ -381,5 +393,6 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void) - } - - SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks)); -+ SLJIT_UPDATE_WX_FLAGS(NULL, NULL, 1); - SLJIT_ALLOCATOR_UNLOCK(); - } --- -2.30.0 - diff --git a/P/PCRE2/bundled/patches/sljit-nomprotect.patch b/P/PCRE2/bundled/patches/sljit-nomprotect.patch deleted file mode 100644 index 3c2df180863..00000000000 --- a/P/PCRE2/bundled/patches/sljit-nomprotect.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/sljit_src/sljitExecAllocator.c b/sljit_src/sljitExecAllocator.c -index 2e1c138..bae8cd6 100644 ---- a/sljit_src/sljitExecAllocator.c -+++ b/sljit_src/sljitExecAllocator.c -@@ -182,10 +182,12 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size) - if (retval == MAP_FAILED) - return NULL; - -+#ifdef SLIJT_WX_OS_NEEDSCHEK - if (mprotect(retval, size, prot) < 0) { - munmap(retval, size); - return NULL; - } -+#endif - - SLJIT_UPDATE_WX_FLAGS(retval, (uint8_t *)retval + size, 0); -