Skip to content

build: work around GCC optimizer bug for aarch64 #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jobs:
pull-request:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create app token
uses: actions/create-github-app-token@v2
id: app-token
Expand All @@ -25,6 +29,5 @@ jobs:
gh pr create -d -B master -H "$GITHUB_REF_NAME"
"${PR_TITLE:+--title=}${PR_TITLE:---fill-first}"
env:
GH_REPO: ${{github.repository}}
GH_TOKEN: ${{steps.app-token.outputs.token}}
PR_TITLE: ${{github.event.inputs.title}}
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
CIBW_ARCHS: ${{matrix.cibw_arch}}
CIBW_SKIP: "*-musllinux_aarch64"
# FIXME: stop skipping when the tests stop crashing
CIBW_TEST_SKIP: "*-win_* *linux_aarch64"
CIBW_TEST_SKIP: "*-win_*"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand Down
29 changes: 16 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
from sys import platform
from os import name as os_name
from platform import machine

from setuptools import Extension, setup # type: ignore

if os_name != "nt":
cflags = [
"-std=c11",
"-fvisibility=hidden",
"-Wno-cast-function-type",
"-Werror=implicit-function-declaration",
]
# FIXME: GCC optimizer bug workaround for #330 & #386
if machine().startswith("aarch64"):
cflags.append("--param=early-inlining-insns=9")
else:
cflags = ["/std:c11", "/wd4244"]

setup(
packages=["tree_sitter"],
include_package_data=False,
Expand Down Expand Up @@ -36,18 +50,7 @@
("PY_SSIZE_T_CLEAN", None),
("TREE_SITTER_HIDE_SYMBOLS", None),
],
undef_macros=[
"TREE_SITTER_FEATURE_WASM",
],
extra_compile_args=[
"-std=c11",
"-fvisibility=hidden",
"-Wno-cast-function-type",
"-Werror=implicit-function-declaration",
] if platform != "win32" else [
"/std:c11",
"/wd4244",
],
extra_compile_args=cflags,
)
],
)
7 changes: 2 additions & 5 deletions tree_sitter/binding/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ static bool parser_progress_callback(TSParseState *state) {
PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
ModuleState *state = GET_MODULE_STATE(self);
PyObject *source_or_callback;
PyObject *old_tree_obj = NULL;
PyObject *encoding_obj = NULL;
PyObject *progress_callback_obj = NULL;
bool keep_text = true;
PyObject *old_tree_obj = NULL, *encoding_obj = NULL, *progress_callback_obj = NULL;
char *keywords[] = {"", "old_tree", "encoding", "progress_callback", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O!OO:parse", keywords, &source_or_callback,
state->tree_type, &old_tree_obj, &encoding_obj,
Expand Down Expand Up @@ -206,7 +203,7 @@ PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
}
tree->tree = new_tree;
tree->language = self->language;
tree->source = keep_text ? source_or_callback : Py_None;
tree->source = source_or_callback;
Py_INCREF(tree->source);
Py_INCREF(tree->language);
return PyObject_Init((PyObject *)tree, state->tree_type);
Expand Down
Loading