Skip to content

Commit 8edcac1

Browse files
authored
Merge branch 'kaspanet:master' into master
2 parents fce6230 + 3370225 commit 8edcac1

54 files changed

Lines changed: 9180 additions & 1329 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Cargo configuration for musl builds
2+
# This configures linker flags to handle mimalloc conflicts with libstdc++
3+
# Since kaspa-alloc uses mimalloc with 'override' feature (which conflicts with
4+
# libstdc++'s operator new/delete in musl static builds), we use linker flags
5+
# to allow multiple definitions. The linker will use the first definition it encounters.
6+
7+
[target.x86_64-unknown-linux-musl]
8+
rustflags = [
9+
"-C", "link-arg=-Wl,--allow-multiple-definition",
10+
]
11+
12+
# Static link CRT on Windows to avoid VCRedist dependency
13+
# (similar to how we use musl on Linux for portable binaries)
14+
[target.x86_64-pc-windows-msvc]
15+
rustflags = ["-C", "target-feature=+crt-static"]

.github/workflows/ci.yaml

Lines changed: 95 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ jobs:
181181
- name: Install stable toolchain
182182
uses: dtolnay/rust-toolchain@stable
183183
with:
184+
toolchain: 1.93.0
184185
components: rustfmt, clippy
185186

186187
- name: Set up cache
@@ -192,6 +193,25 @@ jobs:
192193
- name: Run cargo clippy
193194
run: cargo clippy --workspace --tests --benches --examples -- -D warnings
194195

196+
check-no-std:
197+
name: Check no_std
198+
runs-on: ubuntu-latest
199+
steps:
200+
- name: Checkout sources
201+
uses: actions/checkout@v4
202+
203+
- name: Install stable toolchain
204+
uses: dtolnay/rust-toolchain@stable
205+
206+
- name: Add thumbv7em-none-eabi target
207+
run: rustup target add thumbv7em-none-eabi
208+
209+
- name: Set up cache
210+
uses: Swatinem/rust-cache@v2
211+
212+
- name: Run no_std cargo check for crypto/addresses
213+
run: cargo check -p kaspa-addresses --no-default-features --target thumbv7em-none-eabi
214+
195215

196216
check-wasm32:
197217
name: Check WASM32
@@ -247,6 +267,74 @@ jobs:
247267

248268
- name: Run cargo check of kaspa-wasm for wasm32 target
249269
run: cargo clippy -p kaspa-wasm --target wasm32-unknown-unknown
270+
271+
test-wasm32:
272+
name: Test WASM32
273+
runs-on: ubuntu-latest
274+
steps:
275+
- name: Checkout sources
276+
uses: actions/checkout@v4
277+
278+
- name: Install Protoc
279+
uses: arduino/setup-protoc@v3
280+
with:
281+
repo-token: ${{ secrets.GITHUB_TOKEN }}
282+
283+
- name: Install llvm
284+
id: install_llvm
285+
continue-on-error: true
286+
run: |
287+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
288+
sudo apt-get install -y clang-15 lldb-15 lld-15 clangd-15 clang-tidy-15 clang-format-15 clang-tools-15 llvm-15-dev lld-15 lldb-15 llvm-15-tools libomp-15-dev libc++-15-dev libc++abi-15-dev libclang-common-15-dev libclang-15-dev libclang-cpp15-dev libunwind-15-dev
289+
# Make Clang 15 default
290+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-15/bin/clang++ 100
291+
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-15/bin/clang 100
292+
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/lib/llvm-15/bin/clang-format 100
293+
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/lib/llvm-15/bin/clang-tidy 100
294+
sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/lib/llvm-15/bin/run-clang-tidy 100
295+
# Alias cc to clang
296+
sudo update-alternatives --install /usr/bin/cc cc /usr/lib/llvm-15/bin/clang 0
297+
sudo update-alternatives --install /usr/bin/c++ c++ /usr/lib/llvm-15/bin/clang++ 0
298+
299+
- name: Install gcc-multilib
300+
# gcc-multilib allows clang to find gnu libraries properly
301+
run: |
302+
sudo apt-get update
303+
sudo apt install -y gcc-multilib
304+
305+
- name: Install stable toolchain
306+
if: steps.install_llvm.outcome == 'success' && steps.install_llvm.conclusion == 'success'
307+
uses: dtolnay/rust-toolchain@stable
308+
309+
- name: Install wasm-pack
310+
uses: taiki-e/install-action@v2
311+
with:
312+
tool: wasm-pack
313+
314+
- name: Add wasm32 target
315+
run: rustup target add wasm32-unknown-unknown
316+
317+
- name: Set up cache
318+
uses: Swatinem/rust-cache@v2
319+
320+
- name: Install Node.js
321+
uses: actions/setup-node@v6
322+
with:
323+
node-version: 20
324+
325+
- name: Install NodeJS dependencies
326+
run: npm install --global typedoc typescript
327+
328+
# append here any new crates that contains wasm test suites (and aren't already covered)
329+
- name: Run wasm tests for consensus/core
330+
run: wasm-pack test --node consensus/core
331+
332+
- name: Run wasm tests for crypto/addresses
333+
run: wasm-pack test --node crypto/addresses
334+
335+
- name: Run wasm tests for wallet/pskt
336+
run: wasm-pack test --node wallet/pskt
337+
250338

251339
build-wasm32:
252340
name: Build WASM32 SDK
@@ -339,20 +427,15 @@ jobs:
339427
- name: Set up Rust cache
340428
uses: Swatinem/rust-cache@v2
341429

