SynoCommunity / spksrc

Cross compilation framework to create native packages for the Synology's NAS
https://synocommunity.com
Other
3.04k stars 1.23k forks source link

Fix Python 3 wheels cross-compilation #3944

Closed ymartin59 closed 4 years ago

ymartin59 commented 4 years ago

At the moment application packages publication are stuck because Python 3.8 cross-compiled wheels are badly generated with "x64" architecture in their shared objects (so) file names, which prevent their loading at runtime.

Example: file share/wheelhouse/immutables-0.11-cp36-none-any.whl containes /immutables/_map.cpython-36m-x86_64-linux-gnu.so for all compiled archs.

# file immutables/_map.cpython-36m-x86_64-linux-gnu.so 
immutables/_map.cpython-36m-x86_64-linux-gnu.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, with debug_info, not stripped

Some application installation just fail because of this invalid file naming. It is expected wheels file to match target runtime architecture like _map.cpython-36m-aarch64-linux-gnueabi.so according to toolchain TC_TARGET value.

Pending packages because of this:

And many other Python applications to come...

@roleoroleo and @smaarn did progress with #3726 #3731 #3739 #3833 But there is still trouble according

Related issues: #3737

Objectives: fix current 3.6.10 to be published, and prepare for next version, either 3.7 or directly 3.8

smaarn commented 4 years ago

@ymartin59 open question: is there any specific reason to skipping the intermediary 3.7 version ? I mean, in the "master" branch only 3.6 version seems to be present. On my side I'm working on having a 3.7 version running (turns out that bazarr is upgrading its requirements to 3.7 ...) and I was wondering if there was a specific reason which would imply the dismissal of that one.

ymartin59 commented 4 years ago

@smaarn Simply because it is to much work. Publishing 3.6.10 is still in pending/failed state because of that issue. As far as I know, all applications' package list is expected to run on Python 3.8

smaarn commented 4 years ago

@ymartin59 ok I was misled by the title of this issue to be honest !

I'm having a look to see how this works.

smaarn commented 4 years ago

Ok after a "little" of digging:

From what I see

  1. It's "pretty easy" to find all the files to look for (basically their name end up with that <EXT_SUFFIX>.so)
  2. We need to plug ourselves after the compilation has occurred and before the wheel is being generated to perform the renaming or we need to patch the native python so it can be overriden (using an environment variable maybe ?) or we need to patch every single wheel we're generating so that it enforces a custom value (yuck but maybe feasible...)

What do you think ?

The "guilty code" is under Lib/distutils/sysconfig.py and the variable is defined in configure (line 15280).

smaarn commented 4 years ago

(I checked it on python 3.7.7 to be honest)

ymartin59 commented 4 years ago

Investigate if crossenv https://pypi.org/project/crossenv/ would be an easier and more efficient way to cross-compile wheels.

Safihre commented 4 years ago

This seems fixed with #3953? Yes, the whl file is still wrongly named, but the so files inside have the right name.

ymartin59 commented 4 years ago

PR #3953 has been merged.

smaarn commented 4 years ago

@ymartin59 issue reported for borgmatic seems to be fixed by #4094 (just tested it manually). Whether or not borgbackup is now totally operational is, unfortunately, outside of my area of expertise unfortunately.

ymartin59 commented 4 years ago

@smaarn Thanks for your contribution on Python 3. borgbackup fails to cross-compile for powerpc (qoriq-6.1) with message:

