Skip to content

Initial Android support #262

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

o01eg
Copy link

@o01eg o01eg commented Jan 19, 2020

Fixes #253 and fixes #158

@jcfr
Copy link
Contributor

jcfr commented Jan 22, 2020

Thanks for the contribution 🙏

still not configurable due heavily usage of TRY_RUN

You may want to try using a recent version of CMake and specify the variable https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING_EMULATOR.html

Here are examples illustrating how the variable is used: https://github.com/dockcross/dockcross/blob/1c10fb2ce795a85707f063eb33e42b0f67d2acec/linux-armv7/Toolchain.cmake#L19

@o01eg
Copy link
Author

o01eg commented Jan 22, 2020

I've tried qemu-arm emulator for armeabi-v7a and I suppose it doesn't work correctly because each check returns /system/bin/linker: No such file or directory.

@o01eg
Copy link
Author

o01eg commented Jan 22, 2020

I've found emulator/qemu/linux-x86_64/qemu-system-armel-headless in android folder, but it doesn't work either:

-- Checking SOABI - cpython-36m-invalid command-line parameter: /tmp/scratch/python-build/CMakeFiles/CMakeTmp/cmTC_6c348.
Hint: use '@foo' to launch a virtual device named 'foo'.
please use -help for more information

@o01eg
Copy link
Author

o01eg commented Jan 24, 2020

@jcfr It looks like there nothing could be used for CMAKE_CROSSCOMPILING_EMULATOR. Qemu for Android cannot execute binary files. Looks like other libraries also excludes TRY_RUN for android cross-compilation:
curl/curl#3292

I suppose it should be maintained manually like cmake/config-mingw/pyconfig.h

@o01eg
Copy link
Author

o01eg commented Jan 24, 2020

No, I found a way:

#!/bin/sh
adb push "$1" /data/local/tmp/ 1>/dev/null 2>/dev/null
adb shell /data/local/tmp/$(basename $1)

It requires to start up emulator with correct ABI, but latest Google emulator for ARM CPUs are 7.1.1 Android.

Now it configures but fails on compilation:

[  1%] Building C object CMakeBuild/extensions/extension_array/CMakeFiles/extension_array.dir/tmp/scratch/Python-3.6.7/Modules/arraymodule.c.o
cd /tmp/scratch/python-build/CMakeBuild/extensions/extension_array && /mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi16 --gcc-toolchain=/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Dextension_array_EXPORTS -I/tmp/scratch/Python-3.6.7/Include -I/tmp/scratch/python-build/bin -I/tmp/scratch/Python-3.6.7/Python  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security  -Wall -Oz -DNDEBUG  -fPIC   -o CMakeFiles/extension_array.dir/tmp/scratch/Python-3.6.7/Modules/arraymodule.c.o   -c /tmp/scratch/Python-3.6.7/Modules/arraymodule.c
[  1%] Linking C shared library ../../../lib/python3.6/lib-dynload/array.so
cd /tmp/scratch/python-build/CMakeBuild/extensions/extension_array && /mnt/new/o01eg/android/cmake/3.10.2.4988404/bin/cmake -E cmake_link_script CMakeFiles/extension_array.dir/link.txt --verbose=1
/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi16 --gcc-toolchain=/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security  -Wall -Oz -DNDEBUG  -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments  -shared -Wl,-soname,array.so -o ../../../lib/python3.6/lib-dynload/array.so CMakeFiles/extension_array.dir/tmp/scratch/Python-3.6.7/Modules/arraymodule.c.o -latomic -lm 
/tmp/scratch/Python-3.6.7/Modules/arraymodule.c:3033: error: undefined reference to 'PyModuleDef_Init'
/tmp/scratch/Python-3.6.7/Modules/clinic/arraymodule.c.h:463: error: undefined reference to '_PyArg_ParseTuple_SizeT'
/tmp/scratch/Python-3.6.7/Modules/arraymodule.c:0: error: undefined reference to 'PyErr_Format'
/tmp/scratch/Python-3.6.7/Modules/arraymodule.c:1937: error: undefined reference to 'PyType_IsSubtype'
/tmp/scratch/Python-3.6.7/Modules/arraymodule.c:1938: error: undefined reference to 'PyErr_Format'
/tmp/scratch/Python-3.6.7/Modules/arraymodule.c:0: error: undefined reference to 'PyErr_SetString'
/tmp/scratch/Python-3.6.7/Modules/arraymodule.c:2086: error: undefined reference to 'PyList_New'

@o01eg o01eg force-pushed the android-initial-support branch 2 times, most recently from abd7390 to cfffedc Compare January 24, 2020 21:37
@o01eg
Copy link
Author

o01eg commented Jan 24, 2020

Linker failure can be solved with checks for Clang compiler and option -DANDROID_ALLOW_UNDEFINED_SYMBOLS=On.

Now it fails on assembler

