Skip to content
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

Initial Android Support: alternate #280

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

Conversation

victorpaleologue
Copy link

Hello,
I have been using the branch by @o01eg to build Python for Android (from this PR: #262) and managed to make it work with some extra changes.
I hope this set of changes will be interesting as well.

To avoid requiring to connect to a target device while building (which is hard to achieve on simpler buildfarms), I had to provide certain definitions manually. I tested the build with the following definitions:

"-DBUILD_EXTENSIONS_AS_BUILTIN=ON", // Have the extensions built in the Python library.
"-DANDROID_ALLOW_UNDEFINED_SYMBOLS=ON", // Required because of how Python builds its extensions.

// Remove content or features we do not need.
"-DINSTALL_MANUAL=OFF",
"-DINSTALL_TEST=OFF",
"-DINSTALL_DEVELOPMENT=OFF",
"-DWITH_DOC_STRINGS=OFF",

// Disable some Python extensions that are not supported.
"-DENABLE_CTYPES=OFF",
"-DENABLE_DECIMAL=OFF",
"-DENABLE_GRP=OFF",

// KLUDGE: assuming some properties of the target platform to avoid running
// programs on a target device to deduce them.
"-DX87_DOUBLE_ROUNDING=OFF",
"-DTANH_PRESERVES_ZERO_SIGN=ON",
"-DLOG1P_DROPS_ZERO_SIGN=ON",
"-DPOSIX_SEMAPHORES_NOT_ENABLED=OFF",
"-DHAVE_BROKEN_SEM_GETVALUE=OFF",
"-DHAVE_BROKEN_NICE=OFF",
"-DHAVE_BROKEN_POLL=OFF",
"-DHAVE_WORKING_TZSET=ON",
"-DHAVE_ALIGNED_REQUIRED=ON",
"-DHAVE_BROKEN_MBSTOWCS=OFF",
"-DHAVE_COMPUTED_GOTOS=OFF",
"-DHAVE_GLIBC_MEMMOVE_BUG=OFF",
"-DHAVE_LONG_LONG_FORMAT=OFF",
"-DHAVE_SIZE_T_FORMAT=OFF",

o01eg and others added 7 commits May 25, 2021 16:50
It was not effective, and it was visible using Android Studio.
Translated to CMake from a patch on the Yocto project:
http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-devtools/python/python3/0002-Don-t-do-runtime-test-to-get-float-byte-order.patch?h=zeus
It avoids the execution of a program on the target device,
and produces a clearer endianness result.
It avoids the need for checking it by running a program on the target
platform.
…piling

They are already present in source releases, so it is possible to ignore
the regeneration step. We do that only when cross-compiling, because it
is not possible to build for both the host and the target with a single
pass of CMake.
@o01eg
Copy link

o01eg commented Oct 13, 2021

Nice, I'll try it later, but Fix floating point endianness checks helped to fix them on Github Actions Android emulator. Locally I got:

-- Checking for x64 gcc inline assembler
-- Checking for x64 gcc inline assembler - yes
-- Checking whether C doubles are little-endian IEEE 754 binary64
-- Checking whether C doubles are little-endian IEEE 754 binary64 - yes
-- Checking whether C doubles are big-endian IEEE 754 binary64
-- Checking whether C doubles are big-endian IEEE 754 binary64 - no
-- Checking doubles are ARM mixed-endian IEEE 754 binary64
-- Checking doubles are ARM mixed-endian IEEE 754 binary64 - no
-- Checking whether we can use gcc inline assembler to get and set x87 control word
-- Checking whether we can use gcc inline assembler to get and set x87 control word - yes

But in Github Actions I got:

-- Checking for x64 gcc inline assembler
-- Checking for x64 gcc inline assembler - yes
-- Checking whether C doubles are little-endian IEEE 754 binary64
-- Checking whether C doubles are little-endian IEEE 754 binary64 - yes
-- Checking whether C doubles are big-endian IEEE 754 binary64
-- Checking whether C doubles are big-endian IEEE 754 binary64 - yes
-- Checking doubles are ARM mixed-endian IEEE 754 binary64
-- Checking doubles are ARM mixed-endian IEEE 754 binary64 - yes
-- Checking whether we can use gcc inline assembler to get and set x87 control word
-- Checking whether we can use gcc inline assembler to get and set x87 control word - yes

@jcfr
Copy link
Contributor

jcfr commented Dec 27, 2021

@victorpaleologue Thanks for working on the Android support 🙏 and thanks @o01eg for reviewing.

Working on the backlog of pull request, is there anything else from #262 that we should add here ?

@jcfr jcfr added Project: crosscompilation crosscompilation specific Type: Enhancement Improvement to functionality labels Dec 27, 2021
@o01eg
Copy link

o01eg commented Dec 27, 2021

@jcfr I suppose it could be useful to add Github Actions CI build here at least.

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.

None yet

3 participants