python-build-standalone
python-build-standalone copied to clipboard
Supporting linking musl build artifacts to Rust projects
I still haven't given up on reviving the PyOxidizer project and upgrading the Python distributions that it ships with to more recent versions (up to 3.13) ;-) I'm nearly done with the update in my fork, except for the musl libc build where I ran into an issue as follows.
At some point in the past, PBS decided to build musl-based Python distributions with musl 1.2.5. This version added support for the preadv2/pwritev2 syscalls, and the source code of Python actually uses these syscalls in Modules/posixmodule.c (protected by an #ifdef guard). PyOxidizer produces executables embedding a Python interpreter by wrapping it in Rust code and then using the Rust toolchain to link to the build artifacts published by the PBS project. However, Rust's x86_64-unknown-linux-musl build target ships with musl 1.2.3 for the time being, which does not have preadv2/pwritev2. Therefore, trying to compile a PyOxidizer project with a recent PBS build of Python using musl libc fails with the following linker error:
/usr/bin/ld: /tmp/pyoxidizerm7APCE/build/target/x86_64-unknown-linux-musl/debug/deps/libpyo3_ffi-ee08b5301f7179af.rlib(posixmodule.o): in function `os_preadv':
posixmodule.c:(.text+0x8a8e): undefined reference to `preadv2'
/usr/bin/ld: /tmp/pyoxidizerm7APCE/build/target/x86_64-unknown-linux-musl/debug/deps/libpyo3_ffi-ee08b5301f7179af.rlib(posixmodule.o): in function `os_pwritev':
posixmodule.c:(.text+0x900e): undefined reference to `pwritev2'
collect2: error: ld returned 1 exit status
(See the failed CI run here).
My question is: would it be possible to make the published tarballs of musl PBS builds ship libc.a from musl libc, or, alternatively, can you include the version of musl libc used for the build in PYTHON.json so PyOxidizer could download the appropriate version of a pre-compiled musl libc from another source to finish the build?
I think we want to ship dynamically linked musl builds instead of static builds — we haven't started on that work though.