Skip to content

Commit 092b7ab

Browse files
authored
fix: make irpc-iroh compile in wasm, and check in CI (#66)
`irpc-iroh` does not compile to wasm atm because we imported the wrong BoxFuture alias (in n0_future there are two: one that has a Send bound always, and one that has one on non-wasm targets and does not have one on wasm targets. We might want to revisit this). Also we only checked irpc but not irpc-iroh in CI for wasm compilation. Fixed here too.
1 parent b103963 commit 092b7ab

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ jobs:
106106
wasm_build:
107107
name: Build wasm32
108108
runs-on: ubuntu-latest
109+
env:
110+
RUSTFLAGS: '--cfg getrandom_backend="wasm_js"'
109111
steps:
110112
- name: Checkout sources
111113
uses: actions/checkout@v4
@@ -116,12 +118,13 @@ jobs:
116118
- name: Install wasm-tools
117119
uses: bytecodealliance/actions/wasm-tools/setup@v1
118120
- name: wasm32 build
119-
run: cargo build --target wasm32-unknown-unknown
121+
run: cargo build --target wasm32-unknown-unknown --all
120122
# If the Wasm file contains any 'import "env"' declarations, then
121123
# some non-Wasm-compatible code made it into the final code.
122-
- name: Ensure no 'import "env"' in iroh-relay Wasm
124+
- name: Ensure no 'import "env"' in wasm
123125
run: |
124126
! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/irpc.wasm | grep 'import "env"'
127+
! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/irpc_iroh.wasm | grep 'import "env"'
125128
126129
# Checks correct runtime deps and features are requested by not including dev-dependencies.
127130
check-deps:

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ description = "A streaming rpc system based on quic"
1212
# Sadly this also needs to be updated in .github/workflows/ci.yml
1313
rust-version = "1.76"
1414

15+
[lib]
16+
crate-type = ["cdylib", "rlib"]
17+
1518
[dependencies]
1619
# we require serde even in non-rpc mode
1720
serde = { workspace = true }

irpc-iroh/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ license = "Apache-2.0/MIT"
99
repository = "https://github.com/n0-computer/irpc"
1010
description = "Iroh transport for irpc"
1111

12+
[lib]
13+
crate-type = ["cdylib", "rlib"]
14+
1215
[dependencies]
1316
anyhow = { workspace = true }
1417
iroh = { workspace = true }

irpc-iroh/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use irpc::{
1616
util::AsyncReadVarintExt,
1717
LocalSender, RequestError,
1818
};
19-
use n0_future::{boxed::BoxFuture, TryFutureExt};
19+
use n0_future::{future::Boxed as BoxFuture, TryFutureExt};
2020
use serde::de::DeserializeOwned;
2121
use tracing::{trace, trace_span, warn, Instrument};
2222

0 commit comments

Comments
 (0)