Skip to content

Commit ef90c3c

Browse files
committed
build: statically linked packages for riscv64
1 parent 4b00f64 commit ef90c3c

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: dtolnay/rust-toolchain@master
2121
with:
2222
toolchain: stable
23-
targets: i686-unknown-linux-musl,x86_64-unknown-linux-musl,aarch64-unknown-linux-musl
23+
targets: i686-unknown-linux-musl,x86_64-unknown-linux-musl,aarch64-unknown-linux-musl,riscv64gc-unknown-linux-musl
2424
components: clippy, rustfmt
2525
- name: Build
2626
run: |
@@ -70,9 +70,9 @@ jobs:
7070
with:
7171
crate: cargo-generate-rpm
7272
version: "^0.15.0"
73-
- name: Install aarch64 Dependencies
73+
- name: Install aarch64 and riscv64 Dependencies
7474
run: |
75-
sudo apt-get install gcc-aarch64-linux-gnu
75+
sudo apt-get install gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu
7676
- name: Static Build x86_64
7777
run: |
7878
make build-static-x86_64
@@ -85,11 +85,19 @@ jobs:
8585
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_STRIP: "aarch64-linux-gnu-strip"
8686
run: |
8787
make build-static-aarch64
88+
- name: Static Build riscv64
89+
env:
90+
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_LINKER: "riscv64-linux-gnu-gcc"
91+
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_STRIP: "riscv64-linux-gnu-strip"
92+
run: |
93+
make build-static-riscv64
8894
- name: Build Packages
8995
env:
9096
USE_ASCIIDOCTOR: "1"
9197
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: "aarch64-linux-gnu-gcc"
9298
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_STRIP: "aarch64-linux-gnu-strip"
99+
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_LINKER: "riscv64-linux-gnu-gcc"
100+
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_MUSL_STRIP: "riscv64-linux-gnu-strip"
93101
run: |
94102
make packages
95103
- name: Upload Packages

INSTALL.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ The following Makefile targets are available to build packages:
9494
- `deb-i686`: build `stgit_x.y.z_i386.deb`
9595
- `deb-x86_64`: build `stgit_x.y.z_amd64.deb`
9696
- `deb-aarch64`: build `stgit_x.y.z_arm64.deb`
97+
- `deb-riscv64`: build `stgit_x.y.z_riscv64.deb`
9798
- `rpm-i686`: build `stgit-x.y.z-w.i686.rpm`
9899
- `rpm-x86_64`: build `stgit-x.y.z-w.x86_64.rpm`
99100
- `rpm-aarch64`: build `stgit-x.y.z-w.aarch64.rpm`
101+
- `rpm-riscv64`: build `stgit-x.y.z-w.riscv64.rpm`
100102

101103
The generated package files are output to `target/pkg/`.
102104

@@ -106,6 +108,7 @@ Rust Dependencies
106108
To build these packages, rust needs to be setup for some additional targets:
107109

108110
- aarch64-unknown-linux-musl
111+
- riscv64gc-unknown-linux-musl
109112
- i686-unknown-linux-musl
110113
- x86_64-unknown-linux-musl
111114

@@ -121,19 +124,22 @@ install`.
121124
Linker Setup
122125
============
123126

124-
When cross-compiling, e.g. when building aarch64 targets from an x86_64
125-
host, the cross compiler linker needs to be installed and configured.
127+
When cross-compiling, e.g. when building aarch64 or riscv64 targets from
128+
an x86_64 host, the cross compiler linker needs to be installed and configured.
126129

127-
On Arch Linux, install `aarch64-linux-gnu-gcc`.
130+
On Arch Linux, install `aarch64-linux-gnu-gcc` and `riscv64-linux-gnu-gcc`.
128131

129132
In Debian/Ubuntu environments, install the `gcc-aarch64-linux-gnu`
130-
package.
133+
and `gcc-riscv64-linux-gnu` packages.
131134

132135
To configure, add the following to your `~/.cargo/config.toml` file:
133136

134137
```toml
135138
[target.aarch64-unknown-linux-musl]
136139
linker = "aarch64-linux-gnu-gcc"
140+
141+
[target.riscv64gc-unknown-linux-musl]
142+
linker = "riscv64-linux-gnu-gcc"
137143
```
138144

139145
[musl]: https://musl.libc.org/

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ build-static-x86_64:
6666
build-static-aarch64:
6767
$(CARGO) build --profile=for-pkg --target aarch64-unknown-linux-musl --no-default-features
6868

69+
build-static-riscv64:
70+
$(CARGO) build --profile=for-pkg --target riscv64gc-unknown-linux-musl --no-default-features
71+
6972
target/pkg:
7073
mkdir -p $@
7174

@@ -78,7 +81,10 @@ deb-x86_64: completion doc target/pkg build-static-x86_64
7881
deb-aarch64: completion doc target/pkg build-static-aarch64
7982
$(CARGO_OFFLINE) deb --no-build --no-strip --output target/pkg/ --profile=for-pkg --target=aarch64-unknown-linux-musl
8083

81-
debs: deb-i686 deb-x86_64 deb-aarch64
84+
deb-riscv64: completion doc target/pkg build-static-riscv64
85+
$(CARGO_OFFLINE) deb --no-build --no-strip --output target/pkg/ --profile=for-pkg --target=riscv64gc-unknown-linux-musl
86+
87+
debs: deb-i686 deb-x86_64 deb-aarch64 deb-riscv64
8288

8389
rpm-i686: completion doc target/pkg build-static-i686
8490
$(CARGO_OFFLINE) generate-rpm --output target/pkg/ --profile=for-pkg --target=i686-unknown-linux-musl
@@ -89,14 +95,17 @@ rpm-x86_64: completion doc target/pkg build-static-x86_64
8995
rpm-aarch64: completion doc target/pkg build-static-aarch64
9096
$(CARGO_OFFLINE) generate-rpm --output target/pkg/ --profile=for-pkg --target=aarch64-unknown-linux-musl
9197

92-
rpms: rpm-i686 rpm-x86_64 rpm-aarch64
98+
rpm-riscv64: completion doc target/pkg build-static-riscv64
99+
$(CARGO_OFFLINE) generate-rpm --output target/pkg/ --profile=for-pkg --target=riscv64gc-unknown-linux-musl
100+
101+
rpms: rpm-i686 rpm-x86_64 rpm-aarch64 rpm-riscv64
93102

94103
packages: debs rpms
95104

96105
.PHONY: packages
97-
.PHONY: debs deb-i686 deb-x86_64 deb-aarch64
98-
.PHONY: rpms rpm-i686 rpm-x86_64 rpm-aarch64
99-
.PHONY: build-static-i686 build-static-x86_64 build-static-aarch64
106+
.PHONY: debs deb-i686 deb-x86_64 deb-aarch64 deb-riscv64
107+
.PHONY: rpms rpm-i686 rpm-x86_64 rpm-aarch64 rpm-riscv64
108+
.PHONY: build-static-i686 build-static-x86_64 build-static-aarch64 build-static-riscv64
100109

101110

102111
lint: lint-format lint-clippy lint-api-doc lint-t unit-test

0 commit comments

Comments
 (0)