Skip to content

Commit 575ee54

Browse files
committed
add p3 TLS support to CLI
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
1 parent 1461d3d commit 575ee54

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ component-model-async = [
520520
"component-model",
521521
"wasmtime-wasi?/p3",
522522
"wasmtime-wasi-http?/p3",
523+
"wasmtime-wasi-tls?/p3",
523524
"dep:futures",
524525
]
525526
rr = ["wasmtime/rr", "component-model", "wasmtime-cli-flags/rr", "run"]

src/commands/run.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,10 @@ impl RunCommand {
10921092
ctx.ctx().table,
10931093
)
10941094
})?;
1095+
#[cfg(feature = "component-model-async")]
1096+
if self.run.common.wasi.p3.unwrap_or(crate::common::P3_DEFAULT) {
1097+
wasmtime_wasi_tls::p3::add_to_linker(linker)?;
1098+
}
10951099

10961100
let ctx = wasmtime_wasi_tls::WasiTlsCtxBuilder::new().build();
10971101
store.data_mut().wasi_tls = Some(Arc::new(ctx));
@@ -1225,8 +1229,11 @@ pub struct Host {
12251229
wasi_http_outgoing_body_buffer_chunks: Option<usize>,
12261230
#[cfg(feature = "wasi-http")]
12271231
wasi_http_outgoing_body_chunk_size: Option<usize>,
1228-
#[cfg(all(feature = "wasi-http", feature = "component-model-async"))]
1229-
p3_http: crate::common::DefaultP3Ctx,
1232+
#[cfg(all(
1233+
any(feature = "wasi-http", feature = "wasi-tls"),
1234+
feature = "component-model-async"
1235+
))]
1236+
p3_ctx: crate::common::DefaultP3Ctx,
12301237
limits: StoreLimits,
12311238
#[cfg(feature = "profiling")]
12321239
guest_profiler: Option<Arc<wasmtime::GuestProfiler>>,
@@ -1286,7 +1293,17 @@ impl wasmtime_wasi_http::p3::WasiHttpView for Host {
12861293
fn http(&mut self) -> wasmtime_wasi_http::p3::WasiHttpCtxView<'_> {
12871294
wasmtime_wasi_http::p3::WasiHttpCtxView {
12881295
table: WasiView::ctx(unwrap_singlethread_context(&mut self.wasip1_ctx)).table,
1289-
ctx: &mut self.p3_http,
1296+
ctx: &mut self.p3_ctx,
1297+
}
1298+
}
1299+
}
1300+
1301+
#[cfg(all(feature = "wasi-tls", feature = "component-model-async"))]
1302+
impl wasmtime_wasi_tls::p3::WasiTlsView for Host {
1303+
fn tls(&mut self) -> wasmtime_wasi_tls::p3::WasiTlsCtxView<'_> {
1304+
wasmtime_wasi_tls::p3::WasiTlsCtxView {
1305+
table: WasiView::ctx(unwrap_singlethread_context(&mut self.wasip1_ctx)).table,
1306+
ctx: &mut self.p3_ctx,
12901307
}
12911308
}
12921309
}

src/common.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,12 @@ impl Profile {
433433
}
434434

435435
#[derive(Default, Clone)]
436-
#[cfg(all(feature = "wasi-http", feature = "component-model-async"))]
436+
#[cfg(all(
437+
any(feature = "wasi-http", feature = "wasi-tls"),
438+
feature = "component-model-async"
439+
))]
437440
pub struct DefaultP3Ctx;
438441
#[cfg(all(feature = "wasi-http", feature = "component-model-async"))]
439442
impl wasmtime_wasi_http::p3::WasiHttpCtx for DefaultP3Ctx {}
443+
#[cfg(all(feature = "wasi-tls", feature = "component-model-async"))]
444+
impl wasmtime_wasi_tls::p3::WasiTlsCtx for DefaultP3Ctx {}

0 commit comments

Comments
 (0)