building 'borg.algorithms.msgpack._packer' extension
/spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/bin/powerpc-e500v2-linux-gnuspe-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/powerpc-e500v2-linux-gnuspe/sysroot/usr/include -mcpu=8548 -mhard-float -mfloat-gprs=double -I/spksrc/spk/borgbackup/work-qoriq-6.1/install//var/packages/borgbackup/target/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -L /spksrc/spk/borgbackup/work-qoriq-6.1/install/var/packages/borgbackup/target/lib -I /spksrc/spk/borgbackup/work-qoriq-6.1/install/var/packages/borgbackup/target/include -I/spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/powerpc-e500v2-linux-gnuspe/sysroot/usr/include -mcpu=8548 -mhard-float -mfloat-gprs=double -I/spksrc/spk/borgbackup/work-qoriq-6.1/install//var/packages/borgbackup/target/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -L /spksrc/spk/borgbackup/work-qoriq-6.1/install/var/packages/borgbackup/target/lib -I /spksrc/spk/borgbackup/work-qoriq-6.1/install/var/packages/borgbackup/target/include -I/spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/powerpc-e500v2-linux-gnuspe/sysroot/usr/include -mcpu=8548 -mhard-float -mfloat-gprs=double -I/spksrc/spk/borgbackup/work-qoriq-6.1/install//var/packages/borgbackup/target/include -I/spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/powerpc-e500v2-linux-gnuspe/sysroot/usr/include -mcpu=8548 -mhard-float -mfloat-gprs=double -I/spksrc/spk/borgbackup/work-qoriq-6.1/install//var/packages/borgbackup/target/include -fPIC -D__LITTLE_ENDIAN__=1 -I/spksrc/spk/borgbackup/work-qoriq-6.1/install/var/packages/borgbackup/target/include -Isrc/borg/algorithms/lz4/lib -Isrc/borg/algorithms/zstd/lib -Isrc/borg/algorithms/zstd/lib/common -Isrc/borg/algorithms/zstd/lib/compress -Isrc/borg/algorithms/zstd/lib/decompress -Isrc/borg/algorithms/zstd/lib/dictBuilder -Isrc/borg/algorithms/blake2/ref -I/spksrc/spk/borgbackup/work-qoriq-6.1/crossenv/cross/include -I/spksrc/spk/borgbackup/work-qoriq-6.1/install/var/packages/borgbackup/target/include/python3.7m -c src/borg/algorithms/msgpack/_packer.cpp -o build/temp.linux-powerpc-3.7/src/borg/algorithms/msgpack/_packer.o
In file included from /spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/powerpc-e500v2-linux-gnuspe/sysroot/usr/include/endian.h:36:0,
                 from /spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/powerpc-e500v2-linux-gnuspe/sysroot/usr/include/bits/waitstatus.h:64,
                 from /spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/powerpc-e500v2-linux-gnuspe/sysroot/usr/include/stdlib.h:42,
                 from /spksrc/spk/borgbackup/work-qoriq-6.1/install/var/packages/borgbackup/target/include/python3.7m/Python.h:34,
                 from src/borg/algorithms/msgpack/_packer.cpp:4:
/spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/powerpc-e500v2-linux-gnuspe/sysroot/usr/include/bits/endian.h:26:4: error: #error Both BIG_ENDIAN and LITTLE_ENDIAN defined!
 #  error Both BIG_ENDIAN and LITTLE_ENDIAN defined!
    ^
error: command '/spksrc/toolchains/syno-qoriq-6.1/work/powerpc-e500v2-linux-gnuspe/bin/powerpc-e500v2-linux-gnuspe-gcc' failed with exit status 1

May you help about it?

ymartin59 commented 4 years ago

@hgy59 @th0ma7 If I remember well, you have already faced powerpc compilation troubles which required patching original build chain or source. May you please help about this borgbackup ppc compilation failure?

th0ma7 commented 4 years ago

@ymartin59 I can certainly have a look at it but I'll be offline for a few days, perhaps next week. Cheers!

smaarn commented 4 years ago

@ymartin59 @th0ma7 @hgy59 I actually may have found a way to fix it (see #4135 ). Unfortunately I cannot really test it to be sure on the corresponding powerpc architectures.

ymartin59 commented 4 years ago

@smaarn Many thanks. I take it as-is, I have no way to test either.

ymartin59 commented 4 years ago

Thanks everybody. I consider it as fixed - published applications run well as far as I know

rgodinezp commented 4 years ago

@ymartin59 Sorry to bring bad news, but the homeassistant package release 0.114.2-7 still has the same problems in my DS214play (Intel Atom processor, DSM 6.2.3-25426 Update 2):

Attached the logs homeassistant.log homeassistant_install.log

Hope this helps finding root cause and fixing the issue.