astral-sh / astral-sh/python-build-standalone
Supporting linking musl build artifacts to Rust projects
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 314
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 27
Description
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](https://github.com/ntamas/PyOxidizer/tree/update-python-distributions), 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](https://github.com/ntamas/PyOxidizer/actions/runs/12698612470/job/35399380879)).
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?
Contributor guide
Assessment
This issue has not been assessed yet.