|
| 1 | +diff --git a/numpy/_core/include/numpy/ndarrayobject.h b/numpy/_core/include/numpy/ndarrayobject.h |
| 2 | +index f06bafe5b5..52063a7d16 100644 |
| 3 | +--- a/numpy/_core/include/numpy/ndarrayobject.h |
| 4 | ++++ b/numpy/_core/include/numpy/ndarrayobject.h |
| 5 | +@@ -220,7 +220,7 @@ NPY_TITLE_KEY_check(PyObject *key, PyObject *value) |
| 6 | + if (key == title) { |
| 7 | + return 1; |
| 8 | + } |
| 9 | +-#ifdef PYPY_VERSION |
| 10 | ++#if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON) |
| 11 | + /* |
| 12 | + * On PyPy, dictionary keys do not always preserve object identity. |
| 13 | + * Fall back to comparison by value. |
| 14 | +diff --git a/numpy/_core/src/multiarray/compiled_base.c b/numpy/_core/src/multiarray/compiled_base.c |
| 15 | +index 48524aff4d..e55e2479e1 100644 |
| 16 | +--- a/numpy/_core/src/multiarray/compiled_base.c |
| 17 | ++++ b/numpy/_core/src/multiarray/compiled_base.c |
| 18 | +@@ -1455,6 +1455,7 @@ fail: |
| 19 | + NPY_NO_EXPORT PyObject * |
| 20 | + arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *const *args, Py_ssize_t len_args) |
| 21 | + { |
| 22 | ++#if 0 // GraalPy change |
| 23 | + PyObject *obj; |
| 24 | + PyObject *str; |
| 25 | + const char *docstr; |
| 26 | +@@ -1559,6 +1560,7 @@ arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *const *args, Py_ssize_t |
| 27 | + } |
| 28 | + |
| 29 | + #undef _ADDDOC |
| 30 | ++#endif // GraalPy change |
| 31 | + |
| 32 | + Py_RETURN_NONE; |
| 33 | + } |
| 34 | +diff --git a/numpy/_core/src/multiarray/shape.c b/numpy/_core/src/multiarray/shape.c |
| 35 | +index 340fe7289a..8f13674383 100644 |
| 36 | +--- a/numpy/_core/src/multiarray/shape.c |
| 37 | ++++ b/numpy/_core/src/multiarray/shape.c |
| 38 | +@@ -97,6 +97,11 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck, |
| 39 | + "cannot resize an array with refcheck=True on PyPy.\n" |
| 40 | + "Use the np.resize function or refcheck=False"); |
| 41 | + return NULL; |
| 42 | ++#elif defined(GRAALVM_PYTHON) |
| 43 | ++ PyErr_SetString(PyExc_ValueError, |
| 44 | ++ "cannot resize an array with refcheck=True on GraalPy.\n" |
| 45 | ++ "Use the np.resize function or refcheck=False"); |
| 46 | ++ return NULL; |
| 47 | + #else |
| 48 | + refcnt = Py_REFCNT(self); |
| 49 | + #endif /* PYPY_VERSION */ |
| 50 | +diff --git a/numpy/_core/src/multiarray/stringdtype/dtype.c b/numpy/_core/src/multiarray/stringdtype/dtype.c |
| 51 | +index cb8265dd3d..0dabb49346 100644 |
| 52 | +--- a/numpy/_core/src/multiarray/stringdtype/dtype.c |
| 53 | ++++ b/numpy/_core/src/multiarray/stringdtype/dtype.c |
| 54 | +@@ -841,7 +841,7 @@ init_string_dtype(void) |
| 55 | + }; |
| 56 | + |
| 57 | + /* Loaded dynamically, so needs to be set here: */ |
| 58 | +- Py_TYPE(((PyObject *)&PyArray_StringDType)) = &PyArrayDTypeMeta_Type; |
| 59 | ++ Py_SET_TYPE((PyObject *)&PyArray_StringDType, &PyArrayDTypeMeta_Type); |
| 60 | + ((PyTypeObject *)&PyArray_StringDType)->tp_base = &PyArrayDescr_Type; |
| 61 | + if (PyType_Ready((PyTypeObject *)&PyArray_StringDType) < 0) { |
| 62 | + return -1; |
| 63 | +diff --git a/numpy/_core/src/multiarray/temp_elide.c b/numpy/_core/src/multiarray/temp_elide.c |
| 64 | +index 662a2fa52b..791ede8c1a 100644 |
| 65 | +--- a/numpy/_core/src/multiarray/temp_elide.c |
| 66 | ++++ b/numpy/_core/src/multiarray/temp_elide.c |
| 67 | +@@ -58,7 +58,7 @@ |
| 68 | + * supported too by using the appropriate Windows APIs. |
| 69 | + */ |
| 70 | + |
| 71 | +-#if defined HAVE_BACKTRACE && defined HAVE_DLFCN_H && ! defined PYPY_VERSION |
| 72 | ++#if defined HAVE_BACKTRACE && defined HAVE_DLFCN_H && ! defined PYPY_VERSION && !defined(GRAALVM_PYTHON) |
| 73 | + |
| 74 | + #include <feature_detection_misc.h> |
| 75 | + |
| 76 | +diff --git a/numpy/_core/src/npymath/ieee754.c.src b/numpy/_core/src/npymath/ieee754.c.src |
| 77 | +index 8fccc9a69b..3bb9cf0d58 100644 |
| 78 | +--- a/numpy/_core/src/npymath/ieee754.c.src |
| 79 | ++++ b/numpy/_core/src/npymath/ieee754.c.src |
| 80 | +@@ -362,6 +362,11 @@ int npy_get_floatstatus_barrier(char* param) |
| 81 | + * By using a volatile, the compiler cannot reorder this call |
| 82 | + */ |
| 83 | + if (param != NULL) { |
| 84 | ++ // GraalPy change: the pointer needs to be dereferenced to establish |
| 85 | ++ // a data dependency to to ensure the compiler won't reorder the call |
| 86 | ++ if (points_to_py_handle_space(param)) { |
| 87 | ++ param = (char*)pointer_to_stub(param); |
| 88 | ++ } |
| 89 | + volatile char NPY_UNUSED(c) = *(char*)param; |
| 90 | + } |
| 91 | + |
| 92 | +diff --git a/numpy/_core/src/npymath/ieee754.cpp b/numpy/_core/src/npymath/ieee754.cpp |
| 93 | +index 1c59bf300b..519fabc113 100644 |
| 94 | +--- a/numpy/_core/src/npymath/ieee754.cpp |
| 95 | ++++ b/numpy/_core/src/npymath/ieee754.cpp |
| 96 | +@@ -428,6 +428,11 @@ npy_get_floatstatus_barrier(char *param) |
| 97 | + * By using a volatile, the compiler cannot reorder this call |
| 98 | + */ |
| 99 | + if (param != NULL) { |
| 100 | ++ // GraalPy change: the pointer needs to be dereferenced to establish |
| 101 | ++ // a data dependency to to ensure the compiler won't reorder the call |
| 102 | ++ if (points_to_py_handle_space(param)) { |
| 103 | ++ param = (char*)pointer_to_stub(param); |
| 104 | ++ } |
| 105 | + volatile char NPY_UNUSED(c) = *(char *)param; |
| 106 | + } |
| 107 | + |
| 108 | +diff --git a/vendored-meson/meson/mesonbuild/utils/universal.py b/vendored-meson/meson/mesonbuild/utils/universal.py |
| 109 | +index 6aee268ee..539be8bab 100644 |
| 110 | +--- a/vendored-meson/meson/mesonbuild/utils/universal.py |
| 111 | ++++ b/vendored-meson/meson/mesonbuild/utils/universal.py |
| 112 | +@@ -728,6 +728,7 @@ def windows_detect_native_arch() -> str: |
| 113 | + """ |
| 114 | + if sys.platform != 'win32': |
| 115 | + return '' |
| 116 | ++ return 'amd64' # Workaround for GraalPy bug on Windows with kernel32.GetCurrentProcess() |
| 117 | + try: |
| 118 | + import ctypes |
| 119 | + process_arch = ctypes.c_ushort() |
0 commit comments