python312Packages.tree-sitter: patch segfaulting code, enable tests

This commit is contained in:
Gutyina Gergő 2025-02-07 11:27:19 +01:00
parent 271bbf8f6e
commit c31e83ecd2
No known key found for this signature in database
2 changed files with 21 additions and 6 deletions

View File

@ -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 ];
};
}

View File

@ -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,