Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkgsCross.python3Packages.cffi passes -I${buildPackages.python}/include to gcc #186525

Closed
ghost opened this issue Aug 13, 2022 · 4 comments
Closed
Labels
0.kind: bug 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on

Comments

@ghost
Copy link

ghost commented Aug 13, 2022

Note: I don't expect anybody else to fix this for me, but I also want to acknowledge that my python skills are totally inadequate for the task. This bug is filed mostly so I can reference it as justification for #186527.

Describe the bug

Cross-compilation of python3Packages.cffi (and probably many other packages too) ends up invoking the C compiler with a -I flag pointing to the build platform's python headers. This works sometimes, but will fail if the build and host platform have differently-sized long types. The include/python3.10/pyconfig.h file is platform-specific, so it matters whether the build's pyconfig.h is used versus the host's. However we've probably been "getting away with it" when both host and build are ILP64 platforms.

nix build -f . -L pkgsCross.mips64el-linux-gnuabin32.python3Packages.cffi

fails with (reformatted for readability):

python3.10-cffi> mips64el-unknown-linux-gnuabin32-gcc \
  -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DFFI_BUILDING=1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE \
  -I/nix/store/gz6a4x3vcj4rjb098gp76xf36fzb14dw-libffi-mips64el-unknown-linux-gnuabin32-3.4.2-dev/include \
  -I/nix/store/ng6m2yhqk7vsa1agyn0w2km1g011bb74-python3-3.10.5/include/python3.10 \
  -c c/_cffi_backend.c \
  -o build/temp.linux-mips64el-cpython-310/c/_cffi_backend.o

The second -I flag above should point to /nix/store/...-python3-mips64el-unknown-linux-gnuabin32-3.10.5/include/python3.10.

Notify maintainers

@domenkozar

@LnL7

@ghost ghost added the 0.kind: bug label Aug 13, 2022
@veprbl veprbl added the 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on label Aug 14, 2022
@Mindavi
Copy link
Contributor

Mindavi commented Aug 15, 2022

Can't we change it to point to the correct python?

@ghost
Copy link
Author

ghost commented Aug 16, 2022

I could not figure out how to do that.

I the undesirable -I path is coming from somewhere within the bowels of setuptools, which is probably getting it from the PYTHONPATH of some derivation (although it is not clear which one -- cpython? setuptools? cffi?). If that is the case then this is a known not-easily-fixed problem according to this comment by @FRidh:

# TODO: For cross we probably need a different PYTHONPATH, or not

27d3a18

@lopsided98
Copy link
Contributor

Could you check whether this problem still occurs in staging? I think 2e7c392 should fix this.

@ghost
Copy link
Author

ghost commented Sep 1, 2022

Yes! Cherry-picking that commit fixes this issue! Thank you @lopsided98!

@ghost ghost closed this as completed Sep 1, 2022
RaitoBezarius pushed a commit to RaitoBezarius/nixpkgs that referenced this issue Sep 17, 2022
Python cross-compilation is quite difficult, and doesn't work in
several situations, such as:

NixOS#186525

Let's give people the option of cross-compiling `btrfs-progs` to
hostPlatforms for which we cannot cross-compile python.  Unfortunately
btrfs-progs insists on a special configure flag `--disable-python`;
simply being unable to find python isn't enough.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on
Projects
None yet
Development

No branches or pull requests

3 participants