[ 19%] Building ASM object CMakeBuild/extensions/extension_ctypes/CMakeFiles/extension_ctypes.dir/tmp/scratch/Python-3.6.7/Modules/_ctypes/libffi/src/arm/sysv.S.o
cd /tmp/scratch/python-build/CMakeBuild/extensions/extension_ctypes && /mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target armv7-none-linux-androideabi16 -gcc-toolchain /mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot -Dextension_ctypes_EXPORTS -I/tmp/scratch/Python-3.6.7/Include -I/tmp/scratch/python-build/bin -I/tmp/scratch/Python-3.6.7/Python -I/tmp/scratch/Python-3.6.7/Modules/_ctypes/libffi/src/arm -I/tmp/scratch/Python-3.6.7/Modules/_ctypes/libffi/include -I/tmp/scratch/python-cmake-buildsystem/cmake  -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security  -Oz -DNDEBUG  -fPIC   -o CMakeFiles/extension_ctypes.dir/tmp/scratch/Python-3.6.7/Modules/_ctypes/libffi/src/arm/sysv.S.o -c /tmp/scratch/Python-3.6.7/Modules/_ctypes/libffi/src/arm/sysv.S
/tmp/scratch/Python-3.6.7/Modules/_ctypes/libffi/src/arm/sysv.S:363:2: error: invalid instruction, did you mean: fldmiax?
 fldmiadgt ip, {d0-d7}
 ^
/tmp/scratch/Python-3.6.7/Modules/_ctypes/libffi/src/arm/sysv.S:399:2: error: invalid instruction
 stmeqia r2, {r0, r1}
 ^
/tmp/scratch/Python-3.6.7/Modules/_ctypes/libffi/src/arm/sysv.S:412:2: error: invalid instruction, did you mean: fstmiax?
 fstmiadeq r2, {d0-d3}
 ^
/tmp/sysv-89fdb2.s:263:2: error: invalid instruction
 fstmfdd sp!, {d0-d7}
 ^
/tmp/sysv-89fdb2.s:313:2: error: invalid instruction, did you mean: fldmiax?
 fldmiad sp, {d0-d1}
 ^
/tmp/sysv-89fdb2.s:316:2: error: invalid instruction, did you mean: fldmiax?
 fldmiad sp, {d0-d3}

@o01eg
Copy link
Author

o01eg commented Jan 24, 2020

I have to disable extension -DENABLE_DECIMAL=Off -DENABLE_CTYPES=Off . Now I get error:

[ 57%] Linking C executable _freeze_importlib
cd /tmp/scratch/python-build/CMakeBuild/libpython && /mnt/new/o01eg/android/cmake/3.10.2.4988404/bin/cmake -E cmake_link_script CMakeFiles/_freeze_importlib.dir/link.txt --verbose=1
/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi16 --gcc-toolchain=/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/mnt/new/o01eg/android/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security  -Wall -Oz -DNDEBUG   -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Qunused-arguments -Wl,--gc-sections  CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Programs/_freeze_importlib.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/getbuildinfo.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/myreadline.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/parsetok.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/tokenizer.c.o CMakeFiles/_freeze_importlib.dir/__/__/CMakeFiles/config.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/gcmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/main.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/getpath.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_codecsmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/errnomodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/signalmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_sre.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/symtablemodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_weakref.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/xxsubtype.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/zipimport.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/accu.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/bytesobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/namespaceobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/odictobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/abstract.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/boolobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/bytearrayobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/bytes_methods.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/capsule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/cellobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/classobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/codeobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/complexobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/descrobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/dictobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/enumobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/exceptions.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/fileobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/floatobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/frameobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/funcobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/genobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/iterobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/listobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/longobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/memoryobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/methodobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/moduleobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/object.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/obmalloc.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/rangeobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/setobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/sliceobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/structseq.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/tupleobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/typeobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/unicodectype.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/unicodeobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Objects/weakrefobject.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/acceler.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/bitset.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/firstsets.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/grammar1.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/grammar.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/listnode.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/metagrammar.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/node.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/parser.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Parser/pgen.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/dynload_shlib.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/dynamic_annotations.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/fileutils.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pyhash.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pylifecycle.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pystrhex.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pystrtod.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pytime.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/thread.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/asdl.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/ast.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/bltinmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/ceval.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/codecs.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/compile.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/dtoa.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/errors.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/formatter_unicode.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/future.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/getargs.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/getcompiler.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/getcopyright.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/getopt.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/getplatform.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/getversion.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/graminit.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/import.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/importdl.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/marshal.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/modsupport.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/mysnprintf.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/mystrtoul.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/peephole.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pyarena.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pyctype.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pyfpe.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pymath.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pystate.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pystrcmp.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/Python-ast.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/pythonrun.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/random.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/structmember.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/symtable.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/sysmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/traceback.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/_warnings.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Python/frozenmain.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_collectionsmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_datetimemodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/timemodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_io/_iomodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_io/bufferedio.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_io/bytesio.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_io/fileio.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_io/iobase.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_io/stringio.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_io/textio.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_threadmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/atexitmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/faulthandler.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_opcode.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_pickle.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_stat.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/hashtable.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_tracemalloc.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/posixmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/pwdmodule.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/_posixsubprocess.c.o CMakeFiles/_freeze_importlib.dir/tmp/scratch/Python-3.6.7/Modules/socketmodule.c.o  -o _freeze_importlib -ldl -latomic -lm 
/tmp/scratch/Python-3.6.7/Python/fileutils.c:65: error: undefined reference to 'nl_langinfo'
/tmp/scratch/Python-3.6.7/Python/fileutils.c:1685: error: undefined reference to 'localeconv'
/tmp/scratch/Python-3.6.7/Python/pylifecycle.c:233: error: undefined reference to 'nl_langinfo'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@o01eg
Copy link
Author

