summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@intel.com>2011-11-04 20:25:03 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-30 16:38:14 +0000
commitccf6077d4ea4fcec3834a9566a267c0058ce31bd (patch)
tree6cebc60964384f00d50db1dfdb5a80ca624aad58 /meta
parent38978dc0b8fdd337eb44b68ae2c673bfbe5ddd20 (diff)
downloadpoky-ccf6077d4ea4fcec3834a9566a267c0058ce31bd.tar.gz
python: skip setup.py 'import check' when cross-compiling
build_extension() in setup.py, as part of the build process, does an 'import check' on the built extension. The import check in turn dlopen()'s the shared library associated with the extension, which isn't something that makes sense if that library was cross-compiled for a different architecture. This was noticed with an x86_64 target that was compiled with avx support, because it caused 'illegal instruction' exceptions: | /bin/sh: line 1: 14575 Illegal instruction ... -E ./setup.py -q build For other target architectures, it doesn't necessarily cause illegal instruction exceptions, but still fails. For example, on arm, the failure pathway causes this warning: *** WARNING: renaming "cmath" since importing it failed: .../cmath.so: wrong ELF class: ELFCLASS32 This patch to setup.py and the associated recipe changes allow the whole 'import check' logic to be skipped when cross-compiling. (From OE-Core rev: 25fae81538a92e15eab3fc169ebce44505f67839) (From OE-Core rev: d83e4ac25cca788d2b102c2072ccb367c0cab284) Signed-off-by: Tom Zanussi <tom.zanussi@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/python/python/setup_py_skip_cross_import_check.patch27
-rw-r--r--meta/recipes-devtools/python/python_2.6.6.bb5
2 files changed, 32 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python/setup_py_skip_cross_import_check.patch b/meta/recipes-devtools/python/python/setup_py_skip_cross_import_check.patch
new file mode 100644
index 0000000000..6ccdb948b9
--- /dev/null
+++ b/meta/recipes-devtools/python/python/setup_py_skip_cross_import_check.patch
@@ -0,0 +1,27 @@
1This patch skips over the 'import check' setup.py does when building
2extensions. This generally won't work when cross-compiling.
3
4Upstream-Status: Inappropriate [embedded-specific]
5
6Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
7
8Index: Python-2.7.2/setup.py
9===================================================================
10--- Python-2.7.2.orig/setup.py 2011-11-04 16:46:34.553796410 -0500
11+++ Python-2.7.2/setup.py 2011-11-04 16:59:49.692802313 -0500
12@@ -287,6 +287,15 @@
13 (ext.name, sys.exc_info()[1]))
14 self.failed.append(ext.name)
15 return
16+
17+ # If we're cross-compiling, we want to skip the import check
18+ # i.e. we shouldn't be dynamically loading target shared libs
19+ if os.environ.get('CROSS_COMPILE') is not None:
20+ self.announce(
21+ 'WARNING: skipping import check for cross-compiled "%s"' %
22+ ext.name)
23+ return
24+
25 # Workaround for Mac OS X: The Carbon-based modules cannot be
26 # reliably imported into a command-line Python
27 if 'Carbon' in ext.extra_link_args:
diff --git a/meta/recipes-devtools/python/python_2.6.6.bb b/meta/recipes-devtools/python/python_2.6.6.bb
index 77c0ff47b3..b3f79a377d 100644
--- a/meta/recipes-devtools/python/python_2.6.6.bb
+++ b/meta/recipes-devtools/python/python_2.6.6.bb
@@ -22,6 +22,7 @@ SRC_URI = "\
22 file://security_issue_2254_fix.patch \ 22 file://security_issue_2254_fix.patch \
23 file://cgi_py.patch \ 23 file://cgi_py.patch \
24 file://remove_sqlite_rpath.patch \ 24 file://remove_sqlite_rpath.patch \
25 file://setup_py_skip_cross_import_check.patch \
25" 26"
26 27
27SRC_URI[md5sum] = "cf4e6881bb84a7ce6089e4a307f71f14" 28SRC_URI[md5sum] = "cf4e6881bb84a7ce6089e4a307f71f14"
@@ -62,6 +63,8 @@ do_compile() {
62 # then call do_install twice we get Makefile.orig == Makefile.sysroot 63 # then call do_install twice we get Makefile.orig == Makefile.sysroot
63 install -m 0644 Makefile Makefile.sysroot 64 install -m 0644 Makefile Makefile.sysroot
64 65
66 export CROSS_COMPILE="${TARGET_PREFIX}"
67
65 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/pgen \ 68 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/pgen \
66 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python \ 69 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python \
67 STAGING_LIBDIR=${STAGING_LIBDIR} \ 70 STAGING_LIBDIR=${STAGING_LIBDIR} \
@@ -83,6 +86,8 @@ do_install() {
83 # make install needs the original Makefile, or otherwise the inclues would 86 # make install needs the original Makefile, or otherwise the inclues would
84 # go to ${D}${STAGING...}/... 87 # go to ${D}${STAGING...}/...
85 install -m 0644 Makefile.orig Makefile 88 install -m 0644 Makefile.orig Makefile
89
90 export CROSS_COMPILE="${TARGET_PREFIX}"
86 91
87 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/pgen \ 92 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/pgen \
88 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python \ 93 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python \