Commit f5d7669
committed
build: Export the stub's dynamic symbols when libpython is static
The manylinux base container builds CPython with --disable-shared, so on
that platform triton_python_backend_stub links libpython3.x.a and the
Py_* symbols live in the executable rather than a shared library. Python
C extension modules are dlopen'ed and deliberately leave Py_* undefined
-- every one of the 77 lib-dynload modules in the image does, math.so
alone with 63 undefined symbols and no libpython in DT_NEEDED -- so they
can only bind against the stub's dynamic symbol table. Without the
export the stub links and starts, then fails on the first `import math`.
Set ENABLE_EXPORTS, which makes CMake add the platform's flag
(-Wl,--export-dynamic on Linux, per Platform/Linux.cmake), matching how
CPython links its own interpreter.
Gate it on the resolved library being an archive rather than on the
platform. A shared libpython needs no export, so the Debian build is
unaffected, and the condition stays correct if a target moves between
the two linkage modes.
The condition reads PYTHON_LIBRARY, not PYTHON_LIBRARIES: pybind11
arrives through FetchContent_MakeAvailable, which uses add_subdirectory,
so only the cache entry find_library creates crosses back into this
scope. PYTHON_LIBRARIES is a plain variable in pybind11's directory and
is empty here, which would have made this a silent no-op.1 parent f9088ff commit f5d7669
1 file changed
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
288 | 312 | | |
289 | 313 | | |
290 | 314 | | |
| |||
0 commit comments