diff options
| author | Niko Mauno <niko.mauno@vaisala.com> | 2024-09-05 10:12:38 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-09-05 21:48:47 +0100 |
| commit | 63055fc4d0e790228af80366632a63a3cd20488a (patch) | |
| tree | c81f52df3fdaeee34f7ba5cc743107e61e63b532 /meta/recipes-devtools/python | |
| parent | 3d029dff3ece464b2c7b4d385860d31c5a9d906c (diff) | |
| download | poky-63055fc4d0e790228af80366632a63a3cd20488a.tar.gz | |
python3-maturin: Fix cross compilation issue for armv7l, mips64, ppc
When bitbaking python3-rpds-py it built extension module as:
site-packages/rpds/rpds.cpython-312-armv7l-linux-gnueabihf.so
Which caused error on target:
root@qemuarm:~# python3 -c "from rpds import HashTrieMap, HashTrieSet, List"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.12/site-packages/rpds/__init__.py", line 1, in <module>
from .rpds import *
ModuleNotFoundError: No module named 'rpds.rpds'
Where as it should have been:
site-packages/rpds/rpds.cpython-312-arm-linux-gnueabihf.so
Associated upstream bug report:
https://github.com/PyO3/maturin/issues/2203
Associated upstream pull request:
https://github.com/PyO3/maturin/pull/2204
Note - mitigation has not been tested with musl:
https://github.com/PyO3/maturin/pull/2204#issuecomment-2323952320
(From OE-Core rev: 32a8a7379008cc6e367b7664c5b10b29f0bb8136)
Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python')
6 files changed, 438 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3-maturin/0001-Extract-extension-architecture-name-resolvation-code.patch b/meta/recipes-devtools/python/python3-maturin/0001-Extract-extension-architecture-name-resolvation-code.patch new file mode 100644 index 0000000000..f75d5a1ba8 --- /dev/null +++ b/meta/recipes-devtools/python/python3-maturin/0001-Extract-extension-architecture-name-resolvation-code.patch | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | From 42a97ee7100ad158d4b1ba6133ea13cc864a567f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?= | ||
| 3 | <vesa.jaaskelainen@vaisala.com> | ||
| 4 | Date: Sun, 1 Sep 2024 09:23:10 +0300 | ||
| 5 | Subject: [PATCH 1/5] Extract extension architecture name resolvation code as | ||
| 6 | helper | ||
| 7 | MIME-Version: 1.0 | ||
| 8 | Content-Type: text/plain; charset=UTF-8 | ||
| 9 | Content-Transfer-Encoding: 8bit | ||
| 10 | |||
| 11 | This commit introduces helper InterpreterConfig.get_python_ext_arch() that | ||
| 12 | can be used to determine the extension architecture name python uses in | ||
| 13 | `ext_suffix` for this architecture. | ||
| 14 | |||
| 15 | Upstream-Status: Backport [https://github.com/PyO3/maturin/commit/42a97ee7100ad158d4b1ba6133ea13cc864a567f] | ||
| 16 | |||
| 17 | Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> | ||
| 18 | --- | ||
| 19 | src/python_interpreter/config.rs | 18 ++++++------------ | ||
| 20 | src/target.rs | 16 ++++++++++++++++ | ||
| 21 | 2 files changed, 22 insertions(+), 12 deletions(-) | ||
| 22 | |||
| 23 | diff --git a/src/python_interpreter/config.rs b/src/python_interpreter/config.rs | ||
| 24 | index 912f9218..d76606f2 100644 | ||
| 25 | --- a/src/python_interpreter/config.rs | ||
| 26 | +++ b/src/python_interpreter/config.rs | ||
| 27 | @@ -47,15 +47,7 @@ impl InterpreterConfig { | ||
| 28 | // Python 2 is not supported | ||
| 29 | return None; | ||
| 30 | } | ||
| 31 | - let python_arch = if matches!(target.target_arch(), Arch::Armv6L | Arch::Armv7L) { | ||
| 32 | - "arm" | ||
| 33 | - } else if matches!(target.target_arch(), Arch::Powerpc64Le) && python_impl == PyPy { | ||
| 34 | - "ppc_64" | ||
| 35 | - } else if matches!(target.target_arch(), Arch::X86) && python_impl == PyPy { | ||
| 36 | - "x86" | ||
| 37 | - } else { | ||
| 38 | - target.get_python_arch() | ||
| 39 | - }; | ||
| 40 | + let python_ext_arch = target.get_python_ext_arch(python_impl); | ||
| 41 | // See https://github.com/pypa/auditwheel/issues/349 | ||
| 42 | let target_env = match python_impl { | ||
| 43 | CPython => { | ||
| 44 | @@ -77,7 +69,7 @@ impl InterpreterConfig { | ||
| 45 | let ldversion = format!("{}{}{}", major, minor, abiflags); | ||
| 46 | let ext_suffix = format!( | ||
| 47 | ".cpython-{}-{}-linux-{}.so", | ||
| 48 | - ldversion, python_arch, target_env | ||
| 49 | + ldversion, python_ext_arch, target_env | ||
| 50 | ); | ||
| 51 | Some(Self { | ||
| 52 | major, | ||
| 53 | @@ -90,7 +82,8 @@ impl InterpreterConfig { | ||
| 54 | } | ||
| 55 | (Os::Linux, PyPy) => { | ||
| 56 | let abi_tag = format!("pypy{}{}-{}", major, minor, PYPY_ABI_TAG); | ||
| 57 | - let ext_suffix = format!(".{}-{}-linux-{}.so", abi_tag, python_arch, target_env); | ||
| 58 | + let ext_suffix = | ||
| 59 | + format!(".{}-{}-linux-{}.so", abi_tag, python_ext_arch, target_env); | ||
| 60 | Some(Self { | ||
| 61 | major, | ||
| 62 | minor, | ||
| 63 | @@ -204,7 +197,8 @@ impl InterpreterConfig { | ||
| 64 | } | ||
| 65 | (Os::Emscripten, CPython) => { | ||
| 66 | let ldversion = format!("{}{}", major, minor); | ||
| 67 | - let ext_suffix = format!(".cpython-{}-{}-emscripten.so", ldversion, python_arch); | ||
| 68 | + let ext_suffix = | ||
| 69 | + format!(".cpython-{}-{}-emscripten.so", ldversion, python_ext_arch); | ||
| 70 | Some(Self { | ||
| 71 | major, | ||
| 72 | minor, | ||
| 73 | diff --git a/src/target.rs b/src/target.rs | ||
| 74 | index dc7df0cf..84bae559 100644 | ||
| 75 | --- a/src/target.rs | ||
| 76 | +++ b/src/target.rs | ||
| 77 | @@ -1,4 +1,5 @@ | ||
| 78 | use crate::cross_compile::is_cross_compiling; | ||
| 79 | +use crate::python_interpreter::InterpreterKind; | ||
| 80 | use crate::PlatformTag; | ||
| 81 | use anyhow::{anyhow, bail, format_err, Result}; | ||
| 82 | use platform_info::*; | ||
| 83 | @@ -368,6 +369,21 @@ impl Target { | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | + /// Returns the extension architecture name python uses in `ext_suffix` for this architecture. | ||
| 88 | + pub fn get_python_ext_arch(&self, python_impl: InterpreterKind) -> &str { | ||
| 89 | + if matches!(self.target_arch(), Arch::Armv6L | Arch::Armv7L) { | ||
| 90 | + "arm" | ||
| 91 | + } else if matches!(self.target_arch(), Arch::Powerpc64Le) | ||
| 92 | + && python_impl == InterpreterKind::PyPy | ||
| 93 | + { | ||
| 94 | + "ppc_64" | ||
| 95 | + } else if matches!(self.target_arch(), Arch::X86) && python_impl == InterpreterKind::PyPy { | ||
| 96 | + "x86" | ||
| 97 | + } else { | ||
| 98 | + self.get_python_arch() | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | /// Returns the name python uses in `sys.platform` for this os | ||
| 103 | pub fn get_python_os(&self) -> &str { | ||
| 104 | match self.os { | ||
| 105 | -- | ||
| 106 | 2.34.1 | ||
| 107 | |||
diff --git a/meta/recipes-devtools/python/python3-maturin/0002-Fix-cross-compilation-issue-with-linux-armv7l-archit.patch b/meta/recipes-devtools/python/python3-maturin/0002-Fix-cross-compilation-issue-with-linux-armv7l-archit.patch new file mode 100644 index 0000000000..4366dde111 --- /dev/null +++ b/meta/recipes-devtools/python/python3-maturin/0002-Fix-cross-compilation-issue-with-linux-armv7l-archit.patch | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | From 0c6b8cc84eff72ed21098029aaba079b899dbee2 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?= | ||
| 3 | <vesa.jaaskelainen@vaisala.com> | ||
| 4 | Date: Sun, 1 Sep 2024 09:23:40 +0300 | ||
| 5 | Subject: [PATCH 2/5] Fix cross compilation issue with linux-armv7l | ||
| 6 | architecture | ||
| 7 | MIME-Version: 1.0 | ||
| 8 | Content-Type: text/plain; charset=UTF-8 | ||
| 9 | Content-Transfer-Encoding: 8bit | ||
| 10 | |||
| 11 | When compiling under Yocto project for linux-armv7l target architecture | ||
| 12 | .so files were generated incorrectly as: | ||
| 13 | |||
| 14 | rpds.cpython-312-armv7l-linux-gnueabihf.so | ||
| 15 | |||
| 16 | Where as platform and EXT_SUFFIX are defined as: | ||
| 17 | |||
| 18 | >>> sysconfig.get_platform() | ||
| 19 | 'linux-armv7l' | ||
| 20 | >>> sysconfig.get_config_vars()['EXT_SUFFIX'] | ||
| 21 | '.cpython-312-arm-linux-gnueabihf.so' | ||
| 22 | |||
| 23 | Which should have caused the .so files as: | ||
| 24 | |||
| 25 | rpds.cpython-312-arm-linux-gnueabihf.so | ||
| 26 | |||
| 27 | Upstream-Status: Backport [https://github.com/PyO3/maturin/commit/0c6b8cc84eff72ed21098029aaba079b899dbee2] | ||
| 28 | |||
| 29 | Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> | ||
| 30 | --- | ||
| 31 | src/python_interpreter/config.rs | 8 ++++---- | ||
| 32 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
| 33 | |||
| 34 | diff --git a/src/python_interpreter/config.rs b/src/python_interpreter/config.rs | ||
| 35 | index d76606f2..5736aedc 100644 | ||
| 36 | --- a/src/python_interpreter/config.rs | ||
| 37 | +++ b/src/python_interpreter/config.rs | ||
| 38 | @@ -306,7 +306,7 @@ impl InterpreterConfig { | ||
| 39 | format!( | ||
| 40 | ".cpython-{}-{}-{}-{}.{}", | ||
| 41 | abi_tag, | ||
| 42 | - target.get_python_arch(), | ||
| 43 | + target.get_python_ext_arch(interpreter_kind), | ||
| 44 | target.get_python_os(), | ||
| 45 | target_env, | ||
| 46 | file_ext, | ||
| 47 | @@ -319,7 +319,7 @@ impl InterpreterConfig { | ||
| 48 | major, | ||
| 49 | minor, | ||
| 50 | abi_tag, | ||
| 51 | - target.get_python_arch(), | ||
| 52 | + target.get_python_ext_arch(interpreter_kind), | ||
| 53 | target.get_python_os(), | ||
| 54 | target_env, | ||
| 55 | file_ext, | ||
| 56 | @@ -330,7 +330,7 @@ impl InterpreterConfig { | ||
| 57 | format!( | ||
| 58 | ".{}-{}-{}.{}", | ||
| 59 | abi_tag.replace('_', "-"), | ||
| 60 | - target.get_python_arch(), | ||
| 61 | + target.get_python_ext_arch(interpreter_kind), | ||
| 62 | target.get_python_os(), | ||
| 63 | file_ext, | ||
| 64 | ) | ||
| 65 | @@ -341,7 +341,7 @@ impl InterpreterConfig { | ||
| 66 | format!( | ||
| 67 | ".cpython-{}-{}-{}.{}", | ||
| 68 | abi_tag, | ||
| 69 | - target.get_python_arch(), | ||
| 70 | + target.get_python_ext_arch(interpreter_kind), | ||
| 71 | target.get_python_os(), | ||
| 72 | file_ext | ||
| 73 | ) | ||
| 74 | -- | ||
| 75 | 2.34.1 | ||
| 76 | |||
diff --git a/meta/recipes-devtools/python/python3-maturin/0003-Extract-extension-ABI-name-resolvation-code-as-helpe.patch b/meta/recipes-devtools/python/python3-maturin/0003-Extract-extension-ABI-name-resolvation-code-as-helpe.patch new file mode 100644 index 0000000000..b4a7f69492 --- /dev/null +++ b/meta/recipes-devtools/python/python3-maturin/0003-Extract-extension-ABI-name-resolvation-code-as-helpe.patch | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | From fa64426f3a98a0455721c23ec86bd2240708b45e Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?= | ||
| 3 | <vesa.jaaskelainen@vaisala.com> | ||
| 4 | Date: Sun, 1 Sep 2024 15:55:07 +0300 | ||
| 5 | Subject: [PATCH 3/5] Extract extension ABI name resolvation code as helper | ||
| 6 | MIME-Version: 1.0 | ||
| 7 | Content-Type: text/plain; charset=UTF-8 | ||
| 8 | Content-Transfer-Encoding: 8bit | ||
| 9 | |||
| 10 | This commit introduces helper InterpreterConfig.get_python_target_env() | ||
| 11 | that can be used to determine the extension ABI python uses in | ||
| 12 | `ext_suffix` for this architecture. | ||
| 13 | |||
| 14 | Upstream-Status: Backport [https://github.com/PyO3/maturin/commit/fa64426f3a98a0455721c23ec86bd2240708b45e] | ||
| 15 | |||
| 16 | Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> | ||
| 17 | --- | ||
| 18 | src/python_interpreter/config.rs | 19 ++----------------- | ||
| 19 | src/target.rs | 20 ++++++++++++++++++++ | ||
| 20 | 2 files changed, 22 insertions(+), 17 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/src/python_interpreter/config.rs b/src/python_interpreter/config.rs | ||
| 23 | index 5736aedc..938e9955 100644 | ||
| 24 | --- a/src/python_interpreter/config.rs | ||
| 25 | +++ b/src/python_interpreter/config.rs | ||
| 26 | @@ -48,17 +48,7 @@ impl InterpreterConfig { | ||
| 27 | return None; | ||
| 28 | } | ||
| 29 | let python_ext_arch = target.get_python_ext_arch(python_impl); | ||
| 30 | - // See https://github.com/pypa/auditwheel/issues/349 | ||
| 31 | - let target_env = match python_impl { | ||
| 32 | - CPython => { | ||
| 33 | - if python_version >= (3, 11) { | ||
| 34 | - target.target_env().to_string() | ||
| 35 | - } else { | ||
| 36 | - target.target_env().to_string().replace("musl", "gnu") | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | - PyPy | GraalPy => "gnu".to_string(), | ||
| 40 | - }; | ||
| 41 | + let target_env = target.get_python_target_env(python_impl, python_version); | ||
| 42 | match (target.target_os(), python_impl) { | ||
| 43 | (Os::Linux, CPython) => { | ||
| 44 | let abiflags = if python_version < (3, 8) { | ||
| 45 | @@ -294,12 +284,7 @@ impl InterpreterConfig { | ||
| 46 | }; | ||
| 47 | let file_ext = if target.is_windows() { "pyd" } else { "so" }; | ||
| 48 | let ext_suffix = if target.is_linux() || target.is_macos() { | ||
| 49 | - // See https://github.com/pypa/auditwheel/issues/349 | ||
| 50 | - let target_env = if (major, minor) >= (3, 11) { | ||
| 51 | - target.target_env().to_string() | ||
| 52 | - } else { | ||
| 53 | - target.target_env().to_string().replace("musl", "gnu") | ||
| 54 | - }; | ||
| 55 | + let target_env = target.get_python_target_env(interpreter_kind, (major, minor)); | ||
| 56 | match interpreter_kind { | ||
| 57 | InterpreterKind::CPython => ext_suffix.unwrap_or_else(|| { | ||
| 58 | // Eg: .cpython-38-x86_64-linux-gnu.so | ||
| 59 | diff --git a/src/target.rs b/src/target.rs | ||
| 60 | index 84bae559..ad8ebaba 100644 | ||
| 61 | --- a/src/target.rs | ||
| 62 | +++ b/src/target.rs | ||
| 63 | @@ -1,5 +1,6 @@ | ||
| 64 | use crate::cross_compile::is_cross_compiling; | ||
| 65 | use crate::python_interpreter::InterpreterKind; | ||
| 66 | +use crate::python_interpreter::InterpreterKind::{CPython, GraalPy, PyPy}; | ||
| 67 | use crate::PlatformTag; | ||
| 68 | use anyhow::{anyhow, bail, format_err, Result}; | ||
| 69 | use platform_info::*; | ||
| 70 | @@ -384,6 +385,25 @@ impl Target { | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | + /// Returns the environment python uses in `ext_suffix` for this architecture. | ||
| 75 | + pub fn get_python_target_env( | ||
| 76 | + &self, | ||
| 77 | + python_impl: InterpreterKind, | ||
| 78 | + python_version: (usize, usize), | ||
| 79 | + ) -> String { | ||
| 80 | + match python_impl { | ||
| 81 | + CPython => { | ||
| 82 | + // For musl handling see https://github.com/pypa/auditwheel/issues/349 | ||
| 83 | + if python_version >= (3, 11) { | ||
| 84 | + self.target_env().to_string() | ||
| 85 | + } else { | ||
| 86 | + self.target_env().to_string().replace("musl", "gnu") | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + PyPy | GraalPy => "gnu".to_string(), | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | /// Returns the name python uses in `sys.platform` for this os | ||
| 94 | pub fn get_python_os(&self) -> &str { | ||
| 95 | match self.os { | ||
| 96 | -- | ||
| 97 | 2.34.1 | ||
| 98 | |||
diff --git a/meta/recipes-devtools/python/python3-maturin/0004-Fix-cross-compilation-issue-with-linux-ppc-architect.patch b/meta/recipes-devtools/python/python3-maturin/0004-Fix-cross-compilation-issue-with-linux-ppc-architect.patch new file mode 100644 index 0000000000..bda5dca8f6 --- /dev/null +++ b/meta/recipes-devtools/python/python3-maturin/0004-Fix-cross-compilation-issue-with-linux-ppc-architect.patch | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | From f2c892109a05db144e8b18bcbcf9c24fe8d977c4 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?= | ||
| 3 | <vesa.jaaskelainen@vaisala.com> | ||
| 4 | Date: Sun, 1 Sep 2024 15:55:16 +0300 | ||
| 5 | Subject: [PATCH 4/5] Fix cross compilation issue with linux-ppc architecture | ||
| 6 | MIME-Version: 1.0 | ||
| 7 | Content-Type: text/plain; charset=UTF-8 | ||
| 8 | Content-Transfer-Encoding: 8bit | ||
| 9 | |||
| 10 | When compiling under Yocto project for linux-ppc target architecture | ||
| 11 | .so files were generated incorrectly as: | ||
| 12 | |||
| 13 | rpds.cpython-312-ppc-linux-gnu.so | ||
| 14 | |||
| 15 | Where as platform and EXT_SUFFIX are defined as: | ||
| 16 | |||
| 17 | >>> sysconfig.get_platform() | ||
| 18 | 'linux-ppc' | ||
| 19 | >>> sysconfig.get_config_vars()['EXT_SUFFIX'] | ||
| 20 | '.cpython-312-powerpc-linux-gnu.so' | ||
| 21 | |||
| 22 | Which should have caused the .so files as: | ||
| 23 | |||
| 24 | rpds.cpython-312-powerpc-linux-gnu.so | ||
| 25 | |||
| 26 | Upstream-Status: Backport [https://github.com/PyO3/maturin/commit/f2c892109a05db144e8b18bcbcf9c24fe8d977c4] | ||
| 27 | |||
| 28 | Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> | ||
| 29 | --- | ||
| 30 | src/python_interpreter/config.rs | 8 ++++++++ | ||
| 31 | src/target.rs | 2 ++ | ||
| 32 | 2 files changed, 10 insertions(+) | ||
| 33 | |||
| 34 | diff --git a/src/python_interpreter/config.rs b/src/python_interpreter/config.rs | ||
| 35 | index 938e9955..8f883887 100644 | ||
| 36 | --- a/src/python_interpreter/config.rs | ||
| 37 | +++ b/src/python_interpreter/config.rs | ||
| 38 | @@ -424,6 +424,14 @@ mod test { | ||
| 39 | ".cpython-310-powerpc64le-linux-gnu.so" | ||
| 40 | ); | ||
| 41 | |||
| 42 | + let sysconfig = InterpreterConfig::lookup_one( | ||
| 43 | + &Target::from_target_triple(Some("powerpc-unknown-linux-gnu".to_string())).unwrap(), | ||
| 44 | + InterpreterKind::CPython, | ||
| 45 | + (3, 10), | ||
| 46 | + ) | ||
| 47 | + .unwrap(); | ||
| 48 | + assert_eq!(sysconfig.ext_suffix, ".cpython-310-powerpc-linux-gnu.so"); | ||
| 49 | + | ||
| 50 | let sysconfig = InterpreterConfig::lookup_one( | ||
| 51 | &Target::from_target_triple(Some("s390x-unknown-linux-gnu".to_string())).unwrap(), | ||
| 52 | InterpreterKind::CPython, | ||
| 53 | diff --git a/src/target.rs b/src/target.rs | ||
| 54 | index ad8ebaba..93afd9bb 100644 | ||
| 55 | --- a/src/target.rs | ||
| 56 | +++ b/src/target.rs | ||
| 57 | @@ -380,6 +380,8 @@ impl Target { | ||
| 58 | "ppc_64" | ||
| 59 | } else if matches!(self.target_arch(), Arch::X86) && python_impl == InterpreterKind::PyPy { | ||
| 60 | "x86" | ||
| 61 | + } else if matches!(self.target_arch(), Arch::Powerpc) { | ||
| 62 | + "powerpc" | ||
| 63 | } else { | ||
| 64 | self.get_python_arch() | ||
| 65 | } | ||
| 66 | -- | ||
| 67 | 2.34.1 | ||
| 68 | |||
diff --git a/meta/recipes-devtools/python/python3-maturin/0005-Fix-cross-compilation-issue-with-linux-mips64-archit.patch b/meta/recipes-devtools/python/python3-maturin/0005-Fix-cross-compilation-issue-with-linux-mips64-archit.patch new file mode 100644 index 0000000000..b24196d5dd --- /dev/null +++ b/meta/recipes-devtools/python/python3-maturin/0005-Fix-cross-compilation-issue-with-linux-mips64-archit.patch | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | From 5fe643579bcc63d824f6a0f0936fff451c622903 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?= | ||
| 3 | <vesa.jaaskelainen@vaisala.com> | ||
| 4 | Date: Sun, 1 Sep 2024 15:55:54 +0300 | ||
| 5 | Subject: [PATCH 5/5] Fix cross compilation issue with linux-mips64 | ||
| 6 | architecture | ||
| 7 | MIME-Version: 1.0 | ||
| 8 | Content-Type: text/plain; charset=UTF-8 | ||
| 9 | Content-Transfer-Encoding: 8bit | ||
| 10 | |||
| 11 | When compiling under Yocto project for linux-mips64 target architecture | ||
| 12 | .so files were generated incorrectly as: | ||
| 13 | |||
| 14 | rpds.cpython-312-mips64-linux-gnu.so | ||
| 15 | |||
| 16 | Where as platform and EXT_SUFFIX are defined as: | ||
| 17 | |||
| 18 | >>> sysconfig.get_platform() | ||
| 19 | 'linux-mips64' | ||
| 20 | >>> sysconfig.get_config_vars()['EXT_SUFFIX'] | ||
| 21 | '.cpython-312-mips64-linux-gnuabi64.so' | ||
| 22 | |||
| 23 | Which should have caused the .so files as: | ||
| 24 | |||
| 25 | rpds.cpython-312-mips64-linux-gnuabi64.so | ||
| 26 | |||
| 27 | Upstream-Status: Backport [https://github.com/PyO3/maturin/commit/5fe643579bcc63d824f6a0f0936fff451c622903] | ||
| 28 | |||
| 29 | Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> | ||
| 30 | --- | ||
| 31 | src/python_interpreter/config.rs | 19 +++++++++++++++++++ | ||
| 32 | src/target.rs | 4 +++- | ||
| 33 | 2 files changed, 22 insertions(+), 1 deletion(-) | ||
| 34 | |||
| 35 | diff --git a/src/python_interpreter/config.rs b/src/python_interpreter/config.rs | ||
| 36 | index 8f883887..ef656010 100644 | ||
| 37 | --- a/src/python_interpreter/config.rs | ||
| 38 | +++ b/src/python_interpreter/config.rs | ||
| 39 | @@ -432,6 +432,25 @@ mod test { | ||
| 40 | .unwrap(); | ||
| 41 | assert_eq!(sysconfig.ext_suffix, ".cpython-310-powerpc-linux-gnu.so"); | ||
| 42 | |||
| 43 | + let sysconfig = InterpreterConfig::lookup_one( | ||
| 44 | + &Target::from_target_triple(Some("mips64-unknown-linux-gnu".to_string())).unwrap(), | ||
| 45 | + InterpreterKind::CPython, | ||
| 46 | + (3, 10), | ||
| 47 | + ) | ||
| 48 | + .unwrap(); | ||
| 49 | + assert_eq!( | ||
| 50 | + sysconfig.ext_suffix, | ||
| 51 | + ".cpython-310-mips64-linux-gnuabi64.so" | ||
| 52 | + ); | ||
| 53 | + | ||
| 54 | + let sysconfig = InterpreterConfig::lookup_one( | ||
| 55 | + &Target::from_target_triple(Some("mips-unknown-linux-gnu".to_string())).unwrap(), | ||
| 56 | + InterpreterKind::CPython, | ||
| 57 | + (3, 10), | ||
| 58 | + ) | ||
| 59 | + .unwrap(); | ||
| 60 | + assert_eq!(sysconfig.ext_suffix, ".cpython-310-mips-linux-gnu.so"); | ||
| 61 | + | ||
| 62 | let sysconfig = InterpreterConfig::lookup_one( | ||
| 63 | &Target::from_target_triple(Some("s390x-unknown-linux-gnu".to_string())).unwrap(), | ||
| 64 | InterpreterKind::CPython, | ||
| 65 | diff --git a/src/target.rs b/src/target.rs | ||
| 66 | index 93afd9bb..25fc6c07 100644 | ||
| 67 | --- a/src/target.rs | ||
| 68 | +++ b/src/target.rs | ||
| 69 | @@ -396,7 +396,9 @@ impl Target { | ||
| 70 | match python_impl { | ||
| 71 | CPython => { | ||
| 72 | // For musl handling see https://github.com/pypa/auditwheel/issues/349 | ||
| 73 | - if python_version >= (3, 11) { | ||
| 74 | + if matches!(self.target_arch(), Arch::Mips64 | Arch::Mips64el) && self.is_linux() { | ||
| 75 | + "gnuabi64".to_string() | ||
| 76 | + } else if python_version >= (3, 11) { | ||
| 77 | self.target_env().to_string() | ||
| 78 | } else { | ||
| 79 | self.target_env().to_string().replace("musl", "gnu") | ||
| 80 | -- | ||
| 81 | 2.34.1 | ||
| 82 | |||
diff --git a/meta/recipes-devtools/python/python3-maturin_1.7.1.bb b/meta/recipes-devtools/python/python3-maturin_1.7.1.bb index 1a8581e594..b9279f5ab5 100644 --- a/meta/recipes-devtools/python/python3-maturin_1.7.1.bb +++ b/meta/recipes-devtools/python/python3-maturin_1.7.1.bb | |||
| @@ -6,6 +6,13 @@ LIC_FILES_CHKSUM = "file://license-apache;md5=1836efb2eb779966696f473ee8540542 \ | |||
| 6 | file://license-mit;md5=85fd3b67069cff784d98ebfc7d5c0797" | 6 | file://license-mit;md5=85fd3b67069cff784d98ebfc7d5c0797" |
| 7 | 7 | ||
| 8 | SRC_URI[sha256sum] = "147754cb3d81177ee12d9baf575d93549e76121dacd3544ad6a50ab718de2b9c" | 8 | SRC_URI[sha256sum] = "147754cb3d81177ee12d9baf575d93549e76121dacd3544ad6a50ab718de2b9c" |
| 9 | SRC_URI:append = "\ | ||
| 10 | file://0001-Extract-extension-architecture-name-resolvation-code.patch \ | ||
| 11 | file://0002-Fix-cross-compilation-issue-with-linux-armv7l-archit.patch \ | ||
| 12 | file://0003-Extract-extension-ABI-name-resolvation-code-as-helpe.patch \ | ||
| 13 | file://0004-Fix-cross-compilation-issue-with-linux-ppc-architect.patch \ | ||
| 14 | file://0005-Fix-cross-compilation-issue-with-linux-mips64-archit.patch \ | ||
| 15 | " | ||
| 9 | 16 | ||
| 10 | S = "${WORKDIR}/maturin-${PV}" | 17 | S = "${WORKDIR}/maturin-${PV}" |
| 11 | 18 | ||
