From 67f6d7ec53f4a7d602b0102a277b81e9e9b90afa Mon Sep 17 00:00:00 2001 From: Rot127 Date: Thu, 10 Oct 2024 00:37:57 -0500 Subject: [PATCH 1/2] Add patch to disable PCRE2 JIT. Multiple users reported problems related to this. See: https://github.com/rizinorg/cutter/issues/3220 https://github.com/rizinorg/cutter/issues/3328 --- .../rizin/0002-disable-pcre2-jit.patch | 36 +++++++++++++++++++ .../tools/analysis/rizin/default.nix | 1 + 2 files changed, 37 insertions(+) create mode 100644 pkgs/development/tools/analysis/rizin/0002-disable-pcre2-jit.patch diff --git a/pkgs/development/tools/analysis/rizin/0002-disable-pcre2-jit.patch b/pkgs/development/tools/analysis/rizin/0002-disable-pcre2-jit.patch new file mode 100644 index 000000000000..4a10f44612c1 --- /dev/null +++ b/pkgs/development/tools/analysis/rizin/0002-disable-pcre2-jit.patch @@ -0,0 +1,36 @@ +diff --git a/meson.build b/meson.build +index a8153a2ee5..787cbfae06 100644 +--- a/meson.build ++++ b/meson.build +@@ -197,7 +197,7 @@ endif + + # Handle PCRE2 + cpu_jit_supported = [ 'aarch64', 'arm', 'mips', 'mips64', 'ppc', 'ppc64', 'riscv32', 'riscv64', 's390x', 'x86', 'x86_64' ] +-pcre2_jit_supported = target_machine.cpu_family() in cpu_jit_supported and cc.get_id() != 'tcc' and target_machine.system() != 'darwin' ++pcre2_jit_supported = false + if pcre2_jit_supported + add_project_arguments(['-DSUPPORTS_PCRE2_JIT'], language: 'c') + endif +diff --git a/subprojects/packagefiles/pcre2/meson.build b/subprojects/packagefiles/pcre2/meson.build +index b40ea85740..f3ee7a02ed 100644 +--- a/subprojects/packagefiles/pcre2/meson.build ++++ b/subprojects/packagefiles/pcre2/meson.build +@@ -60,18 +60,6 @@ cpu_jit_supported = [ 'aarch64', 'arm', 'mips', 'mips64', 'ppc', 'ppc64', 'riscv + # tcc doesn't support the MSVC asm syntax PCRE2 uses (`__asm { ... }`). + # Darwin kernel not as well, because of forbidden wx memory. + # It is used in the JIT compiler code. +-if cc.get_id() != 'tcc' and target_machine.cpu_family() in cpu_jit_supported and target_machine.system() != 'darwin' +- libpcre2_c_args += ['-DSUPPORT_JIT'] +- pcre2_files += ['src/pcre2_jit_compile.c'] +-endif +- +-if target_machine.system() == 'openbsd' +- # jit compilation fails with "no more memory" if wx allocations are allowed. +- libpcre2_c_args += ['-DSLJIT_WX_EXECUTABLE_ALLOCATOR'] +-elif target_machine.system() == 'netbsd' +- # jit compilation fails with "no more memory" if wx allocations are allowed. +- libpcre2_c_args += ['-DSLJIT_PROT_EXECUTABLE_ALLOCATOR'] +-endif + + pcre2_includes = [ + include_directories('.'), diff --git a/pkgs/development/tools/analysis/rizin/default.nix b/pkgs/development/tools/analysis/rizin/default.nix index 6336d603a61b..90b30d28464a 100644 --- a/pkgs/development/tools/analysis/rizin/default.nix +++ b/pkgs/development/tools/analysis/rizin/default.nix @@ -60,6 +60,7 @@ let rizin = stdenv.mkDerivation rec { ./librz-wrapper-support.patch ./0001-fix-compilation-with-clang.patch + ./0002-disable-pcre2-jit.patch ]; From b6785a0df67ca3ff01f7cbb0355ccbe1fd5f296d Mon Sep 17 00:00:00 2001 From: Rot127 <45763064+Rot127@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:25:26 +0000 Subject: [PATCH 2/2] Add note about the issue this patch works around. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jörg Thalheim --- pkgs/development/tools/analysis/rizin/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/tools/analysis/rizin/default.nix b/pkgs/development/tools/analysis/rizin/default.nix index 90b30d28464a..893242aa4f5a 100644 --- a/pkgs/development/tools/analysis/rizin/default.nix +++ b/pkgs/development/tools/analysis/rizin/default.nix @@ -60,6 +60,7 @@ let rizin = stdenv.mkDerivation rec { ./librz-wrapper-support.patch ./0001-fix-compilation-with-clang.patch + # Can be dropped when upstream fixes this: https://github.com/NixOS/nixpkgs/issues/300056 ./0002-disable-pcre2-jit.patch ];