Skip to content

Commit 0cc3f50

Browse files
authored
fix: build
* chore(ci): update rust workflow for multi-arch cross compilation and caching * chore(Cargo.lock): update obj-rs git reference to latest commit * chore(ci): add windows build and improve packaging in github actions workflow * chore(ci): update rust toolchain to nightly-2023-05-20 in github actions workflow * chore(ci): refactor rust workflow for improved caching and packaging * chore(ci): add cross-compilation support for aarch64 and update packaging paths * chore(ci): add separate upload steps for build and wasm artifacts in github actions * chore(ci): update rust workflow to install additional compilers and targets * chore(ci): update rust workflow with specific macos version and improved aarch64 cross-compilation setup * chore(ci): add rustfmt component and update environment variables in rust workflow * chore(workflow): add cstdint and cinttypes includes to CXXFLAGS in rust.yml
1 parent c31b7dd commit 0cc3f50

File tree

2 files changed

+62
-12
lines changed

2 files changed

+62
-12
lines changed

.github/workflows/rust.yml

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
jobs:
1010

1111
build:
12-
1312
strategy:
1413
fail-fast: false
1514
matrix:
@@ -23,7 +22,7 @@ jobs:
2322
name: linux-aarch64
2423
suffix: ''
2524
- target: x86_64-apple-darwin
26-
os: macos-latest
25+
os: macos-13
2726
name: macos
2827
suffix: ''
2928

@@ -35,11 +34,28 @@ jobs:
3534
- uses: actions-rs/toolchain@v1.0.7
3635
with:
3736
profile: minimal
38-
toolchain: nightly-2023-05-20
37+
toolchain: nightly-2023-05-05
3938
override: true
39+
components: rustfmt
40+
41+
- name: Install system dependencies
42+
if: matrix.os == 'ubuntu-latest'
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y --no-install-recommends libclang-dev cmake g++
46+
sudo ln -sf /usr/bin/g++ /usr/bin/c++
47+
48+
- name: Install cross-compilation tools
49+
if: matrix.target == 'aarch64-unknown-linux-gnu'
50+
run: |
51+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
52+
sudo ln -sf /usr/bin/aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-c++
53+
rustup target add aarch64-unknown-linux-gnu
4054
41-
- name: Add WASM target
42-
run: rustup target add wasm32-unknown-unknown
55+
- name: Add targets
56+
run: |
57+
rustup target add wasm32-unknown-unknown
58+
rustup target add ${{ matrix.target }}
4359
4460
- uses: actions/cache@v4.2.3
4561
with:
@@ -59,22 +75,56 @@ jobs:
5975
- uses: actions-rs/cargo@v1.0.3
6076
with:
6177
command: build
62-
args: '--release'
78+
args: '--release --target ${{ matrix.target }}'
79+
env:
80+
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
81+
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
82+
AR_aarch64_unknown_linux_gnu: aarch64-linux-gnu-ar
83+
CMAKE_CXX_COMPILER_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
84+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
85+
RUSTFLAGS_aarch64_unknown_linux_gnu: -C linker=aarch64-linux-gnu-gcc
86+
CXXFLAGS: -std=c++17 -include cstdint -include cinttypes
87+
CXXFLAGS_aarch64_unknown_linux_gnu: -std=c++17 -include cstdint -include cinttypes
88+
ROCKSDB_DISABLE_JEMALLOC: 1
6389

6490
- name: Package
6591
shell: bash
6692
run: |
67-
cd target/release
68-
tar czvf ../../poscan-consensus-${{ matrix.name }}.tar.gz poscan-consensus${{ matrix.suffix }}
93+
cd target/${{ matrix.target }}/release
94+
tar czvf ../../../poscan-consensus-${{ matrix.name }}.tar.gz poscan-consensus${{ matrix.suffix }}
6995
cd -
7096
7197
- name: Package WASM Artifact
7298
if: matrix.name == 'linux-x86_64'
7399
run: |
74-
cd target/release/wbuild/poscan-runtime
75-
tar czvf ../../../../poscan_runtime-wasm32-unknown-unknown.tar.gz poscan_runtime.compact.compressed.wasm
100+
cd target/${{ matrix.target }}/release/wbuild/poscan-runtime
101+
tar czvf ../../../../../poscan_runtime-wasm32-unknown-unknown.tar.gz poscan_runtime.compact.compressed.wasm
102+
103+
- name: Upload build artifacts
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: poscan-consensus-${{ matrix.name }}
107+
path: poscan-consensus-${{ matrix.name }}.tar.gz
108+
retention-days: 1
109+
110+
- name: Upload WASM artifacts
111+
if: matrix.name == 'linux-x86_64'
112+
uses: actions/upload-artifact@v4
113+
with:
114+
name: poscan-runtime-wasm
115+
path: poscan_runtime-wasm32-unknown-unknown.tar.gz
116+
retention-days: 1
117+
118+
release:
119+
needs: build
120+
runs-on: ubuntu-latest
121+
steps:
122+
- name: Download all artifacts
123+
uses: actions/download-artifact@v4
124+
with:
125+
merge-multiple: true
76126

77-
- name: Publish
127+
- name: Publish release
78128
uses: softprops/action-gh-release@v2.2.2
79129
with:
80130
files: |

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)