[issue28833] cross compilation of third-party extension modules

2016-12-01 Thread Chi Hsuan Yen

Chi Hsuan Yen added the comment:

Well, cross compiling extension modules already works fine...

$ _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_m_linux_aarch64-linux-android 
PYTHONHOME=~/Projects/python3-android/build/21-aarch64-linux-android-4.9/usr 
python3.7 setup.py build_ext
running build_ext
building 'xx' extension
creating build
creating build/temp.linux-x86_64-3.7
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang 
-Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 
-Wall -Wstrict-prototypes -target aarch64-none-linux-android -gcc-toolchain 
/opt/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 
--sysroot=/opt/android-ndk/platforms/android-21/arch-arm64/usr -fPIE 
-fno-integrated-as -target aarch64-none-linux-android -gcc-toolchain 
/opt/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 
--sysroot=/opt/android-ndk/platforms/android-21/arch-arm64/usr -fPIE 
-fno-integrated-as -fPIC 
-I/home/yen/Projects/python3-android/build/21-aarch64-linux-android-4.9/usr/include/python3.7m
 -c xxmodule.c -o build/temp.linux-x86_64-3.7/xxmodule.o
creating build/lib.linux-x86_64-3.7
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -shared 
-target aarch64-none-linux-android -gcc-toolchain 
/opt/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 
--sysroot=/opt/android-ndk/platforms/android-21/arch-arm64/usr -pie 
-L/home/yen/Projects/python3-android/build/21-aarch64-linux-android-4.9/usr/lib 
-target aarch64-none-linux-android -gcc-toolchain 
/opt/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 
--sysroot=/opt/android-ndk/platforms/android-21/arch-arm64/usr -pie 
-L/home/yen/Projects/python3-android/build/21-aarch64-linux-android-4.9/usr/lib 
build/temp.linux-x86_64-3.7/xxmodule.o -o 
build/lib.linux-x86_64-3.7/xx.cpython-37m-aarch64-linux-android.so
clang: warning: argument unused during compilation: '-pie'
clang: warning: argument unused during compilation: '-pie'

And it's running fine, too:

$ adb push build/lib.linux-x86_64-3.7/xx.cpython-37m-aarch64-linux-android.so 
/data/local/tmp
[100%] /data/local/tmp/xx.cpython-37m-aarch64-linux-android.so

$ adb shell
shell@ASUS_Z00E_2:/ $ cd /data/local/tmp
shell@ASUS_Z00E_2:/data/local/tmp $ . ./python3/tools/env.sh
shell@ASUS_Z00E_2:/data/local/tmp $ python3.7m
Python 3.7.0a0 (default:3d660ed2a60e+, Nov 23 2016, 20:22:14) 
[GCC 4.2.1 Compatible Android Clang 3.8.256229 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xx
>>> xx

>>>

Here's my xxmodule.c:

#include "Python.h"

PyDoc_STRVAR(module_doc,
"This is a template module just for instruction.");

static struct PyModuleDef xxmodule = {
PyModuleDef_HEAD_INIT,
"xx",
module_doc,
0,
NULL,
NULL,
NULL,
NULL,
NULL
};

PyMODINIT_FUNC
PyInit_xx(void)
{
return PyModuleDef_Init();
}

And setup.py:

from distutils.core import setup, Extension

module1 = Extension('xx',
sources=['xxmodule.c'])

setup(name='PackageName',
  version='1.0',
  description='This is a demo package',
  ext_modules=[module1])

Both the host and target Python are built from a6e59a2e880e

There's a little bug in the built filename: 
build/lib.linux-x86_64-3.7/xx.cpython-37m-aarch64-linux-android.so, which 
should be build/lib.linux-aarch64-3.7/xx.cpython-37m-aarch64-linux-android.so.

Also, I guess there may be quirks if NDK or the cross-built CPython is at 
different locations than built-time configurations. Those issues can be left to 
the future.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28849] do not define sys.implementation._multiarch on Android

2016-12-01 Thread Xavier de Gaye

New submission from Xavier de Gaye:

Android is not a multiarch system and the unix build system can cross compile 
non-multiarch systems as well as multiarch systems.  This is a follow up of the 
decisions implemented in issue 28046 and the patch fixes also an oversight made 
in this issue in Makefile.pre.in.

Also tested with the patch in issue 28833 that implements cross compilation of 
third-party extension modules.
Please run autoconf after installing the patch.

--
assignee: xdegaye
components: Cross-Build
files: android_multiarch.patch
keywords: patch
messages: 282140
nosy: Alex.Willmer, Chi Hsuan Yen, doko, haypo, ned.deily, xdegaye, zach.ware
priority: normal
severity: normal
stage: patch review
status: open
title: do not define sys.implementation._multiarch on Android
type: behavior
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45717/android_multiarch.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



<    1   2