← All tasks
pythonfonttools/fonttools #4028Not a task: already works

Missing libm linkage causes undefined symbol errors in Cython extensions

envgap__fonttools__fonttools-4028

01 / FAILURE SIGNATURE

As reported upstream

Example error output:
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
90508af3a6738749cc75856f8c0db38d0b7e169e
Manifest
setup.py
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

fonttools/fonttools #4028 · read the original issue
When building fontTools from source on Linux (aarch64), some Cython extension modules fail to load at runtime due to missing linkage against libm.

The affected extensions use math functions provided by libm (such as sqrt, pow, fabs, etc.), but do not explicitly link against it. As a result, importing the modules fails with undefined symbol errors.

Affected modules:
- fontTools.cu2qu.cu2qu
- fontTools.qu2cu.qu2cu
- fontTools.misc.bezierTools
- fontTools.pens.momentsPen

Example error output:
```bash
[./lib/python3.12/site-packages/fontTools/cu2qu/cu2qu.cpython-312-aarch64-linux-gnu.so]:
    linux-vdso.so.1 (0x0000ffff907d7000)
    libc.so.6 => /lib64/libc.so.6 (0x0000ffff90570000)
    /lib/ld-linux-aarch64.so.1 (0x0000ffff9078a000)
undefined symbol: sqrt	(./lib/python3.12/site-packages/fontTools/cu2qu/cu2qu.cpython-312-aarch64-linux-gnu.so)
undefined symbol: pow	(./lib/python3.12/site-packages/fontTools/cu2qu/cu2qu.cpython-312-aarch64-linux-gnu.so)
```

Workaround is to manually patch setup.py to explicitly link against libm:
```bash
sed -i \
  -e '/Extension("fontTools\.cu2qu\.cu2qu",.*\["Lib\/fontTools\/cu2qu\/cu2qu\.py"\]/ s/\])/], libraries=["m"])/' \
  -e '/Extension("fontTools\.qu2cu\.qu2cu",.*\["Lib\/fontTools\/qu2cu\/qu2qu\.py"\]/ s/\])/], libraries=["m"])/' \
  -e '/Extension("fontTools\.misc\.bezierTools",.*\["Lib\/fontTools\/misc\/bezierTools\.py"\]/ s/\])/], libraries=["m"])/' \
  -e '/Extension("fontTools\.pens\.momentsPen",.*\["Lib\/fontTools\/pens\/momentsPen\.py"\]/ s/\])/], libraries=["m"])/' \
  "./setup.py"
```

Environment:

fontTools version: 4.61.1
OS: Amazon Linux 2023 (aarch64)
Python: 3.12.x
Compiler: Clang 20 (git)
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]