342-
- name: Cache Toolchain
343-
uses: actions/cache@v4
344-
with:
345-
path: |
346-
~/x-tools
347-
key: ${{ runner.os }}-musl-${{ hashFiles('**/musl-toolchain/preset.sh') }}
348-
restore-keys: |
349-
${{ runner.os }}-musl-
350-
351-
352430
- name: Build RK with musl toolchain
353431
if: runner.os == 'Linux'
354432
run: |
355433
# Run build script for musl toolchain
356434
source musl-toolchain/build.sh
357-
# Build for musl
358-
cargo --verbose build --bin kaspad --bin rothschild --bin kaspa-wallet --release --target x86_64-unknown-linux-musl
435+
# Build bridge with allow-multiple-definition flag to handle mimalloc conflicts with libstdc++ in musl builds
436+
# This flag is only needed for kaspa-stratum-bridge due to its dual mimalloc dependency structure
437+
export RUSTFLAGS="$RUSTFLAGS -C link-arg=-Wl,--allow-multiple-definition"
438+
439+
# Build other binaries first (without the allow-multiple-definition flag)
440+
cargo build --bin kaspad --bin rothschild --bin kaspa-wallet --bin stratum-bridge --release --target x86_64-unknown-linux-musl
441+

.github/workflows/deploy.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ jobs:
4040
target/
4141
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
4242

43-
- name: Cache Toolchain
44-
uses: actions/cache@v4
45-
with:
46-
path: |
47-
~/x-tools
48-
key: ${{ runner.os }}-musl-${{ hashFiles('**/musl-toolchain/preset.sh') }}
49-
restore-keys: |
50-
${{ runner.os }}-musl-
5143

5244
- name: Build on Linux
5345
if: runner.os == 'Linux'
@@ -59,8 +51,12 @@ jobs:
5951
# Go back to the workspace
6052
cd $GITHUB_WORKSPACE
6153
62-
# Build for musl
63-
cargo --verbose build --bin kaspad --bin rothschild --bin kaspa-wallet --bin stratum-bridge --release --target x86_64-unknown-linux-musl
54+
# Build non-bridge binaries first
55+
cargo --verbose build --bin kaspad --bin rothschild --bin kaspa-wallet --release --target x86_64-unknown-linux-musl
56+
# Build bridge with allow-multiple-definition to resolve mimalloc/libstdc++ symbol collisions.
57+
# musl-toolchain/build.sh sets RUSTFLAGS directly, so we append this flag here explicitly.
58+
export RUSTFLAGS="$RUSTFLAGS -C link-arg=-Wl,--allow-multiple-definition"
59+
cargo --verbose build --bin stratum-bridge --release --target x86_64-unknown-linux-musl
6460
mkdir bin || true
6561
cp target/x86_64-unknown-linux-musl/release/kaspad bin/
6662
cp target/x86_64-unknown-linux-musl/release/rothschild bin/
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build musl toolchain
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- 'musl-toolchain/preset.sh'
8+
branches:
9+
- master
10+
11+
jobs:
12+
build-toolchain:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Set preset
21+
run: source musl-toolchain/preset.sh && echo "CTNG_PRESET=$CTNG_PRESET" >> $GITHUB_ENV
22+
23+
- name: Calculate preset hash
24+
run: |
25+
HASH=$(sha256sum musl-toolchain/preset.sh | awk '{print $1}')
26+
echo "PRESET_HASH=$HASH" >> $GITHUB_ENV
27+
echo "Preset hash: $HASH"
28+
29+
- name: Install dependencies
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install -y autoconf automake libtool libtool-bin unzip help2man python3-dev gperf bison flex texinfo gawk libncurses5-dev zstd
33+
34+
- name: Build crosstool-ng
35+
run: |
36+
cd musl-toolchain
37+
git clone https://github.com/crosstool-ng/crosstool-ng
38+
cd crosstool-ng
39+
git checkout crosstool-ng-1.26.0
40+
./bootstrap
41+
./configure --prefix=$HOME/ctng
42+
make
43+
make install
44+
45+
- name: Build musl toolchain
46+
run: |
47+
export PATH=$HOME/ctng/bin:$PATH
48+
cd musl-toolchain
49+
ct-ng ${{ env.CTNG_PRESET }}
50+
ct-ng build > build.log 2>&1
51+
status=$?
52+
if [ $status -eq 0 ]; then
53+
echo "Build succeeded"
54+
echo "${{ env.PRESET_HASH }}" > "$HOME/x-tools/preset_hash"
55+
ls -la $HOME/x-tools
56+
else
57+
echo "Build failed:"
58+
cat .config
59+
cat build.log
60+
exit 1
61+
fi
62+
63+
- name: Package toolchain
64+
run: |
65+
tar --use-compress-program=zstd -cf x-tools.tar.zst -C "$HOME" x-tools
66+
ls -lh x-tools.tar.zst
67+
68+
- name: Upload toolchain release
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
TAG="musl-toolchain-v1"
73+
# Delete existing release if it exists
74+
gh release delete "$TAG" --yes --cleanup-tag 2>/dev/null || true
75+
# Create new release with the toolchain archive
76+
gh release create "$TAG" x-tools.tar.zst \
77+
--title "musl cross-compilation toolchain" \
78+
--notes "Pre-built x86_64-multilib-linux-musl toolchain (crosstool-ng 1.26.0). Preset hash: ${{ env.PRESET_HASH }}" \
79+
--latest=false

0 commit comments

Comments
 (0)