Skip to content

Commit 6a88d71

Browse files
committed
Fix compilation on sparc targets. (#417)
* Fix compilation on sparc targets. Adjust cfg's as needed to fix compilation errors on sparc. Fixes #408. * Rust's 32-bit sparc Linux target has a 32-bit time_t.
1 parent 7cccca8 commit 6a88d71

File tree

7 files changed

+54
-2
lines changed

7 files changed

+54
-2
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
armv5te-unknown-linux-gnueabi
7272
s390x-unknown-linux-gnu
7373
arm-linux-androideabi
74+
sparc64-unknown-linux-gnu
75+
sparcv9-sun-solaris
7476
aarch64-linux-android
7577
aarch64-apple-ios
7678
- name: Install cross-compilation tools
@@ -111,6 +113,8 @@ jobs:
111113
- run: cargo check --workspace --release -vv --target=armv5te-unknown-linux-gnueabi --features=all-apis
112114
- run: cargo check --workspace --release -vv --target=s390x-unknown-linux-gnu --features=all-apis
113115
- run: cargo check --workspace --release -vv --target=arm-linux-androideabi --features=all-apis
116+
- run: cargo check --workspace --release -vv --target=sparc64-unknown-linux-gnu --features=all-apis
117+
- run: cargo check --workspace --release -vv --target=sparcv9-sun-solaris --features=all-apis
114118
- run: cargo check --workspace --release -vv --target=aarch64-apple-ios --features=all-apis
115119
- run: cargo check --workspace --release -vv --target=aarch64-linux-android --features=all-apis
116120

@@ -187,6 +191,7 @@ jobs:
187191
- run: cargo check -Z build-std --target x86_64-unknown-openbsd --all-targets --features=all-apis
188192
- run: cargo check -Z build-std --target mips64-openwrt-linux-musl --all-targets --features=all-apis
189193
- run: cargo check -Z build-std --target x86_64-unknown-dragonfly --all-targets --features=all-apis
194+
- run: cargo check -Z build-std --target sparc-unknown-linux-gnu --all-targets --features=all-apis
190195
# Omit --all-targets on haiku because not all the tests build yet.
191196
- run: cargo check -Z build-std --target x86_64-unknown-haiku --features=all-apis
192197
# x86_64-uwp-windows-msvc isn't currently working.

src/backend/libc/process/types.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ pub enum Signal {
221221
target_os = "solaris",
222222
all(
223223
any(target_os = "android", target_os = "linux"),
224-
any(target_arch = "mips", target_arch = "mips64"),
224+
any(
225+
target_arch = "mips",
226+
target_arch = "mips64",
227+
target_arch = "sparc",
228+
target_arch = "sparc64"
229+
),
225230
)
226231
)))]
227232
Stkflt = c::SIGSTKFLT,
@@ -304,7 +309,12 @@ impl Signal {
304309
target_os = "solaris",
305310
all(
306311
any(target_os = "android", target_os = "linux"),
307-
any(target_arch = "mips", target_arch = "mips64"),
312+
any(
313+
target_arch = "mips",
314+
target_arch = "mips64",
315+
target_arch = "sparc",
316+
target_arch = "sparc64"
317+
),
308318
)
309319
)))]
310320
c::SIGSTKFLT => Some(Self::Stkflt),

src/backend/libc/termios/types.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ pub const B2000000: Speed = c::B2000000;
766766

767767
/// `B2500000`
768768
#[cfg(not(any(
769+
target_arch = "sparc",
770+
target_arch = "sparc64",
769771
target_os = "dragonfly",
770772
target_os = "freebsd",
771773
target_os = "haiku",
@@ -779,6 +781,8 @@ pub const B2500000: Speed = c::B2500000;
779781

780782
/// `B3000000`
781783
#[cfg(not(any(
784+
target_arch = "sparc",
785+
target_arch = "sparc64",
782786
target_os = "dragonfly",
783787
target_os = "freebsd",
784788
target_os = "haiku",
@@ -792,6 +796,8 @@ pub const B3000000: Speed = c::B3000000;
792796

793797
/// `B3500000`
794798
#[cfg(not(any(
799+
target_arch = "sparc",
800+
target_arch = "sparc64",
795801
target_os = "dragonfly",
796802
target_os = "freebsd",
797803
target_os = "haiku",
@@ -805,6 +811,8 @@ pub const B3500000: Speed = c::B3500000;
805811

806812
/// `B4000000`
807813
#[cfg(not(any(
814+
target_arch = "sparc",
815+
target_arch = "sparc64",
808816
target_os = "dragonfly",
809817
target_os = "freebsd",
810818
target_os = "haiku",

src/backend/linux_raw/termios/types.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,19 @@ pub const B1500000: Speed = linux_raw_sys::general::B1500000;
338338
pub const B2000000: Speed = linux_raw_sys::general::B2000000;
339339

340340
/// `B2500000`
341+
#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64",)))]
341342
pub const B2500000: Speed = linux_raw_sys::general::B2500000;
342343

