Mailing List Archive

python3.10rc2 compilation on android/termux/clang12.0.1 fails
I am trying to compile Python3.10rc2 on rather unusual platform (termux on
android). The
gcc version is listed below:
~ $ g++ -v
clang version 12.0.1
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin

I get following warnings and errors:
Python/pytime.c:398:10: warning: implicit conversion from 'long' to
'double' changes value from 9223372036854775807 to 9223372036854775808
[-Wimplicit-const-int-float-conver
sion]
if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {

Python/bootstrap_hash.c:141:17: error: implicit declaration of function
'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
n = getrandom(dest, n, flags);
^
Python/bootstrap_hash.c:145:17: error: implicit declaration of function
'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
n = getrandom(dest, n, flags);

Not sure if this is limitation of the platform or Python codebase needs
fixes.

Thanks
-S
Re: python3.10rc2 compilation on android/termux/clang12.0.1 fails [ In reply to ]
Did previous versions of Python compile successfully? The RC phase wouldn't
be the right time to add support for a new platform.

El mié, 15 sept 2021 a las 10:15, Sandeep Gupta (<gupta.sandeep@gmail.com>)
escribió:

> I am trying to compile Python3.10rc2 on rather unusual platform (termux on
> android). The
> gcc version is listed below:
> ~ $ g++ -v
> clang version 12.0.1
> Target: aarch64-unknown-linux-android24
> Thread model: posix
> InstalledDir: /data/data/com.termux/files/usr/bin
>
> I get following warnings and errors:
> Python/pytime.c:398:10: warning: implicit conversion from 'long' to
> 'double' changes value from 9223372036854775807 to 9223372036854775808
> [-Wimplicit-const-int-float-conver
> sion]
> if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {
>
> Python/bootstrap_hash.c:141:17: error: implicit declaration of function
> 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> n = getrandom(dest, n, flags);
> ^
> Python/bootstrap_hash.c:145:17: error: implicit declaration of function
> 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> n = getrandom(dest, n, flags);
>
> Not sure if this is limitation of the platform or Python codebase needs
> fixes.
>
> Thanks
> -S _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/KEURSMCLUVI7VPKM6M2VUV4JIW6FP66Z/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
Re: python3.10rc2 compilation on android/termux/clang12.0.1 fails [ In reply to ]
Sounds to me as if the first warning is somewhat legit (you can probably
ignore it).

The second seems to be a limitation of your platform -- that code is only
compiled if HAS_GETRANDOM is set by the configure script, so apparently
./configure determined that it exists, but the compiler thinks it doesn't.
Maybe it's in a different header file?

Please understand that your platform is not officially supported so we can
only provide limited hints.

On Wed, Sep 15, 2021 at 10:19 AM Sandeep Gupta <gupta.sandeep@gmail.com>
wrote:

> I am trying to compile Python3.10rc2 on rather unusual platform (termux on
> android). The
> gcc version is listed below:
> ~ $ g++ -v
> clang version 12.0.1
> Target: aarch64-unknown-linux-android24
> Thread model: posix
> InstalledDir: /data/data/com.termux/files/usr/bin
>
> I get following warnings and errors:
> Python/pytime.c:398:10: warning: implicit conversion from 'long' to
> 'double' changes value from 9223372036854775807 to 9223372036854775808
> [-Wimplicit-const-int-float-conver
> sion]
> if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {
>
> Python/bootstrap_hash.c:141:17: error: implicit declaration of function
> 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> n = getrandom(dest, n, flags);
> ^
> Python/bootstrap_hash.c:145:17: error: implicit declaration of function
> 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> n = getrandom(dest, n, flags);
>
> Not sure if this is limitation of the platform or Python codebase needs
> fixes.
>
> Thanks
> -S _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/KEURSMCLUVI7VPKM6M2VUV4JIW6FP66Z/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


--
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
Re: python3.10rc2 compilation on android/termux/clang12.0.1 fails [ In reply to ]
Hi,

On Wed, Sep 15, 2021 at 7:16 PM Sandeep Gupta <gupta.sandeep@gmail.com> wrote:
> I get following warnings and errors:
> Python/pytime.c:398:10: warning: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conver
> sion]
> if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {

This warning is tracked at: https://bugs.python.org/issue39277

I proposed a fix but i'm not sure that it's correct and so I never did
anything with this PR: https://github.com/python/cpython/pull/17933

> Python/bootstrap_hash.c:141:17: error: implicit declaration of function 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> n = getrandom(dest, n, flags);
> ^
> Python/bootstrap_hash.c:145:17: error: implicit declaration of function 'getrandom' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> n = getrandom(dest, n, flags);

This code path should only be taken if HAVE_GETRANDOM macro is
defined. Is it defined in your pyconfig.h file?

Is the getrandom() function available in your libc?

configure.ac tries to build this code:
---
#include <sys/random.h>

int main() {
char buffer[1];
const size_t buflen = sizeof(buffer);
const int flags = 0;
/* ignore the result, Python checks for ENOSYS at runtime */
(void)getrandom(buffer, buflen, flags);
return 0;
}
---

Maybe Android needs a different #include? Or a different test?

> Not sure if this is limitation of the platform or Python codebase needs fixes.

Enhancements are welcomed :-)

Victor
--
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/H35G7QNDUFNQS6AXMN76K3FRE63BXOXF/
Code of Conduct: http://python.org/psf/codeofconduct/
Re: python3.10rc2 compilation on android/termux/clang12.0.1 fails [ In reply to ]
As you are using termux it might be worth checking out the build
arguments and patches termux uses to build their own version of python
(Currently 3.9.7):
https://github.com/termux/termux-packages/tree/master/packages/python

I'm not sure if this will be enough to build python3.10 or if additional
patches and build arguments are needed though.


Adrian


On 9/15/21 19:06, Sandeep Gupta wrote:
> I am trying to compile Python3.10rc2 on rather unusual platform
> (termux on android). The
> gcc version is listed below:
> ~ $ g++ -v
> clang version 12.0.1
> Target: aarch64-unknown-linux-android24
> Thread model: posix
> InstalledDir: /data/data/com.termux/files/usr/bin
>
> I get following warnings and errors:
> Python/pytime.c:398:10: warning: implicit conversion from 'long' to
> 'double' changes value from 9223372036854775807 to 9223372036854775808
> [-Wimplicit-const-int-float-conver
> sion]
>    if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {
>
> Python/bootstrap_hash.c:141:17: error: implicit declaration of
> function 'getrandom' is invalid in C99
> [-Werror,-Wimplicit-function-declaration]
>            n = getrandom(dest, n, flags);
>                ^
> Python/bootstrap_hash.c:145:17: error: implicit declaration of
> function 'getrandom' is invalid in C99
> [-Werror,-Wimplicit-function-declaration]
>            n = getrandom(dest, n, flags);
>
> Not sure if this is limitation of the platform or Python codebase
> needs fixes.
>
> Thanks
> -S
>
> _______________________________________________
> Python-Dev mailing list --python-dev@python.org
> To unsubscribe send an email topython-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived athttps://mail.python.org/archives/list/python-dev@python.org/message/KEURSMCLUVI7VPKM6M2VUV4JIW6FP66Z/
> Code of Conduct:http://python.org/psf/codeofconduct/
Re: python3.10rc2 compilation on android/termux/clang12.0.1 fails [ In reply to ]
I looked a bit more into this and managed to run python 3.10.0rc2 on
android in termux. No additional patches were needed, but the build
process isn't straight forward.

Some packages don't build on-device and have to be built on a computer.
Python is one of them
(https://github.com/termux/termux-packages/issues/4157. The issue is
closed because making all packages build on-device is no longer a goal
of termux)

Follow https://github.com/termux/termux-packages/wiki/Build-environment
to set up your termux build environment. You can use Docker, Vagrant,
Ubuntu or Arch Linux. I used docker.

Next build and install python3.10.0rc2 *on the build machine*. You need
python3.10 installed to cross-compile python3.10.

After that go back to the termux packages and change
packages/python/build.sh. All you need to change is version number, url
and hash. Here's a patch anyways:

diff --git a/packages/python/build.sh b/packages/python/build.sh
index c36bff5e5..d9fd86d02 100644
--- a/packages/python/build.sh
+++ b/packages/python/build.sh
@@ -2,10 +2,11 @@ TERMUX_PKG_HOMEPAGE=https://python.org/
 TERMUX_PKG_DESCRIPTION="Python 3 programming language intended to
enable clear programs"
 TERMUX_PKG_LICENSE="PythonPL"
 TERMUX_PKG_MAINTAINER="@termux"
-_MAJOR_VERSION=3.9
-TERMUX_PKG_VERSION=${_MAJOR_VERSION}.7
-TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz
-TERMUX_PKG_SHA256=f8145616e68c00041d1a6399b76387390388f8359581abc24432bb969b5e3c57
+_MAJOR_VERSION=3.10
+_MINOR_VERSION=.0
+TERMUX_PKG_VERSION=${_MAJOR_VERSION}${_MINOR_VERSION}rc2
+TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${_MAJOR_VERSION}${_MINOR_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz
+TERMUX_PKG_SHA256=e75b56088548b7b9ad1f2571e6f5a2315e4808cb6b5fbe8288502afc802b2f24
 TERMUX_PKG_DEPENDS="gdbm, libandroid-support, libbz2, libcrypt,
libffi, liblzma, libsqlite, ncurses, ncurses-ui-libs, openssl, readline,
zlib"
 TERMUX_PKG_RECOMMENDS="clang, make, pkg-config"
 TERMUX_PKG_SUGGESTS="python-tkinter"

Finally just run "./build-package.sh -i -f python" and send
"output/python*.deb" to your phone, where you can install it using dpkg -i.


Adrian

On 9/16/21 14:27, Adrian Freund wrote:
>
> As you are using termux it might be worth checking out the build
> arguments and patches termux uses to build their own version of python
> (Currently 3.9.7):
> https://github.com/termux/termux-packages/tree/master/packages/python
>
> I'm not sure if this will be enough to build python3.10 or if
> additional patches and build arguments are needed though.
>
>
> Adrian
>
>
> On 9/15/21 19:06, Sandeep Gupta wrote:
>> I am trying to compile Python3.10rc2 on rather unusual platform
>> (termux on android). The
>> gcc version is listed below:
>> ~ $ g++ -v
>> clang version 12.0.1
>> Target: aarch64-unknown-linux-android24
>> Thread model: posix
>> InstalledDir: /data/data/com.termux/files/usr/bin
>>
>> I get following warnings and errors:
>> Python/pytime.c:398:10: warning: implicit conversion from 'long' to
>> 'double' changes value from 9223372036854775807 to
>> 9223372036854775808 [-Wimplicit-const-int-float-conver
>> sion]
>>    if (!_Py_InIntegralTypeRange(_PyTime_t, d)) {
>>
>> Python/bootstrap_hash.c:141:17: error: implicit declaration of
>> function 'getrandom' is invalid in C99
>> [-Werror,-Wimplicit-function-declaration]
>>            n = getrandom(dest, n, flags);
>>                ^
>> Python/bootstrap_hash.c:145:17: error: implicit declaration of
>> function 'getrandom' is invalid in C99
>> [-Werror,-Wimplicit-function-declaration]
>>            n = getrandom(dest, n, flags);
>>
>> Not sure if this is limitation of the platform or Python codebase
>> needs fixes.
>>
>> Thanks
>> -S
>>
>> _______________________________________________
>> Python-Dev mailing list --python-dev@python.org
>> To unsubscribe send an email topython-dev-leave@python.org
>> https://mail.python.org/mailman3/lists/python-dev.python.org/
>> Message archived athttps://mail.python.org/archives/list/python-dev@python.org/message/KEURSMCLUVI7VPKM6M2VUV4JIW6FP66Z/
>> Code of Conduct:http://python.org/psf/codeofconduct/
>
> _______________________________________________
> Python-Dev mailing list --python-dev@python.org
> To unsubscribe send an email topython-dev-leave@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived athttps://mail.python.org/archives/list/python-dev@python.org/message/WFKYODUXY3UHENII7U47XQPUIZQFJDG4/
> Code of Conduct:http://python.org/psf/codeofconduct/