Search code examples
pythonyoctocpython

Is it possible to disable _FILE_OFFSET_BITS==64 in CPython (as a Yocto/Poky package)?


I have a bitbake recipe with a dependency on Python2.7.

I'm trying to compile a C file (generated by CFFI) that includes both Python.h and a library header that includes fts.h somewhere down the line. It fails with

#error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"

I noticed that _FILE_OFFSET_BITS is set to 64 in pyconfig.h:1136, and that file is automatically generated, so I'm wondering if I can prevent this #define from being included, at the cost of not being able to access files >2GB.

For the record, Python is being included through

RDEPENDS_${PN} += "python"

in the file

/common/recipes-core/packagegroups/nativesdk-packagegroup-swi-toolchain.bb


Solution

  • Oh it ended up being rather simple!

    files/disable-lfs.patch

    --- Python-2.7.3.orig/configure.in
    +++ Python-2.7.3/configure.in
    @@ -1449,7 +1449,7 @@
     # structures (such as rlimit64) without declaring them. As a
     # work-around, disable LFS on such configurations
    
    -use_lfs=yes
    +use_lfs=no
     AC_MSG_CHECKING(Solaris LFS bug)
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
     #define _LARGEFILE_SOURCE 1
    

    python-native_%.bbappend

    FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
    SRC_URI += "file://disable-lfs.patch"