dev-lang/python-3.4.5:3.4/3.4m crash while building throw crossdev (arm64 on adm64) emerge. When build with host system emerge - all is fine. Reproducible: Always Steps to Reproduce: 1. crossdev -S -v -t aarch64-unknown-linux-gnu --genv 'USE="cxx multilib fortran -mudflap nls openmp -sanitize"' 2. echo ">dev-lang/python-3.4.5" >> /usr/aarch64-unknown-linux-gnu/etc/portage/package.mask 3. aarch64-unknown-linux-gnu-emerge -va python Actual Results: In build.log I recieve this line: error: [Errno 2] No such file or directory: '/usr/aarch64-unknown-linux-gnu/tmp/portage/dev-lang/python-3.4.5/work/Python-3.4.5/Modules/_ctypes/libffi' And build is failed. Expected Results: Builded and installed package. Portage 2.3.8 (python 3.4.5-final-0, default/linux/arm64/13.0, gcc-5.4.0, unavailable, 4.12.12-gentoo x86_64) ================================================================= System uname: Linux-4.12.12-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_D-1541_@_2.10GHz-with-gentoo-2.3 KiB Mem: 65933640 total, 47872812 free KiB Swap: 63737852 total, 63737852 free Timestamp of repository gentoo: Sat, 07 Oct 2017 07:30:01 +0000 Head commit of repository gentoo: e6ac6cd2cf934ed317f541a7ff651c90c9474c47 sh bash 4.3_p48-r1 ld GNU ld (Gentoo 2.26.1 p1.0) 2.26.1 app-shells/bash: 4.4_p12::gentoo dev-lang/python: 2.7.14::gentoo sys-apps/openrc: 0.32::gentoo sys-apps/sandbox: 2.12::gentoo sys-devel/binutils: 2.29.1::gentoo Repositories: gentoo location: /usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 ACCEPT_KEYWORDS="arm64 ~arm64" ACCEPT_LICENSE="* -@EULA" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-O2 -pipe -fomit-frame-pointer" CHOST="aarch64-unknown-linux-gnu" CONFIG_PROTECT="/etc /usr/share/easy-rsa /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXXFLAGS="-O2 -pipe -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FCFLAGS="-O2" FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news nodoc noinfo noman parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-O2" GENTOO_MIRRORS="http://distfiles.gentoo.org" LC_ALL="ru_RU.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" PKGDIR="/usr/aarch64-unknown-linux-gnu/packages/" PORTAGE_CONFIGROOT="/usr/aarch64-unknown-linux-gnu/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/usr/aarch64-unknown-linux-gnu/tmp/" USE="acl arm64 berkdb bzip2 cli cracklib crypt cxx dri fortran gdbm iconv ipv6 modules multilib ncurses nls nptl openmp pcre readline seccomp session ssl tcpd unicode xattr zlib" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_ARM="edsp neon thumb thumb2 v4 v5 v6 v7 v8 vfp vfp-d32 vfpv3 vfpv4" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby21 ruby22" USERLAND="GNU" VIDEO_CARDS="fbdev dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Created attachment 498050 [details] python.3.4.5-build.log
Created attachment 498052 [details] python.3.6.3-build.log
Bug reproduced with python 3.6.3. System libffi installed ih host system: [ebuild R ] dev-libs/libffi-3.2.1::gentoo USE="-debug -pax_kernel -static-libs {-test}" ABI_X86="(64) -32 (-x32)" 0 KiB and chroot system: [ebuild R ] dev-libs/libffi-3.2.1::gentoo to /usr/aarch64-unknown-linux-gnu/ USE="-debug -pax_kernel -static-libs {-test}" 0 KiB
Bug reproduced with python 3.7
I think the libffi cross build installs into the wrong location, or at least into a location poorly suited to the task at hand. My workaround for this, which worked for me for aarch64 and python3.6, is to create two symlinks: ln -sv ../lib/libffi/include/ffi.h /usr/aarch64-unknown-linux-gnu/usr/include/ffi.h ln -sv ../lib/libffi/include/ffitarget.h /usr/aarch64-unknown-linux-gnu/usr/include/ffitarget.h If those paths aren't the exact ones on your host/target combination, find them with: find /usr/aarch64-unknown-linux-gnu -name "ffi.h"
py3.6 > warning: building with the bundled copy of libffi is deprecated on this platform. It will not be distributed with Python 3.7 py3.7 > checking for --with-system-ffi... yes > configure: WARNING: --with(out)-system-ffi is ignored on this platform py3.8 > configure: WARNING: --with(out)-system-ffi is ignored on this platform So it seems that at least since py3.7, the additional handling in the ebuilds for making sure things use system libffi are redundant.
I can confirm this issue on python:3.8 It looks like the whole lib and include dirs discovery is broken for "setup.py build" when cross-compiling - it fails to build a few modules because "the necessary bits were not found" (sqlite3, zlib) I think that the most elegant way to fix this would be to use "--sysroot" parameter of the compiler/linker, setup.py already parses it and appends to search paths (this fixes the build), but that also affects build stage where libs/includes are already discovered correctly. Another option would be to patch SYSROOT discovery in setup.py So I am not sure which workaround is the best, any ideas? (In reply to Scott Howard from comment #5) > I think the libffi cross build installs into the wrong location, or at least > into a location poorly suited to the task at hand. I believe this behaviour is correct, it is explained in libffi ebuild, https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-libs/libffi/libffi-3.3-r2.ebuild#n61
Created attachment 697809 [details, diff] patch to add --sysroot option to CFLAGS/LDFLAGS
With dev-lang/python-3.9.5_p2 this issue does not happen
(In reply to Alex Kovryhin from comment #9) > With dev-lang/python-3.9.5_p2 this issue does not happen Thank you.
Hi, I seem to have reproduced this issue with "dev-lang/python-3.9.9" when trying to do crossdev for mips64el. Relevant logs: ``` mips64el-unknown-linux-gnu-gcc -fPIC -Wno-unused-result -Wsign-compare -DNDEBUG -march=loongson2f -Wa,-mfix-loongson2f-nop -O2 -pipe -fwrapv -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include -I. -I/usr/mips64el-unknown-linux-gnu/usr/include/ncursesw -I/usr/mips64el-unknown-linux-gnu/usr/include -I/usr/mips64el-unknown-linux-gnu/tmp/portage/dev-lang/python-3.9.9/work/Python-3.9.9/Include -I/usr/mips64el-unknown-linux-gnu/tmp/portage/dev-lang/python-3.9.9/work/Python-3.9.9 -c /usr/mips64el-unknown-linux-gnu/tmp/portage/dev-lang/python-3.9.9/work/Python-3.9.9/Modules/_ctypes/_ctypes.c -o build/temp.linux-mips64el-3.9/usr/mips64el-unknown-linux-gnu/tmp/portage/dev-lang/python-3.9.9/work/Python-3.9.9/Modules/_ctypes/_ctypes.o -DPy_BUILD_CORE_MODULE /usr/mips64el-unknown-linux-gnu/tmp/portage/dev-lang/python-3.9.9/work/Python-3.9.9/Modules/_ctypes/_ctypes.c:107:10: fatal error: ffi.h: No such file or directory 107 | #include <ffi.h> | ^~~~~~~ compilation terminated. Python build finished successfully! The necessary bits to build these optional modules were not found: _bz2 _curses _curses_panel _dbm _gdbm _lzma _tkinter readline zlib To find the necessary bits, look in setup.py in detect_modules() for the module's name. The following modules found by detect_modules() in setup.py, have been built by the Makefile instead, as configured by the Setup files: _abc atexit pwd time Failed to build these modules: _ctypes ``` My "emerge --info": ``` Portage 3.0.28 (python 3.9.9-final-0, default/linux/amd64/17.1, gcc-11.2.0, glibc-2.33-r7, 5.10.78-gentoo-dist x86_64) ================================================================= System uname: Linux-5.10.78-gentoo-dist-x86_64-Intel-R-_Core-TM-_i7-4558U_CPU_@_2.80GHz-with-glibc2.33 KiB Mem: 8150292 total, 5945968 free KiB Swap: 10485756 total, 10485756 free Timestamp of repository gentoo: Sun, 05 Dec 2021 00:45:01 +0000 Head commit of repository gentoo: f860b3e4f444f2bc3b9c474c2438a0d42c1a6d21 sh bash 5.1_p8 ld GNU ld (Gentoo 2.37_p1 p0) 2.37 app-shells/bash: 5.1_p8::gentoo dev-lang/perl: 5.34.0-r3::gentoo dev-lang/python: 3.9.9::gentoo, 3.10.0_p1::gentoo sys-apps/baselayout: 2.7-r3::gentoo sys-apps/openrc: 0.44.9::gentoo sys-apps/sandbox: 2.25::gentoo sys-devel/autoconf: 2.71-r1::gentoo sys-devel/automake: 1.16.4::gentoo sys-devel/binutils: 2.37_p1::gentoo sys-devel/gcc: 11.2.0::gentoo sys-devel/gcc-config: 2.4::gentoo sys-devel/libtool: 2.4.6-r6::gentoo sys-devel/make: 4.3::gentoo sys-kernel/linux-headers: 5.10-r1::gentoo (virtual/os-headers) sys-libs/glibc: 2.33-r7::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 sync-rsync-extra-opts: sync-rsync-verify-max-age: 24 sync-rsync-verify-jobs: 1 sync-rsync-verify-metamanifest: yes crossdev location: /var/db/repos/crossdev masters: gentoo priority: 10 ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="@FREE" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -O2 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo" CXXFLAGS="-march=native -O2 -pipe" DISTDIR="/var/cache/distfiles" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR" FCFLAGS="-march=native -O2 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-march=native -O2 -pipe" GENTOO_MIRRORS="https://gentoo.osuosl.org/" LANG="en_US.utf8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" PKGDIR="/var/cache/binpkgs" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" USE="acl amd64 bzip2 cli crypt dri fortran gdbm iconv ipv6 libglvnd libtirpc multilib ncurses nls nptl openmp pam pcre readline seccomp split-usr ssl unicode xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2020" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26 ruby27" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, MAKEOPTS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS ```
For now the workaround in https://bugs.gentoo.org/633712#c5 still works. It would still be great for it to be fixed.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3478cabb5f94e9d90ae1ed9e3f7909a1146aa471 commit 3478cabb5f94e9d90ae1ed9e3f7909a1146aa471 Author: Sam James <sam@gentoo.org> AuthorDate: 2022-12-06 19:35:41 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2022-12-06 19:38:51 +0000 dev-lang/python: disable _ctypes, _crypt for cross (CBUILD) Python * Use a hack to deduce libdir to nudge the build system in the right direction because get_libdir can't handle BROOT/CBUILD right now. * Disable _ctypes (libffi) and _crypt (lib(x)crypt) modules for cross (CBUILD) Python as they're not needed and Python struggles to find the libraries correctly. This avoids an issue where setup.py can't handle deducing libdir (or even being passed it) for cross-compilation. Fortunately, cpython is migrating away from setup.py to autotools. Note that this isn't the same as what bug 633712 would've been at the time it was reported, but it certainly showed up the same way on more modern Pythons since we introduced the CBUILD part a few months ago. Bug: https://bugs.gentoo.org/633712 Bug: https://bugs.gentoo.org/794181 Bug: https://bugs.gentoo.org/864911 Signed-off-by: Sam James <sam@gentoo.org> dev-lang/python/python-3.10.8_p3.ebuild | 13 +++++++++++-- dev-lang/python/python-3.11.0_p2.ebuild | 13 +++++++++++-- dev-lang/python/python-3.12.0_alpha2.ebuild | 13 +++++++++++-- dev-lang/python/python-3.8.15_p3.ebuild | 13 +++++++++++-- dev-lang/python/python-3.9.15_p3.ebuild | 13 +++++++++++-- 5 files changed, 55 insertions(+), 10 deletions(-)