diff --git a/pkgs/development/python-modules/tree-sitter/default.nix b/pkgs/development/python-modules/tree-sitter/default.nix index 3ec5c58411e6..1ca0885a73ac 100644 --- a/pkgs/development/python-modules/tree-sitter/default.nix +++ b/pkgs/development/python-modules/tree-sitter/default.nix @@ -28,6 +28,11 @@ buildPythonPackage rec { fetchSubmodules = true; }; + # see https://github.com/tree-sitter/py-tree-sitter/issues/330#issuecomment-2629403946 + patches = lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) [ + ./segfault-patch.diff + ]; + build-system = [ setuptools ]; nativeCheckInputs = [ @@ -51,14 +56,11 @@ buildPythonPackage rec { "test_dot_graphs" ]; - # Segfaults explosively for some reason, but dependents seem to work? - doCheck = !stdenv.hostPlatform.isAarch64; - - meta = with lib; { + meta = { description = "Python bindings to the Tree-sitter parsing library"; homepage = "https://github.com/tree-sitter/py-tree-sitter"; changelog = "https://github.com/tree-sitter/py-tree-sitter/releases/tag/${src.tag}"; - license = licenses.mit; - maintainers = with maintainers; [ fab ]; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ fab ]; }; } diff --git a/pkgs/development/python-modules/tree-sitter/segfault-patch.diff b/pkgs/development/python-modules/tree-sitter/segfault-patch.diff new file mode 100644 index 000000000000..9d325ac532c0 --- /dev/null +++ b/pkgs/development/python-modules/tree-sitter/segfault-patch.diff @@ -0,0 +1,13 @@ +--- i/tree_sitter/core/lib/src/parser.c ++++ w/tree_sitter/core/lib/src/parser.c +@@ -2084,6 +2084,10 @@ void ts_parser_reset(TSParser *self) { + self->parse_state = (TSParseState) {0}; + } + ++// FIXME: see tree-sitter/py-tree-sitter#330 ++#if __GNUC__ >= 14 && defined(__aarch64__) && defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) ++__attribute__((optimize(2))) ++#endif + TSTree *ts_parser_parse( + TSParser *self, + const TSTree *old_tree,