cpython: fix cross-compiling extension modules#98915
Conversation
There was a problem hiding this comment.
Splicing doesn't seem to work here. Anyone know why?
There was a problem hiding this comment.
If this is always the case we are going to have a bit of a problem, because all the nativeBuildInputs in case of Python packages are then incorrect.
|
I created an upstream PR: python/cpython#22440 |
2f56545 to
4571e76
Compare
4571e76 to
82c7ed5
Compare
|
I have now implemented this PR as a setup hook. I did not add it to the common Python Also, this PR now fixes #50925. |
|
After looking into it some more, this PR also helps solve #63043. Normally talloc uses |
|
This doesn't fix #63043 for me. Running |
|
Unfortunately, |
|
Yes, it doesn't solve #63043 by itself, you also need to set |
|
Ah. Missed that bit, sorry! |
|
Still doesn't quite work for me: |
|
Oh right, you also have to add both host and build Python as dependencies. I've added the full fix to this PR. |
11b6580 to
cf2bb6e
Compare
|
I fixed the older Python versions as well now. @ofborg build python36.tests python37.tests python38.tests python39.tests python310.tests |
|
3.10 was already broken. @ofborg build python36.tests python37.tests python38.tests python39.tests |
|
Currently we're working on updating the Python packages set. When that is done, I'll push this job to that branch for further testing. That will be about a week from now. |
|
Hi, it's been two weeks; any update? |
|
I pushed the cherry-pick to
Edit: Ouch, ignore that. Apparently, this seems to be have been a bitflip. |
|
I was able to successfully build
|
|
Pushed 0959552 to |
|
https://hydra.nixos.org/eval/1637790 looks good. This now needs a rebase and then it can go in staging. |
cf2bb6e to
1a65c5d
Compare
|
I rebased this to latest staging and pushed again. The only conflict was the addition of the |
|
I successfully built all of |
|
Would it be possible to apply this to 20.09? I think we may be able to avoid the mass-rebuild... |
|
as long it doesn't have any breakages. I'm fine with back-porting it |
|
@matthewbauer While the first version of this was made independently, it's possible the final version relies on #104201 in some ways, too. |
|
A backport would need extensive testing as well first.
…On Tue, 29 Dec 2020, 01:53 Matthew Bauer, ***@***.***> wrote:
Would it be possible to apply this to 20.09? I think we may be able to
avoid the mass-rebuild...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#98915 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQHZ34IC74C5UOK37MP4GDSXESATANCNFSM4R3KRSSA>
.
|
This is my biggest concern. I would prefer not to backport if the scope of everything needed to backport is ill-defined, and likely to introduce regressions. Unstable works great for iteration, but the purpose of the release channel is to allow people to update without fear. |
|
hey just FYI i think this PR broke python extensions under musl libc, have a PR out to fix at #110293. looks like you all are talking about backporting this and it'd be a bummer to backport that breakage too. |
Motivation for this change
Fixes cross-compiling Python native extension modules to host platforms with a different word length than the build platform as well as in a few other cases.
Currently, cross-compiling Python extension modules generally works assuming the build and host platforms have the same word size. This leads to problems like those seen here: #50925 (comment), where x86_64 -> aarch64 works, but x86_64 -> armv7l doesn't. Unfortunately, this PR doesn't fix
btrfs-progs(#50925) andtalloc(#63043), because they do not use setuptools/distutils.This happens because the build Python's headers are used, rather than host Python's headers. The header location and other data used for compiling extension modules are available in the
_sysconfigdata__<kernel>_<platform>module.distutils.sysconfigcan be patched to use this data and then Python needs to be told to usesysconfigdatafrom host Python using the_PYTHON_SYSCONFIGDATA_NAMEenvironment variable. I believe the patch should be upstreamable.There was an ill-fated upstream PR to improve and document Python cross-compilation, avoiding the need to manually construct
_PYTHON_SYSCONFIGDATA_NAME, but based on my quick review I don't think it would have worked for us as is: python/cpython#17420Setting
_PYTHON_HOST_PLATFORMand_PYTHON_SYSCONFIGDATA_NAMEappropriately also fixes some other issues, such as adding the correct platform suffix to extension module file names. This allowscryptographyto build after a few minor fixes.I have tested this PR by cross-compiling a number of Python packages for armv6l, including
requestsandnetifaces, both of which failed before.Things done
sandboxinnix.confon non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)nix path-info -Sbefore and after)