Commit 453b1e3
[nanvix] E: Phase 4 — build lxml C extensions as .so
Phase 4 of the .a -> .so migration (see
nanvix-todo/cpython-static-to-shared-migration.md section 8).
Promotes the 2 lxml C extension modules (_lxml_etree,
_lxml_elementpath) from statically linked into python.elf to
dlopen-loaded shared objects.
Modules moved from *static* to *shared* in Modules/Setup.local
generation (.nanvix/docker.py):
- _lxml_etree (links liblxml_etree.a + libxslt.a + libexslt.a +
libxml2.a + libz.a from the sysroot)
- _lxml_elementpath (links liblxml_elementpath.a + libxml2.a +
libz.a)
Both modules use the same thin-shim approach the static variant
used: lxml_etree_builtin.c / lxml_elementpath_builtin.c each
register the C extension's PyInit_ entrypoint after pulling in
the Cython-generated implementation from
liblxml_etree.a / liblxml_elementpath.a in the sysroot.
The shim files are unchanged. The lxml/etree.py Python-level
shim that re-exports symbols from `_lxml_etree` continues to
work as-is, because Python's import system finds
.cpython-312.so files in lib-dynload/ exactly like static
modules — the import name `_lxml_etree` resolves either way.
Same trade-off as Phase 2 and Phase 3: each .so embeds its own
copy of the underlying libraries (libxslt, libexslt, libxml2,
libz). _lxml_etree.so is 3645 KB primarily because libxslt and
libxml2 are sizable. _lxml_elementpath.so is 175 KB because it
only needs libxml2.
This trade-off is tracked alongside the Phase 2 + Phase 3 bundled
libs in nanvix-todo/phase2-3-unbundle-bundled-libs.md as a
deferred follow-up optimization PR. Note that libz is already
shared with Phase 3's zlib.so today (each carries its own copy);
the same applies to libxml2 (only used by lxml; if libxml2 had
to be in python.elf for other consumers we'd see the same
visibility merge issue as libm, but it has no Rust
compiler_builtins shadows so we're safe).
Validation on local toolchain (phase0-llfix):
- Both .so files produced and installed under lib-dynload/.
- nm python.elf no longer shows PyInit__lxml_etree or
PyInit__lxml_elementpath.
- python.elf size: 11.20 MB (Phase 3) -> 8.48 MB (Phase 4),
-2.72 MB. python.elf now meets the migration plan's "<=10 MB
stripped" success criterion from Section 10.
- Hello + all Phase 1/2/3 import probes + lxml import-and-parse
smoke + HTTP server smoke + full regrtest 160/160 PASS in
standalone mode.
- test_nanvix_lxml (regrtest's lxml-specific test) included in
the 160/160 and passes.
This completes the migration plan's Phase 4 scope — only Phase 5
(optional dormant module revival for numpy / regex) remains.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 3c60ab2 commit 453b1e3
1 file changed
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | 296 | | |
300 | 297 | | |
301 | 298 | | |
302 | 299 | | |
303 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
| |||
0 commit comments