Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for armv7l. #253

Merged
merged 6 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
audit:
if: github.repository_owner == 'a-scie'
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Check out code
uses: actions/checkout@v4
Expand Down
55 changes: 39 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,65 @@ jobs:
org-check:
name: Check GitHub Organization
if: github.repository_owner == 'a-scie'
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Noop
run: "true"
ci:
name: (${{ matrix.os }}) CI
name: ${{ matrix.name }} CI
needs: org-check
runs-on: ${{ matrix.os }}
strategy:
matrix:
# N.B.: macos-13 is the oldest non-deprecated Intel Mac runner and macos-14 is the oldest
# non-deprecated ARM Mac runner.
os: [ ubuntu-22.04, linux-arm64, macos-13, macos-14, windows-2022, windows-arm64 ]
include:
- os: ubuntu-24.04
name: Linux x86-64 (glibc)
- os: ubuntu-24.04
name: Linux x86-64 (musl)
cross-target: x86_64-unknown-linux-musl
- os: ubuntu-24.04
name: Linux aarch64 (musl)
cross-target: aarch64-unknown-linux-musl
- os: ubuntu-24.04
name: Linux armv7l (musl)
cross-target: armv7-unknown-linux-musleabihf
- os: macos-13
name: macOS x86-64
- os: macos-14
name: macOS aarch64
- os: windows-2022
name: Windows x86-64
- os: windows-arm64
name: Windows aarch64
steps:
- uses: actions/checkout@v4
- name: Check Formatting
if: matrix.cross-target == ''
run: |
rustup toolchain add nightly -c rustfmt
cargo +nightly fmt --check --all
- name: Install Cross
if: matrix.cross-target != ''
run: |
cargo install cross --locked
docker run --privileged --rm tonistiigi/binfmt --install all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docker run --privileged --rm tonistiigi/binfmt --install all

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line really needed?

Copy link
Collaborator Author

@jsirois jsirois Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Without it, lint works (cross clippy), but not test or package (cross test or cross run -p package). Although the cross images contain a cross-compiler toolchain for each target, that's only 1/2 the battle for commands like cargo test and cargo run, the other 1/2 is actually running the binary that is compiled and that requires qemu / binfmt support.

- name: Lint
if: matrix.cross-target == ''
run: cargo clippy --locked --all
- name: Lint
if: matrix.cross-target != ''
run: cross clippy --locked --all --target ${{ matrix.cross-target }}
- name: Unit Tests
if: matrix.cross-target == ''
run: cargo test --all
- name: Unit Tests
if: matrix.cross-target != ''
run: cross test --all --target ${{ matrix.cross-target }}
- name: Build & Package
if: ${{ matrix.os != 'ubuntu-22.04' && matrix.os != 'linux-arm64' }}
if: matrix.cross-target == ''
run: cargo run -p package
- name: Build & Package
if: ${{ matrix.os == 'ubuntu-22.04' || matrix.os == 'linux-arm64' }}
run: |
docker run --rm \
-v $PWD:/code \
-w /code \
rust:1.83.0-alpine3.20 \
sh -c "
apk add cmake make musl-dev perl &&
addgroup -g $(id -g) build &&
adduser -u $(id -u) -G build -D -H build &&
su build -c 'cargo run -p package -- dist'
"
if: matrix.cross-target != ''
run: cross run -p package --target ${{ matrix.cross-target }}
41 changes: 25 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
org-check:
name: Check GitHub Organization
if: ${{ github.repository_owner == 'a-scie' }}
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Noop
run: "true"
determine-tag:
name: Determine the release tag to operate against.
needs: org-check
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
outputs:
release-tag: ${{ steps.determine-tag.outputs.release-tag }}
release-version: ${{ steps.determine-tag.outputs.release-version }}
Expand All @@ -40,14 +40,31 @@ jobs:
exit 1
fi
github-release:
name: (${{ matrix.os }}) Create Github Release
name: (${{ matrix.name }}) Create Github Release
needs: determine-tag
runs-on: ${{ matrix.os }}
strategy:
matrix:
# N.B.: macos-13 is the oldest non-deprecated Intel Mac runner and macos-14 is the oldest
# non-deprecated ARM Mac runner.
os: [ ubuntu-22.04, linux-arm64, macos-13, macos-14, windows-2022, windows-arm64 ]
include:
- os: ubuntu-24.04
name: Linux x86-64
cross-target: x86_64-unknown-linux-musl
- os: ubuntu-24.04
name: Linux aarch64
cross-target: aarch64-unknown-linux-musl
- os: ubuntu-24.04
name: Linux armv7l
cross-target: armv7-unknown-linux-musleabihf
- os: macos-13
name: macOS x86-64
- os: macos-14
name: macOS aarch64
- os: windows-2022
name: Windows x86-64
- os: windows-arm64
name: Windows aarch64
environment: Release
permissions:
id-token: write
Expand All @@ -60,21 +77,13 @@ jobs:
with:
ref: ${{ needs.determine-tag.outputs.release-tag }}
- name: Package ptex ${{ needs.determine-tag.outputs.release-tag }} binary
if: ${{ matrix.os != 'ubuntu-22.04' && matrix.os != 'linux-arm64' }}
if: matrix.cross-target == ''
run: cargo run -p package
- name: Package ptex ${{ needs.determine-tag.outputs.release-tag }} binary
if: ${{ matrix.os == 'ubuntu-22.04' || matrix.os == 'linux-arm64' }}
if: matrix.cross-target != ''
run: |
docker run --rm \
-v $PWD:/code \
-w /code \
rust:1.83.0-alpine3.20 \
sh -c "
apk add cmake make musl-dev perl &&
addgroup -g $(id -g) build &&
adduser -u $(id -u) -G build -D -H build &&
su build -c 'cargo run -p package -- dist'
"
cargo install cross --locked
cross run -p package --target ${{ matrix.cross-target }}
- name: Generate ptex ${{ needs.determine-tag.outputs.release-tag }} artifact attestations
uses: actions/attest-build-provenance@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 1.3.0

