Commit 96d6021
authored
build(before-code-freeze): Export the stub's dynamic symbols when libpython is static (#451)
* 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.
* docs: Correct the stale RHEL_BUILD rationale
The comment said RHEL_BUILD existed because pybind would otherwise pick
up Python 3.6 in the RHEL base container, so PYBIND11_PYTHON_VERSION was
set to force 3.12. That pin has been dropped from build.py -- pybind11
prefers the newest entry of its own Python_ADDITIONAL_VERSIONS list, and
the manylinux base container puts a single interpreter first on PATH.
RHEL_BUILD itself stays: it still selects the stub's link settings
further down. Only the justification was wrong.1 parent f9088ff commit 96d6021
1 file changed
Lines changed: 34 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
99 | 105 | | |
100 | 106 | | |
101 | 107 | | |
| |||
285 | 291 | | |
286 | 292 | | |
287 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
288 | 318 | | |
289 | 319 | | |
290 | 320 | | |
| |||
0 commit comments