343344
/// `B3000000`
345+
#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64",)))]
344346
pub const B3000000: Speed = linux_raw_sys::general::B3000000;
345347

346348
/// `B3500000`
349+
#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64",)))]
347350
pub const B3500000: Speed = linux_raw_sys::general::B3500000;
348351

349352
/// `B4000000`
353+
#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64",)))]
350354
pub const B4000000: Speed = linux_raw_sys::general::B4000000;
351355

352356
/// `CSIZE`

src/termios/constants.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pub use backend::termios::types::B1500000;
4444
)))]
4545
pub use backend::termios::types::B2000000;
4646
#[cfg(not(any(
47+
target_arch = "sparc",
48+
target_arch = "sparc64",
4749
target_os = "dragonfly",
4850
target_os = "freebsd",
4951
target_os = "haiku",
@@ -55,6 +57,8 @@ pub use backend::termios::types::B2000000;
5557
)))]
5658
pub use backend::termios::types::B2500000;
5759
#[cfg(not(any(
60+
target_arch = "sparc",
61+
target_arch = "sparc64",
5862
target_os = "dragonfly",
5963
target_os = "freebsd",
6064
target_os = "haiku",
@@ -66,6 +70,8 @@ pub use backend::termios::types::B2500000;
6670
)))]
6771
pub use backend::termios::types::B3000000;
6872
#[cfg(not(any(
73+
target_arch = "sparc",
74+
target_arch = "sparc64",
6975
target_os = "dragonfly",
7076
target_os = "freebsd",
7177
target_os = "haiku",
@@ -77,6 +83,8 @@ pub use backend::termios::types::B3000000;
7783
)))]
7884
pub use backend::termios::types::B3500000;
7985
#[cfg(not(any(
86+
target_arch = "sparc",
87+
target_arch = "sparc64",
8088
target_os = "dragonfly",
8189
target_os = "freebsd",
8290
target_os = "haiku",
@@ -788,6 +796,8 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
788796
)))]
789797
backend::termios::types::B2000000 => Some(2_000_000),
790798
#[cfg(not(any(
799+
target_arch = "sparc",
800+
target_arch = "sparc64",
791801
target_os = "dragonfly",
792802
target_os = "freebsd",
793803
target_os = "haiku",
@@ -799,6 +809,8 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
799809
)))]
800810
backend::termios::types::B2500000 => Some(2_500_000),
801811
#[cfg(not(any(
812+
target_arch = "sparc",
813+
target_arch = "sparc64",
802814
target_os = "dragonfly",
803815
target_os = "freebsd",
804816
target_os = "haiku",
@@ -810,6 +822,8 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
810822
)))]
811823
backend::termios::types::B3000000 => Some(3_000_000),
812824
#[cfg(not(any(
825+
target_arch = "sparc",
826+
target_arch = "sparc64",
813827
target_os = "dragonfly",
814828
target_os = "freebsd",
815829
target_os = "haiku",
@@ -821,6 +835,8 @@ pub fn speed_value(speed: backend::termios::types::Speed) -> Option<u32> {
821835
)))]
822836
backend::termios::types::B3500000 => Some(3_500_000),
823837
#[cfg(not(any(
838+
target_arch = "sparc",
839+
target_arch = "sparc64",
824840
target_os = "dragonfly",
825841
target_os = "freebsd",
826842
target_os = "haiku",

src/termios/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ pub use constants::B1500000;
5252
)))]
5353
pub use constants::B2000000;
5454
#[cfg(not(any(
55+
target_arch = "sparc",
56+
target_arch = "sparc64",
5557
target_os = "dragonfly",
5658
target_os = "freebsd",
5759
target_os = "haiku",
@@ -63,6 +65,8 @@ pub use constants::B2000000;
6365
)))]
6466
pub use constants::B2500000;
6567
#[cfg(not(any(
68+
target_arch = "sparc",
69+
target_arch = "sparc64",
6670
target_os = "dragonfly",
6771
target_os = "freebsd",
6872
target_os = "haiku",
@@ -74,6 +78,8 @@ pub use constants::B2500000;
7478
)))]
7579
pub use constants::B3000000;
7680
#[cfg(not(any(
81+
target_arch = "sparc",
82+
target_arch = "sparc64",
7783
target_os = "dragonfly",
7884
target_os = "freebsd",
7985
target_os = "haiku",
@@ -85,6 +91,8 @@ pub use constants::B3000000;
8591
)))]
8692
pub use constants::B3500000;
8793
#[cfg(not(any(
94+
target_arch = "sparc",
95+
target_arch = "sparc64",
8896
target_os = "dragonfly",
8997
target_os = "freebsd",
9098
target_os = "haiku",

tests/time/y2038.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#[cfg(not(all(target_env = "musl", target_pointer_width = "32")))]
1515
#[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
1616
#[cfg(not(all(target_os = "emscripten", target_pointer_width = "32")))]
17+
#[cfg(not(all(target_os = "linux", target_arch = "sparc")))]
1718
#[test]
1819
fn test_y2038() {
1920
use rustix::time::{Secs, Timespec};

0 commit comments

Comments
 (0)