Repository navigation
Platform-dependent issue with compiling against version 3.11 of Limited API #18248
Copy link
Copy link
Closed
Closed
Copy link
Labels
Description
I've hit a couple compilation errors in stats when targetting a abi3-311 build, which appear to be defects in numpy's C API
astropy/stats/src/fast_sigma_clip.c:109:29: error: call to undeclared function 'PyMem_RawMalloc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
109 | data_buffer = (double *)PyArray_malloc(n_i * sizeof(double));
| ^
/Users/clm/.cache/uv/builds-v0/.tmpBdRAcn/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarraytypes.h:368:24: note: expanded from macro 'PyArray_malloc'
368 | #define PyArray_malloc PyMem_RawMalloc
| ^
astropy/stats/src/fast_sigma_clip.c:109:19: warning: cast to 'double *' from smaller integer type 'int' [-Wint-to-pointer-cast]
109 | data_buffer = (double *)PyArray_malloc(n_i * sizeof(double));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
astropy/stats/src/fast_sigma_clip.c:138:30: warning: cast to 'double *' from smaller integer type 'int' [-Wint-to-pointer-cast]
138 | mad_buffer = (double *)PyArray_malloc(n_i * sizeof(double));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
astropy/stats/src/fast_sigma_clip.c:157:5: error: call to undeclared function 'PyMem_RawFree'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
157 | PyArray_free((void *)data_buffer);
| ^
/Users/clm/.cache/uv/builds-v0/.tmpBdRAcn/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarraytypes.h:369:22: note: expanded from macro 'PyArray_free'
369 | #define PyArray_free PyMem_RawFree
| ^
astropy/stats/src/fast_sigma_clip.c:157:5: note: did you mean 'PyMem_Free'?
/Users/clm/.cache/uv/builds-v0/.tmpBdRAcn/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarraytypes.h:369:22: note: expanded from macro 'PyArray_free'
369 | #define PyArray_free PyMem_RawFree
| ^
/Users/clm/.local/share/uv/python/cpython-3.11.13-macos-aarch64-none/include/python3.11/pymem.h:55:18: note: 'PyMem_Free' declared here
55 | PyAPI_FUNC(void) PyMem_Free(void *ptr);
| ^
2 warnings and 2 errors generated.
error: command '/usr/bin/cc' failed with exit code 1
To summarize, PyArray_malloc and PyArray_free are aliased to Python's C-API PyMem_RawMalloc and PyMem_RawFree respectively, which were not part of Limited API until version 3.13, so they appear as undefined.
I'm surprised that this isn't showing up in the test job introduced in #18236, any idea why that is @astrofrog ?
I want to report/fix this upstream later, though for now I'll continue making progress on astropy itself by targeting abi-cp313 instead.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
astrofrog commentedon Jun 10, 2025
What platform are you using? I noticed that some limited API issues appear only with certain compilers, which might explain why they didn't appear in the CI. I will investigate a bit later on the CI side.
neutrinoceros commentedon Jun 10, 2025
I got this error on Apple Silicon, presumably my auto-selected compiler should be clang
neutrinoceros commentedon Jun 10, 2025
Actually these problems do get reported too on Linux (gcc), but there they're just warnings instead of errors
astrofrog commentedon Jun 10, 2025
These are fixed and properly tested in #18250
[-]Upstream issue with compiling against version 3.11 of Limited API[/-][+]Plateform-dependent issue with compiling against version 3.11 of Limited API[/+][-]Plateform-dependent issue with compiling against version 3.11 of Limited API[/-][+]Platform-dependent issue with compiling against version 3.11 of Limited API[/+]