This release adds support for Linux ARM (armv7l and armv8l 32 bit mode).

## 1.2.0

This release adds support for Windows ARM64.
Expand Down
38 changes: 36 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = [

[package]
name = "ptex"
version = "1.2.0"
version = "1.3.0"
edition = "2021"
authors = [
"John Sirois <[email protected]>",
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ distribution is ~28M:

## Building `ptex`

The `ptex` binary is [released](https://github.com/a-scie/ptex/releases) for Linux (x86_64 &
aarch64), macOS (x86_64 & aarch64) and Windows (x86_64). If you'd like to build your own copy,
you'll need [Rust installed](https://rustup.rs/) at which point you can run `cargo run -p package`
and a binary for your current machine will be built in `dist/` along with a sha256 checksum file.
For more build options, you can run `cargo run -p package -- --help`. On some systems, builds will
require `cmake`, `make` and `perl` in order to build various `*-sys` crates. If you're missing
these, the build failures will point you in the right direction with some reading.
The `ptex` binary is [released](https://github.com/a-scie/ptex/releases) for Linux (x86_64,
aarch64 & armv7l), macOS (x86_64 & aarch64) and Windows (x86_64 & aarch64). If you'd like to build
your own copy, you'll need [Rust installed](https://rustup.rs/) at which point you can run
`cargo run -p package` and a binary for your current machine will be built in `dist/` along with a
sha256 checksum file. For more build options, you can run `cargo run -p package -- --help`. On some
systems, builds will require `cmake`, `make` and `perl` in order to build various `*-sys` crates.
If you're missing these, the build failures will point you in the right direction with some reading.
3 changes: 2 additions & 1 deletion package/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "package"
version = "0.2.0"
version = "0.3.0"
description = "Packages the ptex binary."
authors = [
"John Sirois <[email protected]>",
Expand All @@ -12,3 +12,4 @@ publish = false
clap = { version = "4.5", features = ["derive"] }
proc-exit = "2.0"
sha2 = "0.10"
which = "7.0"
23 changes: 21 additions & 2 deletions package/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ const PATHSEP: &str = ";";
#[cfg(target_family = "unix")]
const PATHSEP: &str = ":";

#[cfg(all(
target_os = "linux",
target_arch = "arm",
target_pointer_width = "32",
target_endian = "little"
))]
const ARCH: &str = "armv7l";

#[cfg(not(all(
target_os = "linux",
target_arch = "arm",
target_pointer_width = "32",
target_endian = "little"
)))]
const ARCH: &str = env::consts::ARCH;

fn execute(command: &mut Command) -> ExitResult {
let mut child = command
.spawn()
Expand Down Expand Up @@ -107,8 +123,11 @@ fn main() -> ExitResult {
// script forwards them.
let out_dir = env!("OUT_DIR");
let target = args.target.unwrap_or_else(|| env!("TARGET").to_string());

// Just in case this target is not already installed.
execute(Command::new("rustup").args(["target", "add", &target]))?;
if let Ok(rustup) = which::which("rustup") {
execute(Command::new(rustup).args(["target", "add", &target]))?;
}

let workspace_root = PathBuf::from(cargo_manifest_dir).join("..");
let output_root = PathBuf::from(out_dir).join("dist");
Expand Down Expand Up @@ -148,7 +167,7 @@ fn main() -> ExitResult {
let file_name = format!(
"{BINARY}-{os}-{arch}{exe}",
os = env::consts::OS,
arch = env::consts::ARCH,
arch = ARCH,
exe = env::consts::EXE_SUFFIX
);
let dst = dest_dir.join(&file_name);
Expand Down
3 changes: 0 additions & 3 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[toolchain]
# N.B.: Update .github and .circleci yaml to use a matching image, if available.
# Although a version match is not required (cargo downloads and installs the
# toolchain described here if not present), it does speed up CI builds.
channel = "1.83.0"
components = [
"cargo",
Expand Down