Missing libm linkage for _imagingmath extension causes undefined symbol errors
envgap__python-pillow__Pillow-9386
01 / FAILURE SIGNATURE
As reported upstream
No identifying execution failure has been captured.
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
e2b87a04209d835d1c55633e230265dcd2c4274c- Manifest
setup.py- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
python-pillow/Pillow #9386 · read the original issue
The PIL._imagingmath extension module fails to load on some systems due to missing linkage against the math library (libm). This causes undefined symbol errors for mathematical functions like fmod, powf, and pow.
```bash
bash[./lib/python3.12/site-packages/PIL/_imagingmath.cpython-312-aarch64-linux-gnu.so]:
linux-vdso.so.1 (0x0000ffff9f92d000)
libc.so.6 => /lib64/libc.so.6 (0x0000ffff9f6dc000)
/lib/ld-linux-aarch64.so.1 (0x0000ffff9f8e0000)
undefined symbol: fmod (./lib/python3.12/site-packages/PIL/_imagingmath.cpython-312-aarch64-linux-gnu.so)
undefined symbol: powf (./lib/python3.12/site-packages/PIL/_imagingmath.cpython-312-aarch64-linux-gnu.so)
undefined symbol: pow (./lib/python3.12/site-packages/PIL/_imagingmath.cpython-312-aarch64-linux-gnu.so)
```
Workaround is to use a sed patch to explicitly link the math library:
```bash
sed -i 's/Extension("PIL\._imagingmath", \["src\/_imagingmath\.c"\]),/Extension("PIL._imagingmath", ["src\/_imagingmath.c"], libraries=["m"]),/' "./setup.py"
```
Environment
Platform: Amz Linux 2023
Python version: 3.12
Architecture: Aarch64
Pillow: 12.1.0
```text
root@a2f52c62c5cf Pillow-12.1.0 # python3 -m PIL --report
--------------------------------------------------------------------
Pillow 12.1.0
Python 3.12.7 (main, Nov 22 2024, 15:13:20) [Clang 20.0.0git ]
--------------------------------------------------------------------
Python executable is /usr/local/bin/python3
System Python files loaded from /usr/local
--------------------------------------------------------------------
Python Pillow modules loaded from /usr/local/lib/python3.12/site-packages/PIL
Binary Pillow modules loaded from /usr/local/lib/python3.12/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 12.1.0
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.13.3
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.4.0
*** AVIF support not installed
--- JPEG support ok, compiled for libjpeg-turbo 3.0.90
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1.zlib-ng, compiled for zlib-ng 2.2.2
--- LIBTIFF support ok, loaded 4.7.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.2
*** LIBIMAGEQUANT (Quantization method) support not installed
*** XCB (X protocol) support not installed
--------------------------------------------------------------------
root@a2f52c62c5cf Pillow-12.1.0 #
```
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]