From 208225bfaab383bde73812c6d357202313f12b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 18 May 2022 11:41:00 +0200 Subject: [PATCH] pcre2: Fix support for macOS < 11.0 by making JIT conditional at runtime (cherry picked from commit 24a06a6d4ab32116a15d0bb5ae7cc3c359be672c) --- thirdparty/README.md | 3 ++ .../patches/sljit-macos11-conditional.patch | 31 +++++++++++++++++++ .../pcre2/src/sljit/sljitExecAllocator.c | 3 ++ 3 files changed, 37 insertions(+) create mode 100644 thirdparty/pcre2/patches/sljit-macos11-conditional.patch diff --git a/thirdparty/README.md b/thirdparty/README.md index 67d5136c5..a185cd82d 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -405,6 +405,9 @@ Files extracted from upstream source: - src/sljit/ - AUTHORS and LICENCE +A sljit patch from upstream was backported to fix macOS < 11.0 compilation +in 10.40, it can be found in the `patches` folder. + ## pvrtccompressor diff --git a/thirdparty/pcre2/patches/sljit-macos11-conditional.patch b/thirdparty/pcre2/patches/sljit-macos11-conditional.patch new file mode 100644 index 000000000..def1207a3 --- /dev/null +++ b/thirdparty/pcre2/patches/sljit-macos11-conditional.patch @@ -0,0 +1,31 @@ +From de8fc816bc6698ab97316ed954e133e7e5098262 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= +Date: Thu, 21 Apr 2022 21:01:12 -0700 +Subject: [PATCH] macos: somehow allow building with a target below 11.0 + +While building for macOS older than 11 in Apple Silicon makes no +sense, some build systems lack the flexibility to set a target per +architecture while aiming to support multi architecture binaries. + +Allow an option in those cases by using the slower runtime checks +if the toolchain allows it. + +Fixes: PCRE2Project/pcre2#109 +--- + sljit_src/sljitExecAllocator.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/sljit_src/sljitExecAllocator.c b/sljit_src/sljitExecAllocator.c +index 92d940dd..6359848c 100644 +--- a/sljit_src/sljitExecAllocator.c ++++ b/sljit_src/sljitExecAllocator.c +@@ -152,6 +152,9 @@ static SLJIT_INLINE void apple_update_wx_flags(sljit_s32 enable_exec) + { + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 + pthread_jit_write_protect_np(enable_exec); ++#elif defined(__clang__) ++ if (__builtin_available(macOS 11.0, *)) ++ pthread_jit_write_protect_np(enable_exec); + #else + #error "Must target Big Sur or newer" + #endif /* BigSur */ diff --git a/thirdparty/pcre2/src/sljit/sljitExecAllocator.c b/thirdparty/pcre2/src/sljit/sljitExecAllocator.c index 92d940ddc..6359848cd 100644 --- a/thirdparty/pcre2/src/sljit/sljitExecAllocator.c +++ b/thirdparty/pcre2/src/sljit/sljitExecAllocator.c @@ -152,6 +152,9 @@ static SLJIT_INLINE void apple_update_wx_flags(sljit_s32 enable_exec) { #if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 pthread_jit_write_protect_np(enable_exec); +#elif defined(__clang__) + if (__builtin_available(macOS 11.0, *)) + pthread_jit_write_protect_np(enable_exec); #else #error "Must target Big Sur or newer" #endif /* BigSur */