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
Nuitka in specific Android environments #1163
Comments
Interesting. So far I think people have cross compiled standalone mode programs only. Using clang mode is clearly a must, otherwise gcc specific options will be used, or at least version specific options will be wrong. If your python is statically compiled, it may not expose the needed symbols for extension modules. This is a matter of how the Python is built. Does it support extension modules, or is it a stripped down version that has things compiled in. |
I use cython to generate. So file, it seems to work normally :
|
You should try |
How do I use bdist_nuitka ? |
Few things to consider when using Termux:
|
Using |
Interestingly enough, I am having similar issues with statically built Pythons on Linux with LTO right now. Nuitka is missing out on some linker flags that make sure symbols get exported. A solution for that is likely a solution for this here too. |
I successfully generated the (venv) ~/python/udb-tools $ venv/bin/python -m nuitka --module --output-dir=out --clang --show-scons --include-package=nuitka_test nuitka_test
Nuitka-Options:INFO: Used command line options: --module --output-dir=out --clang --show-scons --include-package=nuitka_test nuitka_test
Nuitka:INFO: Starting Python compilation with Nuitka '0.6.16.2' on Python '3.9' commercial None.
Nuitka-Recursion:WARNING: Recursed to package 'nuitka_test' at '/home/python/udb-tools/nuitka_test' twice.
Nuitka:INFO: Completed Python level compilation and optimization.
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.
Nuitka:INFO: Running C level backend compilation via Scons.
Scons command: /home/python/udb-tools/venv/bin/python -W ignore /home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/inline_copy/bin/scons.py -f /home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/Backend.scons --jobs 8 --warn=no-deprecated --no-site-dir --debug=explain,stacktrace result_name=/home/python/udb-tools/out/nuitka_test source_dir=. nuitka_python=false debug_mode=false python_debug=false unstripped_mode=false module_mode=true full_compat=false experimental= trace_mode=false python_version=3.9 target_arch=aarch64 python_prefix=/usr nuitka_src=/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build module_count=3 module_suffix=.cpython-39.so clang_mode=true show_scons=true
scons: Reading SConscript files ...
Nuitka-Scons:INFO: CC '/data/data/com.termux/files/usr/bin/gcc' version check gives (12, 0, 0)
Nuitka-Scons:INFO: Initial CC: 'gcc'
Nuitka-Scons:INFO: Initial CCVERSION: (12, 0, 0)
Nuitka-Scons:INFO: Backend C compiler: clang (clang).
Nuitka-Scons:INFO: Modes for this compiler are: {'gcc_mode': True, 'clang_mode': True, 'clangcl_mode': False, 'mingw_mode': False, 'msvc_mode': False}
Nuitka-Scons:INFO: Using C11 mode: True
Scons: Compiler used /data/data/com.termux/files/usr/bin/clang
Nuitka-Scons:INFO: Using resource mode: 'incbin'.
Scons: Told to run compilation on 8 CPUs.
Scons: Launching target: ['/home/python/udb-tools/out/nuitka_test.cpython-39.so']
Backend C: 0%| | 0/12scons: done reading SConscript files.
scons: Building targets ...
Nuitka-Scons:INFO: CC '/bin/gcc' version check gives (12, 0, 0)
scons: building `__constants.os' because it doesn't exist | 0/12
clang -o __constants.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src __constants.c
scons: building `__constants_data.os' because it doesn't exist
clang -o __constants_data.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src __constants_data.c
scons: building `__helpers.os' because it doesn't exist
clang -o __helpers.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src __helpers.c
scons: building `__loader.os' because it doesn't exist
clang -o __loader.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src __loader.c
scons: building `module.nuitka_test.os' because it doesn't exist
clang -o module.nuitka_test.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src module.nuitka_test.c
scons: building `module.nuitka_test.test.os' because it doesn't exist
clang -o module.nuitka_test.test.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src module.nuitka_test.test.c
scons: building `static_src/CompiledCellType.os' because it doesn't exist | 1/12
clang -o static_src/CompiledCellType.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src static_src/CompiledCellType.c
scons: building `static_src/CompiledFunctionType.os' because it doesn't exist
clang -o static_src/CompiledFunctionType.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src static_src/CompiledFunctionType.c
scons: building `static_src/CompiledGeneratorType.os' because it doesn't exist
clang -o static_src/CompiledGeneratorType.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src static_src/CompiledGeneratorType.c
scons: building `static_src/CompiledCodeHelpers.os' because it doesn't exist | 3/12
clang -o static_src/CompiledCodeHelpers.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src static_src/CompiledCodeHelpers.c
scons: building `static_src/InspectPatcher.os' because it doesn't exist
clang -o static_src/InspectPatcher.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src static_src/InspectPatcher.c
scons: building `static_src/MetaPathBasedLoader.os' because it doesn't exist
clang -o static_src/MetaPathBasedLoader.os -c -std=c11 -fvisibility=hidden -fwrapv -w -fvisibility=hidden -fvisibility-inlines-hidden -O3 -pipe -fPIC -D_XOPEN_SOURCE -D__NUITKA_NO_ASSERT__ -D_NUITKA_CONSTANTS_FROM_INCBIN -D_NUITKA_FROZEN=0 -D_NUITKA_MODULE -I/usr/include/python3.9 -I. -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/include -I/home/python/udb-tools/venv/lib/python3.9/site-packages/nuitka/build/static_src static_src/MetaPathBasedLoader.c
scons: building `/home/python/udb-tools/out/nuitka_test.cpython-39.so' because it doesn't exist████████████████████████| 12/12
clang -o /home/python/udb-tools/out/nuitka_test.cpython-39.so -z noexecstack -shared __constants.os __constants_data.os __helpers.os __loader.os module.nuitka_test.os module.nuitka_test.test.os static_src/CompiledCellType.os static_src/CompiledFunctionType.os static_src/CompiledGeneratorType.os static_src/CompiledCodeHelpers.os static_src/InspectPatcher.os static_src/MetaPathBasedLoader.os -ldl -lm -lpython3
scons: done building targets. | 13/?
Nuitka-Scons:WARNING: You are not using ccache.
Nuitka:INFO: Keeping build directory 'out/nuitka_test.build'.
Nuitka:INFO: Successfully created 'out/nuitka_test.cpython-39.so'.
(venv) ~/python/udb-tools $ cd out/
(venv) ~/.../udb-tools/out $ mv nuitka_test.cpython-39.so nuitka_test.so
(venv) ~/.../udb-tools/out $ python
Python 3.9.6 (default, Jun 30 2021, 09:17:59)
[Clang 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489 on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nuitka_test
>>> from nuitka_test.test import *
>>> test_hi()
hello, world
>>>
|
Does it mean, it comes down to Nuitka not being allowed to use the version specific extension? Is the Compiling packages is a bit ugly with having to include them. I never got around to adding a Basically this is about hacking things, so --clang is the default in that setup. Any idea, how to recognize it. I was thinking, it might be best, if gcc was detected to be actually a clang. Can you tell me if |
|
if not use
|
well, the module is the init only, and that's not containing the code of the "test" submodule then. With --package, I meant, there ought to be a way to compile a package without having to specify a filename for the package, and then include the package into the compilation of that. Right now, the --module mode has a very ugly user interface, esp. as modules do not really work well through filenames. It's an artifcat of how nuitka works for executables, where the main program is NOT really a module that is importable. Maybe this motivates me, to at least make it more automatic, or warn about it, or both. Making a single module out of a package directory makes no sense if there is other modules below at least. But the user manual describes how to do it actually pretty well. It's just that not everybody is good at reading. Including myself. :) |
So, the linking against python3 is not what Nuitka does normally, extension modules do not link against libraries at all, but instead get their symbols from python binary. Can you provide |
not linking python: (venv) ~/python/out $ nm nuitka_test.cpython-39.so -gD
U PyArg_ParseTuple
U PyArg_ParseTupleAndKeywords
U PyArg_UnpackTuple
U PyAsyncGen_Type
U PyBaseObject_Type
U PyBool_Type
U PyBuffer_Release
U PyByteArray_FromObject
U PyByteArray_FromStringAndSize
U PyByteArray_Type
U PyBytes_FromString
U PyBytes_FromStringAndSize
U PyBytes_Type
U PyCFunction_Type
U PyCMethod_New
U PyCallIter_Type
U PyCallable_Check
U PyCapsule_New
U PyCode_NewWithPosOnlyArgs
U PyCode_Type
U PyComplex_FromDoubles
U PyComplex_Type
U PyCoro_Type
U PyDict_DelItem
U PyDict_DelItemString
U PyDict_GetItem
U PyDict_GetItemString
U PyDict_New
U PyDict_Next
U PyDict_SetItem
U PyDict_SetItemString
U PyDict_Type
U PyEllipsis_Type
U PyErr_BadArgument
U PyErr_ExceptionMatches
U PyErr_Format
U PyErr_GivenExceptionMatches
U PyErr_NoMemory
U PyErr_NormalizeException
U PyErr_Print
U PyErr_PrintEx
U PyErr_WarnEx
U PyErr_WriteUnraisable
U PyEval_EvalCode
U PyEval_EvalCodeEx
U PyEval_EvalFrameEx
U PyEval_GetFrame
U PyEval_GetFuncName
U PyExc_AttributeError
U PyExc_GeneratorExit
U PyExc_ImportError
U PyExc_ImportWarning
U PyExc_IndexError
U PyExc_KeyError
U PyExc_NameError
U PyExc_OverflowError
U PyExc_RuntimeError
U PyExc_StopAsyncIteration
U PyExc_StopIteration
U PyExc_SystemError
U PyExc_TypeError
U PyExc_UnboundLocalError
U PyExc_ValueError
U PyExc_ZeroDivisionError
U PyException_GetContext
U PyException_GetTraceback
U PyException_SetCause
U PyException_SetContext
U PyFloat_FromDouble
U PyFloat_Type
U PyFrame_GetLineNumber
U PyFrame_New
U PyFrame_Type
U PyFrozenSet_New
U PyFrozenSet_Type
U PyFunction_Type
U PyGen_Type
U PyImport_ExecCodeModule
U PyImport_ExecCodeModuleEx
U PyImport_FrozenModules
U PyImport_GetModule
U PyImport_GetModuleDict
U PyImport_ImportFrozenModule
U PyImport_ImportModule
U PyIndex_Check
000000000000a618 T PyInit_nuitka_test
U PyIter_Next
U PyList_Insert
U PyList_New
U PyList_SetItem
U PyList_Type
U PyLong_AsLong
U PyLong_AsLongAndOverflow
U PyLong_FromLong
U PyLong_FromLongLong
U PyLong_FromSsize_t
U PyLong_FromString
U PyLong_FromUnicodeObject
U PyLong_FromUnsignedLongLong
U PyLong_Type
U PyMapping_Check
U PyMarshal_ReadObjectFromString
U PyMem_Malloc
U PyMem_Realloc
U PyMethod_Type
U PyModuleDef_Type
U PyModule_AddObject
U PyModule_Create2
U PyModule_ExecDef
U PyModule_FromDefAndSpec2
U PyModule_GetDef
U PyModule_GetDict
U PyModule_GetFilenameObject
U PyModule_GetName
U PyModule_NewObject
U PyModule_Type
U PyNumber_Add
U PyNumber_AsSsize_t
U PyNumber_FloorDivide
U PyNumber_InPlaceAdd
U PyNumber_InPlaceLshift
U PyNumber_InPlaceMultiply
U PyNumber_Index
U PyNumber_Negative
U PyNumber_Subtract
U PyNumber_ToBase
U PyObject_Call
U PyObject_CallFunctionObjArgs
U PyObject_CallMethodObjArgs
U PyObject_CallObject
U PyObject_ClearWeakRefs
U PyObject_Free
U PyObject_GC_Del
U PyObject_GC_Track
U PyObject_GC_UnTrack
U PyObject_GenericGetAttr
U PyObject_GenericSetAttr
U PyObject_GetAttr
U PyObject_GetAttrString
U PyObject_GetBuffer
U PyObject_GetIter
U PyObject_IsInstance
U PyObject_IsSubclass
U PyObject_IsTrue
U PyObject_LengthHint
U PyObject_Malloc
U PyObject_Realloc
U PyObject_Repr
U PyObject_RichCompare
U PyObject_RichCompareBool
U PyObject_SelfIter
U PyObject_SetAttr
U PyObject_SetAttrString
U PyObject_Size
U PyObject_Str
U PyRange_Type
U PySeqIter_Type
U PySequence_Check
U PySequence_GetItem
U PySequence_InPlaceConcat
U PySet_Add
U PySet_New
U PySet_Type
U PySlice_New
U PySlice_Type
U PyStructSequence_InitType
U PyStructSequence_New
U PySuper_Type
U PySys_GetObject
U PyTraceBack_Type
U PyTuple_New
U PyTuple_Pack
U PyTuple_Type
U PyType_GetFlags
U PyType_IsSubtype
U PyType_Ready
U PyType_Type
U PyUnicode_AsUTF8
U PyUnicode_AsUnicode
U PyUnicode_Concat
U PyUnicode_DecodeUTF8
U PyUnicode_FindChar
U PyUnicode_Format
U PyUnicode_FromFormat
U PyUnicode_FromOrdinal
U PyUnicode_FromString
U PyUnicode_FromStringAndSize
U PyUnicode_InternInPlace
U PyUnicode_New
U PyUnicode_Substring
U PyUnicode_Type
U Py_BuildValue
U Py_CompileStringExFlags
U Py_Exit
U Py_GenericAlias
U Py_GenericAliasType
U _PyArg_NoKeywords
U _PyAsyncGenWrappedValue_Type
U _PyByteArray_empty_string
U _PyBytes_Resize
U _PyDict_NewPresized
U _PyErr_FormatFromCause
U _PyGen_FetchStopIterationValue
U _PyGen_SetStopIterationValue
U _PyImport_FixupExtensionObject
U _PyLong_New
U _PyObject_GC_Malloc
U _PyObject_GC_New
U _PyObject_GC_Resize
U _PyObject_HasLen
U _PyObject_New
U _PyRuntime
U _PySet_NextEntry
U _PyType_Lookup
U _PyUnicode_Ready
U _Py_Dealloc
U _Py_EllipsisObject
U _Py_FalseStruct
U _Py_NewReference
U _Py_NoneStruct
U _Py_NotImplementedStruct
U _Py_PackageContext
U _Py_TrueStruct
U __cxa_atexit@LIBC
U __cxa_finalize@LIBC
U __errno@LIBC
U __register_atfork@LIBC
U abort@LIBC
U dirname@LIBC
U dladdr@LIBC
U dlerror@LIBC
U dlopen@LIBC
U dlsym@LIBC
U fmod@LIBC
U getenv@LIBC
U getpid@LIBC
U gettimeofday@LIBC
U mbstowcs@LIBC
U memcmp@LIBC
U memcpy@LIBC
U memset@LIBC
U pow@LIBC
U printf@LIBC
U puts@LIBC
U snprintf@LIBC
U strcasecmp@LIBC
U strcat@LIBC
U strchr@LIBC
U strcmp@LIBC
U strcpy@LIBC
U strdup@LIBC
U strlen@LIBC
U strncmp@LIBC
U strncpy@LIBC
U strrchr@LIBC
U vsprintf@LIBC
U wcslen@LIBC
(venv) ~/python/out $ ldd nuitka_test.cpython-39.so
libdl.so
libm.so
libc.so
(venv) ~/python/out $ mv nuitka_test.cpython-39.so nuitka_test.so
(venv) ~/python/out $ python
Python 3.9.6 (default, Jun 30 2021, 09:17:59)
[Clang 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489 on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nuitka_test
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen failed: cannot locate symbol "PyFloat_Type" referenced by "/data/data/com.termux/files/home/python/out/nuitka_test.so"...
linking python3 nm nuitka_test.cpython-39.so -gD
U PyArg_ParseTuple
U PyArg_ParseTupleAndKeywords
U PyArg_UnpackTuple
U PyAsyncGen_Type
U PyBaseObject_Type
U PyBool_Type
U PyBuffer_Release
U PyByteArray_FromObject
U PyByteArray_FromStringAndSize
U PyByteArray_Type
U PyBytes_FromString
U PyBytes_FromStringAndSize
U PyBytes_Type
U PyCFunction_Type
U PyCMethod_New
U PyCallIter_Type
U PyCallable_Check
U PyCapsule_New
U PyCode_NewWithPosOnlyArgs
U PyCode_Type
U PyComplex_FromDoubles
U PyComplex_Type
U PyCoro_Type
U PyDict_DelItem
U PyDict_DelItemString
U PyDict_GetItem
U PyDict_GetItemString
U PyDict_New
U PyDict_Next
U PyDict_SetItem
U PyDict_SetItemString
U PyDict_Type
U PyEllipsis_Type
U PyErr_BadArgument
U PyErr_ExceptionMatches
U PyErr_Format
U PyErr_GivenExceptionMatches
U PyErr_NoMemory
U PyErr_NormalizeException
U PyErr_Print
U PyErr_PrintEx
U PyErr_WarnEx
U PyErr_WriteUnraisable
U PyEval_EvalCode
U PyEval_EvalCodeEx
U PyEval_EvalFrameEx
U PyEval_GetFrame
U PyEval_GetFuncName
U PyExc_AttributeError
U PyExc_GeneratorExit
U PyExc_ImportError
U PyExc_ImportWarning
U PyExc_IndexError
U PyExc_KeyError
U PyExc_NameError
U PyExc_OverflowError
U PyExc_RuntimeError
U PyExc_StopAsyncIteration
U PyExc_StopIteration
U PyExc_SystemError
U PyExc_TypeError
U PyExc_UnboundLocalError
U PyExc_ValueError
U PyExc_ZeroDivisionError
U PyException_GetContext
U PyException_GetTraceback
U PyException_SetCause
U PyException_SetContext
U PyFloat_FromDouble
U PyFloat_Type
U PyFrame_GetLineNumber
U PyFrame_New
U PyFrame_Type
U PyFrozenSet_New
U PyFrozenSet_Type
U PyFunction_Type
U PyGen_Type
U PyImport_ExecCodeModule
U PyImport_ExecCodeModuleEx
U PyImport_FrozenModules
U PyImport_GetModule
U PyImport_GetModuleDict
U PyImport_ImportFrozenModule
U PyImport_ImportModule
U PyIndex_Check
000000000000a698 T PyInit_nuitka_test
U PyIter_Next
U PyList_Insert
U PyList_New
U PyList_SetItem
U PyList_Type
U PyLong_AsLong
U PyLong_AsLongAndOverflow
U PyLong_FromLong
U PyLong_FromLongLong
U PyLong_FromSsize_t
U PyLong_FromString
U PyLong_FromUnicodeObject
U PyLong_FromUnsignedLongLong
U PyLong_Type
U PyMapping_Check
U PyMarshal_ReadObjectFromString
U PyMem_Malloc
U PyMem_Realloc
U PyMethod_Type
U PyModuleDef_Type
U PyModule_AddObject
U PyModule_Create2
U PyModule_ExecDef
U PyModule_FromDefAndSpec2
U PyModule_GetDef
U PyModule_GetDict
U PyModule_GetFilenameObject
U PyModule_GetName
U PyModule_NewObject
U PyModule_Type
U PyNumber_Add
U PyNumber_AsSsize_t
U PyNumber_FloorDivide
U PyNumber_InPlaceAdd
U PyNumber_InPlaceLshift
U PyNumber_InPlaceMultiply
U PyNumber_Index
U PyNumber_Negative
U PyNumber_Subtract
U PyNumber_ToBase
U PyObject_Call
U PyObject_CallFunctionObjArgs
U PyObject_CallMethodObjArgs
U PyObject_CallObject
U PyObject_ClearWeakRefs
U PyObject_Free
U PyObject_GC_Del
U PyObject_GC_Track
U PyObject_GC_UnTrack
U PyObject_GenericGetAttr
U PyObject_GenericSetAttr
U PyObject_GetAttr
U PyObject_GetAttrString
U PyObject_GetBuffer
U PyObject_GetIter
U PyObject_IsInstance
U PyObject_IsSubclass
U PyObject_IsTrue
U PyObject_LengthHint
U PyObject_Malloc
U PyObject_Realloc
U PyObject_Repr
U PyObject_RichCompare
U PyObject_RichCompareBool
U PyObject_SelfIter
U PyObject_SetAttr
U PyObject_SetAttrString
U PyObject_Size
U PyObject_Str
U PyRange_Type
U PySeqIter_Type
U PySequence_Check
U PySequence_GetItem
U PySequence_InPlaceConcat
U PySet_Add
U PySet_New
U PySet_Type
U PySlice_New
U PySlice_Type
U PyStructSequence_InitType
U PyStructSequence_New
U PySuper_Type
U PySys_GetObject
U PyTraceBack_Type
U PyTuple_New
U PyTuple_Pack
U PyTuple_Type
U PyType_GetFlags
U PyType_IsSubtype
U PyType_Ready
U PyType_Type
U PyUnicode_AsUTF8
U PyUnicode_AsUnicode
U PyUnicode_Concat
U PyUnicode_DecodeUTF8
U PyUnicode_FindChar
U PyUnicode_Format
U PyUnicode_FromFormat
U PyUnicode_FromOrdinal
U PyUnicode_FromString
U PyUnicode_FromStringAndSize
U PyUnicode_InternInPlace
U PyUnicode_New
U PyUnicode_Substring
U PyUnicode_Type
U Py_BuildValue
U Py_CompileStringExFlags
U Py_Exit
U Py_GenericAlias
U Py_GenericAliasType
U _PyArg_NoKeywords
U _PyAsyncGenWrappedValue_Type
U _PyByteArray_empty_string
U _PyBytes_Resize
U _PyDict_NewPresized
U _PyErr_FormatFromCause
U _PyGen_FetchStopIterationValue
U _PyGen_SetStopIterationValue
U _PyImport_FixupExtensionObject
U _PyLong_New
U _PyObject_GC_Malloc
U _PyObject_GC_New
U _PyObject_GC_Resize
U _PyObject_HasLen
U _PyObject_New
U _PyRuntime
U _PySet_NextEntry
U _PyType_Lookup
U _PyUnicode_Ready
U _Py_Dealloc
U _Py_EllipsisObject
U _Py_FalseStruct
U _Py_NewReference
U _Py_NoneStruct
U _Py_NotImplementedStruct
U _Py_PackageContext
U _Py_TrueStruct
00000000000787f0 B __bss_start
U __cxa_atexit@LIBC
U __cxa_finalize@LIBC
U __errno@LIBC
U __register_atfork@LIBC
00000000000787f0 D _edata
00000000000796f8 B _end
U abort@LIBC
U dirname@LIBC
U dladdr@LIBC
U dlerror@LIBC
U dlopen@LIBC
U dlsym@LIBC
U fmod@LIBC
U getenv@LIBC
U getpid@LIBC
U gettimeofday@LIBC
U mbstowcs@LIBC
U memcmp@LIBC
U memcpy@LIBC
U memset@LIBC
U pow@LIBC
U printf@LIBC
U puts@LIBC
U snprintf@LIBC
U strcasecmp@LIBC
U strcat@LIBC
U strchr@LIBC
U strcmp@LIBC
U strcpy@LIBC
U strdup@LIBC
U strlen@LIBC
U strncmp@LIBC
U strncpy@LIBC
U strrchr@LIBC
U vsprintf@LIBC
U wcslen@LIBC
(venv) ~/python/out $ ldd nuitka_test.cpython-39.so
libdl.so
libm.so
libpython3.so
libc.so
(venv) ~/python/out $ mv nuitka_test.cpython-39.so nuitka_test.so
(venv) ~/python/out $ python
Python 3.9.6 (default, Jun 30 2021, 09:17:59)
[Clang 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489 on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nuitka_test
>>> exit()
|
I was also interested, what symbols the python binary exports. You know, in standard non-Windows configurations (there is't the reversed), Python does not load libpython, but provides the symbols itself. That way, when Nuitka long ago did link extension modules against the Python shared library, however, there are Python things, manylinux comes to mind, where there is no shared Python library, and then it was understood, you are not required to link to it. Only the ldd table of ELF is the difference here, I do not consider the diff any relevant. Let me know. If am correct, this command should be empty for you:
Which would be something to detect and handle by linking against the link library used by the binary. There should be libpython in your ldd output for the python binary then. |
~ $ nm -gD `which python`
U Py_BytesMain
0000000000001d60 D __FINI_ARRAY__
0000000000001d50 D __INIT_ARRAY__
0000000000001d40 D __PREINIT_ARRAY__
0000000000002000 A __bss_start
U __cxa_atexit@LIBC
U __libc_init@LIBC
U __register_atfork@LIBC
0000000000002000 A _edata
0000000000002008 A _end
0000000000000680 T _start This is very different from my output on the Ubuntu host. |
Yes, this is the root cause, and it links against a shared libpython, which does have the exports. I will try and add a detection of this into the linking parts, such that a loaded python DLL will be linked against for the extension modules too. With executables, unless --static-libpython=yes, that's done anyway. That way it won't be about the specific platform, but work for everybody who chooses to do this configuration, or not, should they ever change their mind. |
I would need instructions how to set this up, then I can do this mayhaps. But I don't think I will have the time unless somebody provides funding. |
Without feedback there is nothing I can do, if somebody wants to provide funding and see this implemented, let me know, otherwise this is delayed until such time. |
It seems Termux is working nowadays just fine. |
Sounds great! I'll try it |
I installed Termux on my Android phone And installed Python 3.9 and Nuitka, But when I use
nuitka --module
, I get the wrong code :Environment
I can use the option
--clang
to generate .so file,but the .so file is not work:Can you give me some help or advice on using Nuitka to generate dynamic library files on Android?
The text was updated successfully, but these errors were encountered: