Skip to content

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

@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: cross-compilationBuilding packages on a different platform than they will be used on
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions