astral-sh / astral-sh/python-build-standalone

Consider using LLVM to cross-compile on Linux

Open
#1,100 5 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
4.4k
Forks
314
Avg merge
1d 9h
Merged PRs (30d)
27

Description

LLVM is a [natively a cross-compiler](https://clang.llvm.org/docs/CrossCompilation.html), the target can be specified with the `-target` option. This functionality could be used to cross-compile on Linux for less common architectures (s390x, ppc64le, riscv64, etc). This approach requires a sysroot for the target which could be provided by Debian packages or alternative means. Only a single toolchain is required as LLVM can also target the host.

This would be different than the current approach where gcc is used for cross-compiling. This is done by using cross gcc toolchains from older Debian released to provide glibc compatibility. Glibc compatibility still needs to be considered if LLVM is used but only in the sysroot, not on the host.

Some benefit of the LLVM approach include:
* The host can use a modern Debian or other Linux distro.
* This allows for the use of the [apt packages](https://apt.llvm.org/) provided by LLVM rather than building from source.
* There is no need for a separate host and cross toolchain, LLVM can be used for both.
* binutils is no longer needed, lld can be used for both host and target linking.

This approach could also be done for native builds to allow modern Linux with a sysroot containing an older glibc.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.