Skip to content

Commit 164e58e

Browse files
committed
Fix build for various targets
1 parent 0d8dbaf commit 164e58e

File tree

3 files changed

+75
-10
lines changed

3 files changed

+75
-10
lines changed

.github/workflows/rust.yml

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ jobs:
3232
with:
3333
python-version: "3.14"
3434
- name: Setup Rust
35-
uses: actions-rs/toolchain@v1
36-
with:
37-
profile: minimal
38-
toolchain: ${{ matrix.rust }}
39-
override: true
35+
uses: dtolnay/rust-toolchain@stable
4036
- name: Build
4137
run: cargo build --verbose
4238
- name: Run tests with num-bigint
@@ -45,3 +41,72 @@ jobs:
4541
run: cargo test --verbose --features ${{ matrix.features }},num-bigint --release
4642
- name: Run tests with malachite-bigint
4743
run: cargo test --verbose --features ${{ matrix.features }},malachite-bigint
44+
45+
# macOS-specific cross-compilation checks
46+
- name: Setup Intel macOS target
47+
if: runner.os == 'macOS'
48+
run: rustup target add x86_64-apple-darwin
49+
- name: Check Intel macOS
50+
if: runner.os == 'macOS'
51+
run: cargo check --target x86_64-apple-darwin --features ${{ matrix.features }},malachite-bigint
52+
53+
- name: Setup iOS target
54+
if: runner.os == 'macOS'
55+
run: rustup target add aarch64-apple-ios
56+
- name: Check iOS
57+
if: runner.os == 'macOS'
58+
run: cargo check --target aarch64-apple-ios --features ${{ matrix.features }},malachite-bigint
59+
60+
exotic_targets:
61+
name: Check exotic targets
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v4
65+
- uses: dtolnay/rust-toolchain@stable
66+
67+
# 32-bit Linux
68+
- name: Setup i686-unknown-linux-gnu
69+
run: rustup target add i686-unknown-linux-gnu
70+
- name: Install gcc-multilib
71+
run: sudo apt-get update && sudo apt-get install -y gcc-multilib
72+
- name: Check i686-unknown-linux-gnu
73+
run: cargo check --target i686-unknown-linux-gnu --features complex,malachite-bigint
74+
75+
# Android
76+
- name: Setup aarch64-linux-android
77+
run: rustup target add aarch64-linux-android
78+
- name: Check aarch64-linux-android
79+
run: cargo check --target aarch64-linux-android --features complex,malachite-bigint
80+
81+
# ARM64 Linux
82+
- name: Setup aarch64-unknown-linux-gnu
83+
run: rustup target add aarch64-unknown-linux-gnu
84+
- name: Install gcc-aarch64-linux-gnu
85+
run: sudo apt-get install -y gcc-aarch64-linux-gnu
86+
- name: Check aarch64-unknown-linux-gnu
87+
run: cargo check --target aarch64-unknown-linux-gnu --features complex,malachite-bigint
88+
89+
# musl
90+
- name: Setup i686-unknown-linux-musl
91+
run: rustup target add i686-unknown-linux-musl
92+
- name: Install musl-tools
93+
run: sudo apt-get install -y musl-tools
94+
- name: Check i686-unknown-linux-musl
95+
run: cargo check --target i686-unknown-linux-musl --features complex,malachite-bigint
96+
97+
# FreeBSD
98+
- name: Setup x86_64-unknown-freebsd
99+
run: rustup target add x86_64-unknown-freebsd
100+
- name: Check x86_64-unknown-freebsd
101+
run: cargo check --target x86_64-unknown-freebsd --features complex,malachite-bigint
102+
103+
clippy:
104+
name: Clippy
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v4
108+
- uses: dtolnay/rust-toolchain@stable
109+
with:
110+
components: clippy
111+
- name: Run clippy
112+
run: cargo clippy --features complex,malachite-bigint -- -Dwarnings

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "pymath"
33
author = "Jeong, YunWon <[email protected]>"
44
repository = "https://github.com/RustPython/pymath"
55
description = "A binary representation compatible Rust implementation of Python's math library."
6-
version = "0.1.2"
6+
version = "0.1.3"
77
edition = "2024"
88
license = "PSF-2.0"
99

src/err.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl TryFrom<c_int> for Error {
2525
#[inline]
2626
pub(crate) fn set_errno(value: i32) {
2727
unsafe {
28-
#[cfg(target_os = "linux")]
28+
#[cfg(any(target_os = "linux", target_os = "android"))]
2929
{
3030
*libc::__errno_location() = value;
3131
}
@@ -40,7 +40,7 @@ pub(crate) fn set_errno(value: i32) {
4040
}
4141
*_errno() = value;
4242
}
43-
#[cfg(all(unix, not(any(target_os = "linux", target_os = "macos"))))]
43+
#[cfg(all(unix, not(any(target_os = "linux", target_os = "android", target_os = "macos"))))]
4444
{
4545
// FreeBSD, NetBSD, OpenBSD, etc. use __error()
4646
*libc::__error() = value;
@@ -52,7 +52,7 @@ pub(crate) fn set_errno(value: i32) {
5252
#[inline]
5353
pub(crate) fn get_errno() -> i32 {
5454
unsafe {
55-
#[cfg(target_os = "linux")]
55+
#[cfg(any(target_os = "linux", target_os = "android"))]
5656
{
5757
*libc::__errno_location()
5858
}
@@ -67,7 +67,7 @@ pub(crate) fn get_errno() -> i32 {
6767
}
6868
*_errno()
6969
}
70-
#[cfg(all(unix, not(any(target_os = "linux", target_os = "macos"))))]
70+
#[cfg(all(unix, not(any(target_os = "linux", target_os = "android", target_os = "macos"))))]
7171
{
7272
// FreeBSD, NetBSD, OpenBSD, etc. use __error()
7373
*libc::__error()

0 commit comments

Comments
 (0)