o01eg commented Jan 24, 2020

To fix localeconv error I have to set -DANDROID_PLATFORM=21 and disable HAVE_LANGINFO_H for android.

Now I stopped on error:

[ 62%] Generating /tmp/scratch/Python-3.6.7/Python/importlib_external.h, /tmp/scratch/Python-3.6.7/Python/importlib.h
cd /tmp/scratch/python-build/CMakeBuild/libpython && /tmp/adb-emu.sh /tmp/scratch/python-build/CMakeBuild/libpython/_freeze_importlib /tmp/scratch/Python-3.6.7/Lib/importlib/_bootstrap_external.py /tmp/scratch/Python-3.6.7/Python/importlib_external.h

I suppose it shouldn't be called from emulation.

@o01eg
Copy link
Author

o01eg commented Jan 24, 2020

I've managed to solve it by fix adb-emu.sh.

It is left last step:

[100%] Relocate _sysconfigdata_m_generic_.py and update pybuilddir.txt
cd /tmp/scratch/python-build/bin && /tmp/adb-emu.sh /tmp/scratch/python-build/bin/python -E -S -m sysconfig --generate-posix-vars

But at least I already get ./lib/libpython3.6m.a

@o01eg o01eg force-pushed the android-initial-support branch from cfffedc to c841b09 Compare January 24, 2020 23:10
@o01eg
Copy link
Author

o01eg commented Jan 24, 2020

I've disabled "Relocate sysconfigdata_m_generic_.py and update pybuilddir.txt" step and python successfully built.

Now it fails on install target:

-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/etree/cElementTree.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/parsers/__init__.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/parsers/expat.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/sax/__init__.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/sax/_exceptions.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/sax/expatreader.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/sax/handler.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/sax/saxutils.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xml/sax/xmlreader.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xmlrpc/__init__.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xmlrpc/client.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/xmlrpc/server.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/zipapp.py
-- Up-to-date: /tmp/scratch/python_install/lib/python3.6/zipfile.py
/tmp/scratch/python_install/bin/python: /tmp/scratch/python_install/bin/python: cannot execute binary file
/tmp/scratch/python_install/bin/python: /tmp/scratch/python_install/bin/python: cannot execute binary file

@jcfr
Copy link
Contributor

jcfr commented Jan 24, 2020

Thanks @o01eg for working on this and sharing your progress 🙏

Just done with a week long hackathon, I will be traveling for few days and then will head to an other week long hackathon ... this means that I may not have a lot of time to review your awesome work right away.

@jcfr jcfr added Project: crosscompilation crosscompilation specific Type: Enhancement Improvement to functionality labels Jan 24, 2020
@o01eg
Copy link
Author

o01eg commented Jan 24, 2020

I've removed last python call in installation and now I get install target to work.

@o01eg
Copy link
Author

o01eg commented Oct 26, 2020

I've rebased it. Does something need to be done to be accepted?

@o01eg
Copy link
Author

o01eg commented Nov 21, 2020

Fixed configuration for Android-x86

@o01eg
Copy link
Author

o01eg commented Mar 31, 2021

@o01eg o01eg force-pushed the android-initial-support branch 7 times, most recently from 322127e to 555170d Compare October 13, 2021 11:55
@o01eg o01eg force-pushed the android-initial-support branch 16 times, most recently from 189c857 to 4d02b74 Compare October 13, 2021 19:08
@o01eg
Copy link
Author

o01eg commented Oct 13, 2021

Add Github Actions CI to build it

@o01eg o01eg force-pushed the android-initial-support branch from 4d02b74 to d47d7ce Compare March 31, 2022 19:09
@o01eg
Copy link
Author

o01eg commented Mar 31, 2022

@o01eg
Copy link
Author

o01eg commented May 8, 2022

Can I do something else for this PR to be accepted?

@jcfr jcfr mentioned this pull request Jan 26, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Project: crosscompilation crosscompilation specific Type: Enhancement Improvement to functionality
Development

Successfully merging this pull request may close these issues.

Compile Python for Android? Android Cross-compilation.
2 participants