Patrick Williams | 3965356 | 2024-03-01 08:54:02 -0600 | [diff] [blame] | 1 | From a945706bd610c5400fc85a248d5e0c96ebd2e953 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Tue, 27 Feb 2024 10:38:49 -0800 |
| 4 | Subject: [PATCH] Add 32-bit RISC-V support |
| 5 | |
| 6 | Tested with qemuriscv32 and it builds fine with all tests passed on a |
| 7 | qemu machine. |
| 8 | |
| 9 | Upstream-Status: Submitted [https://github.com/PyO3/maturin/pull/1969] |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | --- |
| 12 | src/target.rs | 11 ++++++++++- |
| 13 | 1 file changed, 10 insertions(+), 1 deletion(-) |
| 14 | |
| 15 | diff --git a/src/target.rs b/src/target.rs |
| 16 | index fbb93531..33fa9273 100644 |
| 17 | --- a/src/target.rs |
| 18 | +++ b/src/target.rs |
| 19 | @@ -69,6 +69,7 @@ pub enum Arch { |
| 20 | X86_64, |
| 21 | S390X, |
| 22 | Wasm32, |
| 23 | + Riscv32, |
| 24 | Riscv64, |
| 25 | Mips64el, |
| 26 | Mips64, |
| 27 | @@ -91,6 +92,7 @@ impl fmt::Display for Arch { |
| 28 | Arch::X86_64 => write!(f, "x86_64"), |
| 29 | Arch::S390X => write!(f, "s390x"), |
| 30 | Arch::Wasm32 => write!(f, "wasm32"), |
| 31 | + Arch::Riscv32 => write!(f, "riscv32"), |
| 32 | Arch::Riscv64 => write!(f, "riscv64"), |
| 33 | Arch::Mips64el => write!(f, "mips64el"), |
| 34 | Arch::Mips64 => write!(f, "mips64"), |
| 35 | @@ -115,7 +117,7 @@ impl Arch { |
| 36 | Arch::Powerpc | Arch::Powerpc64Le | Arch::Powerpc64 => "powerpc", |
| 37 | Arch::X86 => "i386", |
| 38 | Arch::X86_64 => "amd64", |
| 39 | - Arch::Riscv64 => "riscv", |
| 40 | + Arch::Riscv32 | Arch::Riscv64 => "riscv", |
| 41 | Arch::Mips64el | Arch::Mips64 | Arch::Mipsel | Arch::Mips => "mips", |
| 42 | // sparc64 is unsupported since FreeBSD 13.0 |
| 43 | Arch::Sparc64 => "sparc64", |
| 44 | @@ -139,6 +141,7 @@ fn get_supported_architectures(os: &Os) -> Vec<Arch> { |
| 45 | Arch::S390X, |
| 46 | Arch::X86, |
| 47 | Arch::X86_64, |
| 48 | + Arch::Riscv32, |
| 49 | Arch::Riscv64, |
| 50 | Arch::Mips64el, |
| 51 | Arch::Mips64, |
| 52 | @@ -158,6 +161,7 @@ fn get_supported_architectures(os: &Os) -> Vec<Arch> { |
| 53 | Arch::Powerpc64Le, |
| 54 | Arch::X86, |
| 55 | Arch::X86_64, |
| 56 | + Arch::Riscv32, |
| 57 | Arch::Riscv64, |
| 58 | Arch::Mips64el, |
| 59 | Arch::Mipsel, |
| 60 | @@ -171,6 +175,7 @@ fn get_supported_architectures(os: &Os) -> Vec<Arch> { |
| 61 | Arch::Powerpc, |
| 62 | Arch::Powerpc64, |
| 63 | Arch::Powerpc64Le, |
| 64 | + Arch::Riscv32, |
| 65 | Arch::Riscv64, |
| 66 | Arch::Sparc64, |
| 67 | ], |
| 68 | @@ -255,6 +260,7 @@ impl Target { |
| 69 | Architecture::Powerpc64le => Arch::Powerpc64Le, |
| 70 | Architecture::S390x => Arch::S390X, |
| 71 | Architecture::Wasm32 => Arch::Wasm32, |
| 72 | + Architecture::Riscv32(_) => Arch::Riscv32, |
| 73 | Architecture::Riscv64(_) => Arch::Riscv64, |
| 74 | Architecture::Mips64(mips64_arch) => match mips64_arch { |
| 75 | Mips64Architecture::Mips64el => Arch::Mips64el, |
| 76 | @@ -343,6 +349,7 @@ impl Target { |
| 77 | Arch::X86_64 => "x86_64", |
| 78 | Arch::S390X => "s390x", |
| 79 | Arch::Wasm32 => "wasm32", |
| 80 | + Arch::Riscv32 => "riscv32", |
| 81 | Arch::Riscv64 => "riscv64", |
| 82 | // It's kinda surprising that Python doesn't include the `el` suffix |
| 83 | Arch::Mips64el | Arch::Mips64 => "mips64", |
| 84 | @@ -388,6 +395,7 @@ impl Target { |
| 85 | } |
| 86 | Arch::Armv6L |
| 87 | | Arch::Wasm32 |
| 88 | + | Arch::Riscv32 |
| 89 | | Arch::Riscv64 |
| 90 | | Arch::Mips64el |
| 91 | | Arch::Mips64 |
| 92 | @@ -418,6 +426,7 @@ impl Target { |
| 93 | | Arch::Wasm32 |
| 94 | | Arch::Mipsel |
| 95 | | Arch::Mips |
| 96 | + | Arch::Riscv32 |
| 97 | | Arch::Powerpc => 32, |
| 98 | } |
| 99 | } |
| 100 | -- |
| 101 | 2.44.0 |
| 102 | |