From 15e0db776de7ce6c7e4097d1a66dbc190f68aa60 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 12 Jun 2022 14:20:47 +0800 Subject: [PATCH] Add support for Linux armv6l --- Changelog.md | 1 + src/auditwheel/policy.rs | 1 + src/target.rs | 21 +++++++++++++-------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Changelog.md b/Changelog.md index c535fde0e..960a9733b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Compare minimum python version requirement between `requires-python` and bindings crate in [#954](https://github.com/PyO3/maturin/pull/954) * Set `PYO3_PYTHON` env var for PyPy when abi3 is enabled in [#960](https://github.com/PyO3/maturin/pull/960) * Add sysconfigs for x64 Windows PyPy in [#962](https://github.com/PyO3/maturin/pull/962) +* Add support for Linux armv6l in [#966](https://github.com/PyO3/maturin/pull/966) ## [0.12.19] - 2022-06-05 diff --git a/src/auditwheel/policy.rs b/src/auditwheel/policy.rs index ff2212b0a..3d72b2aa1 100644 --- a/src/auditwheel/policy.rs +++ b/src/auditwheel/policy.rs @@ -97,6 +97,7 @@ impl Policy { if self.name.starts_with("musllinux") && self.lib_whitelist.remove("libc.so") { let new_soname = match target_arch { Arch::Aarch64 => "libc.musl-aarch64.so.1", + Arch::Armv6L => "libc.musl-armhf.so.1", Arch::Armv7L => "libc.musl-armv7.so.1", Arch::Powerpc64Le => "libc.musl-ppc64le.so.1", Arch::Powerpc64 => "", // musllinux doesn't support ppc64 diff --git a/src/target.rs b/src/target.rs index a41821b8c..6e3481fc1 100644 --- a/src/target.rs +++ b/src/target.rs @@ -47,6 +47,7 @@ impl fmt::Display for Os { #[serde(rename_all = "lowercase")] pub enum Arch { Aarch64, + Armv6L, Armv7L, #[serde(alias = "ppc64le")] Powerpc64Le, @@ -62,6 +63,7 @@ impl fmt::Display for Arch { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Arch::Aarch64 => write!(f, "aarch64"), + Arch::Armv6L => write!(f, "armv6l"), Arch::Armv7L => write!(f, "armv7l"), Arch::Powerpc64Le => write!(f, "ppc64le"), Arch::Powerpc64 => write!(f, "ppc64"), @@ -77,6 +79,7 @@ fn get_supported_architectures(os: &Os) -> Vec { match os { Os::Linux => vec![ Arch::Aarch64, + Arch::Armv6L, Arch::Armv7L, Arch::Powerpc64, Arch::Powerpc64Le, @@ -120,6 +123,8 @@ impl Target { /// /// Fails if the target triple isn't supported pub fn from_target_triple(target_triple: Option) -> Result { + use target_lexicon::ArmArchitecture; + let host_triple = get_host_target()?; let (platform, triple) = if let Some(ref target_triple) = target_triple { let platform: Triple = target_triple @@ -150,7 +155,10 @@ impl Target { let arch = match platform.architecture { target_lexicon::Architecture::X86_64 => Arch::X86_64, target_lexicon::Architecture::X86_32(_) => Arch::X86, - target_lexicon::Architecture::Arm(_) => Arch::Armv7L, + target_lexicon::Architecture::Arm(arm_arch) => match arm_arch { + ArmArchitecture::Arm | ArmArchitecture::Armv6 => Arch::Armv6L, + _ => Arch::Armv7L, + }, target_lexicon::Architecture::Aarch64(_) => Arch::Aarch64, target_lexicon::Architecture::Powerpc64 => Arch::Powerpc64, target_lexicon::Architecture::Powerpc64le => Arch::Powerpc64Le, @@ -309,6 +317,7 @@ impl Target { pub fn get_python_arch(&self) -> &str { match self.arch { Arch::Aarch64 => "aarch64", + Arch::Armv6L => "armv6l", Arch::Armv7L => "armv7l", Arch::Powerpc64Le => "powerpc64le", Arch::Powerpc64 => "powerpc64", @@ -340,19 +349,15 @@ impl Target { PlatformTag::manylinux2014() } Arch::X86 | Arch::X86_64 => PlatformTag::manylinux2010(), + Arch::Armv6L => PlatformTag::Linux, } } /// Returns whether the platform is 64 bit or 32 bit pub fn pointer_width(&self) -> usize { match self.arch { - Arch::Aarch64 => 64, - Arch::Armv7L => 32, - Arch::Powerpc64 => 64, - Arch::Powerpc64Le => 64, - Arch::X86 => 32, - Arch::X86_64 => 64, - Arch::S390X => 64, + Arch::Aarch64 | Arch::Powerpc64 | Arch::Powerpc64Le | Arch::X86_64 | Arch::S390X => 64, + Arch::Armv6L | Arch::Armv7L | Arch::X86 => 32, } }