python: Fix cross compiling issue
cover python: Fix cross compiling issue
From: Jackie Huang <[email protected]>
Tested on qemuarm and intel-x86-64.
--
The following changes since commit 80b3974081c4a8c604e23982a6db8fb32c616058:
sstate: Ensure siginfo and sig files are also touched (2015-11-25 08:08:51 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib jhuang0/d_python_151127-0
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=jhuang0/d_python_151127-0
Jackie Huang (2):
python: Fix cross compiling issue
python3: Fix cross compiling issue
.../add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch | 31 ++++++++++++++++++++ .../python3-setup.py-no-host-headers-libs.patch | 33 ---------------------- ...-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch | 2 +- meta/recipes-devtools/python/python3_3.4.3.bb | 6 ++-- meta/recipes-devtools/python/python_2.7.9.bb | 1 + 5 files changed, 35 insertions(+), 38 deletions(-) create mode 100644 meta/recipes-devtools/python/python/add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch delete mode 100644 meta/recipes-devtools/python/python3/python3-setup.py-no-host-headers-libs.patch
Signature · 1 line
1.9.1
PATCH 1/2 python: Fix cross compiling issue
From: Jackie Huang <[email protected]>
If the target and host have the same type, the system may try to execute the instructions from the target version. This can lead to illegal instructions as well as the wrong copy of the code running.
Add CROSSPYTHONPATH for PYTHON_FOR_BUILD and export the correct path to fix it.
--- .../add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch | 31 ++++++++++++++++++++++ meta/recipes-devtools/python/python_2.7.9.bb | 1 + 2 files changed, 32 insertions(+) create mode 100644 meta/recipes-devtools/python/python/add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch
meta/recipes-devtools/python/python/add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch new file +31 -0
@@ -0,0 +1,31 @@ +configure.ac: add CROSSPYTHONPATH into PYTHONPATH for PYTHON_FOR_BUILD + +When building x86->x86 the system will try to execute .so and related items +from the default PYTHONPATH. This will fail if the target CPU contains +instructions that the host CPU does not have, add CROSSPYTHONPATH +into PYTHONPATH so we can prepend the list to find correct libs. + +Upstream-Status: Inappropriate [OE-Core integration specific] + +Signed-off-by: Mark Hatle <[email protected]> +Signed-off-by: Jackie Huang <[email protected]> +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 87a4f02..f20cc7b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -33,7 +33,7 @@ if test "$cross_compiling" = yes; then + AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) + fi + AC_MSG_RESULT($interp) +- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp ++ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(CROSSPYTHONPATH):$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp + fi + elif test "$cross_compiling" = maybe; then + AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) +-- +2.5.0 +
meta/recipes-devtools/python/python_2.7.9.bb +1 -0
@@ -26,6 +26,7 @@ SRC_URI += "\ file://parallel-makeinst-create-bindir.patch \ file://use_sysroot_ncurses_instead_of_host.patch \ file://avoid_parallel_make_races_on_pgen.patch \ + file://add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \ " S = "${WORKDIR}/Python-${PV}"
Signature · 1 line
1.9.1
PATCH 2/2 python3: Fix cross compiling issue
In reply to [email protected]From: Jackie Huang <[email protected]>
If the target and host have the same type, the system may try to execute the instructions from the target version. This can lead to illegal instructions as well as the wrong copy of the code running.
This was fixed by python3-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch but it broke _ctypes build and then the CROSSPYTHONPATH was set back to the default paths by the commit:
"c254807 python3-ctypes: Fix cross compilation for arm targets"
So correct the above patch and export the correct path for CROSSPYTHONPATH, to fix both of the issues.
And remove the python3-setup.py-no-host-headers-libs.patch, it was needed since the above inappropriate patch causes setup.py gets data from the native _sysconfigdata and introduce host paths, it's not needed any more with this fix.
--- .../python3-setup.py-no-host-headers-libs.patch | 33 ---------------------- ...-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch | 2 +- meta/recipes-devtools/python/python3_3.4.3.bb | 6 ++-- 3 files changed, 3 insertions(+), 38 deletions(-) delete mode 100644 meta/recipes-devtools/python/python3/python3-setup.py-no-host-headers-libs.patch
meta/recipes-devtools/python/python3/python3-setup.py-no-host-headers-libs.patch deleted +0 -33
@@ -1,33 +0,0 @@ -From 43238e1ac13e32984d015c92a5841f3de1fe1d15 Mon Sep 17 00:00:00 2001 -From: Jackie Huang <[email protected]> -Date: Tue, 18 Nov 2014 00:07:07 -0500 -Subject: [PATCH] setup.py: no host headers libs - -When we are cross-compiling, setup.py should never look in /usr -or /usr/local to find headers or libraries. - -Upstream-Status: Inappropriate [Cross compile specific] - -Signed-off-by: Jackie Huang <[email protected]> ---- - setup.py | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/setup.py b/setup.py -index f020b28..e8339cd 100644 ---- a/setup.py -+++ b/setup.py -@@ -444,10 +444,7 @@ class PyBuildExt(build_ext): - if not cross_compiling: - add_dir_to_list(self.compiler.library_dirs, os.path.join('/usr/local', sys.lib)) - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') -- # only change this for cross builds for 3.3, issues on Mageia -- if cross_compiling: - self.add_gcc_paths() -- if not cross_compiling: - self.add_multiarch_paths() - - # Add paths specified in the environment variables LDFLAGS and --- -2.0.0 -
meta/recipes-devtools/python/python3/python3-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch +1 -1
@@ -19,7 +19,7 @@ index 989baf9..2890c96 100644 fi AC_MSG_RESULT($interp) - PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp -+ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(CROSSPYTHONPATH) '$interp ++ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(CROSSPYTHONPATH):$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp fi elif test "$cross_compiling" = maybe; then AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
meta/recipes-devtools/python/python3_3.4.3.bb +2 -4
@@ -33,7 +33,6 @@ SRC_URI += "\ file://unixccompiler.patch \ file://avoid-ncursesw-include-path.patch \ file://python3-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \ - file://python3-setup.py-no-host-headers-libs.patch \ file://sysconfig.py-add-_PYTHON_PROJECT_SRC.patch \ file://setup.py-check-cross_compiling-when-get-FLAGS.patch \ file://setup.py-find-libraries-in-staging-dirs.patch \
@@ -59,15 +58,14 @@ CACHED_CONFIGUREVARS = "ac_cv_have_chflags=no \ TARGET_CC_ARCH += "-DNDEBUG -fno-inline" EXTRA_OEMAKE += "CROSS_COMPILE=yes" -EXTRA_OECONF += "CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ --without-ensurepip" +EXTRA_OECONF += "--without-ensurepip" export CROSS_COMPILE = "${TARGET_PREFIX}" export _PYTHON_PROJECT_BASE = "${B}" export _PYTHON_PROJECT_SRC = "${S}" export CCSHARED = "-fPIC" -# Fix ctypes cross compilation -export CROSSPYTHONPATH = "${B}/build/lib.linux-${TARGET_ARCH}-${PYTHON_MAJMIN}:${S}/Lib:${S}/Lib/plat-linux" +export CROSSPYTHONPATH = "${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/" # No ctypes option for python 3 PYTHONLSBOPTS = ""
Signature · 1 line
1.9.1