From e0c92e4a79e9afcec60c5273ee1b85fb440a67c5 Mon Sep 17 00:00:00 2001 From: Alex Casalboni Date: Wed, 2 Apr 2025 22:30:48 +0200 Subject: [PATCH 1/5] docs: add -no-debug warning for tinygo --- component-model/src/language-support/go.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/component-model/src/language-support/go.md b/component-model/src/language-support/go.md index 85d1cbec..24d36db3 100644 --- a/component-model/src/language-support/go.md +++ b/component-model/src/language-support/go.md @@ -286,6 +286,8 @@ Under the hood, TinyGo invokes `wasm-tools` to embed the WIT file to the module tinygo build -target=wasip2 -o add.wasm --wit-package docs:adder@0.1.0.wasm --wit-world adder main.go ``` +> **WARNING:** By default, tinygo includes all debug-related information in your .wasm file. That is desirable when prototyping or testing locally to obtain useful backtraces in case of errors (for example, with `wasmtime::WasmBacktraceDetails::Enable`). To remove debug data and optimize your binary file, build with `-no-debug`. The resulting .wasm file will be considerably smaller (up to 75% reduction in size). + We now have an add component that satisfies our `adder` world, exporting the `add` function, which We can confirm using the `wasm-tools component wit` command: From a01d1208017b1bfd1e43b1e99bc91be70c37c64c Mon Sep 17 00:00:00 2001 From: Alex Casalboni Date: Wed, 2 Apr 2025 22:31:58 +0200 Subject: [PATCH 2/5] docs: add '--disable all' warning for standard library utilities that don't work without WASI interfaces such as stdio, random, and clocks --- component-model/src/language-support/javascript.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/component-model/src/language-support/javascript.md b/component-model/src/language-support/javascript.md index 5336b075..e440f91b 100644 --- a/component-model/src/language-support/javascript.md +++ b/component-model/src/language-support/javascript.md @@ -106,6 +106,8 @@ You should see output like the following: OK Successfully written add.wasm. ``` +> **WARNING:** By using `--disable all`, your component won't get access to any WASI interfaces that might be useful for debugging or logging. For example, you can't `console.log(...)` or `console.error(...)` without `stdio`; you can't use `Math.random()` without `random`; and you can't use `Date.now()` or `new Date()` without `clocks`. Please note that calls to `Math.random()` or `Data.now()` will return seemengly valid outputs, but without actual randomness or timestamp correctness. + [mdn-js-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules ## Running the Component in the `example-host` From 61bf101eec0a787054b5cc9ed85433eb7450ed56 Mon Sep 17 00:00:00 2001 From: Alex Casalboni Date: Wed, 2 Apr 2025 22:32:42 +0200 Subject: [PATCH 3/5] docs: add --release warning for Rust debugging --- component-model/src/language-support/rust.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/component-model/src/language-support/rust.md b/component-model/src/language-support/rust.md index f03e531b..cba6a1f4 100644 --- a/component-model/src/language-support/rust.md +++ b/component-model/src/language-support/rust.md @@ -90,6 +90,8 @@ Now, use `cargo component` to build the component, being sure to optimize with a cargo component build --release ``` +> **WARNING:** Building with `--release` removes all debug-related information from the resulting .wasm file. When prototyping or testing locally, you might want to avoid `--release` to obtain useful backtraces in case of errors (for example, with `wasmtime::WasmBacktraceDetails::Enable`). Note: the resulting .wasm file will be considerably larger (likely 4MB+). + You can use `wasm-tools component wit` to output the WIT package of the component: ``` From bf23676429388dc781cf8799aa81049902ea7717 Mon Sep 17 00:00:00 2001 From: Alex Casalboni Date: Thu, 3 Apr 2025 10:18:11 +0200 Subject: [PATCH 4/5] chore: typo --- component-model/src/language-support/javascript.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component-model/src/language-support/javascript.md b/component-model/src/language-support/javascript.md index e440f91b..64c5afd4 100644 --- a/component-model/src/language-support/javascript.md +++ b/component-model/src/language-support/javascript.md @@ -106,7 +106,7 @@ You should see output like the following: OK Successfully written add.wasm. ``` -> **WARNING:** By using `--disable all`, your component won't get access to any WASI interfaces that might be useful for debugging or logging. For example, you can't `console.log(...)` or `console.error(...)` without `stdio`; you can't use `Math.random()` without `random`; and you can't use `Date.now()` or `new Date()` without `clocks`. Please note that calls to `Math.random()` or `Data.now()` will return seemengly valid outputs, but without actual randomness or timestamp correctness. +> **WARNING:** By using `--disable all`, your component won't get access to any WASI interfaces that might be useful for debugging or logging. For example, you can't `console.log(...)` or `console.error(...)` without `stdio`; you can't use `Math.random()` without `random`; and you can't use `Date.now()` or `new Date()` without `clocks`. Please note that calls to `Math.random()` or `Data.now()` will return seemingly valid outputs, but without actual randomness or timestamp correctness. [mdn-js-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules From 4742f3ba0bfbde4c4d57db92e0a601dae620a565 Mon Sep 17 00:00:00 2001 From: Alex Casalboni Date: Thu, 3 Apr 2025 10:19:21 +0200 Subject: [PATCH 5/5] chore: typo --- component-model/src/language-support/javascript.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component-model/src/language-support/javascript.md b/component-model/src/language-support/javascript.md index 64c5afd4..75e410c9 100644 --- a/component-model/src/language-support/javascript.md +++ b/component-model/src/language-support/javascript.md @@ -106,7 +106,7 @@ You should see output like the following: OK Successfully written add.wasm. ``` -> **WARNING:** By using `--disable all`, your component won't get access to any WASI interfaces that might be useful for debugging or logging. For example, you can't `console.log(...)` or `console.error(...)` without `stdio`; you can't use `Math.random()` without `random`; and you can't use `Date.now()` or `new Date()` without `clocks`. Please note that calls to `Math.random()` or `Data.now()` will return seemingly valid outputs, but without actual randomness or timestamp correctness. +> **WARNING:** By using `--disable all`, your component won't get access to any WASI interfaces that might be useful for debugging or logging. For example, you can't `console.log(...)` or `console.error(...)` without `stdio`; you can't use `Math.random()` without `random`; and you can't use `Date.now()` or `new Date()` without `clocks`. Please note that calls to `Math.random()` or `Date.now()` will return seemingly valid outputs, but without actual randomness or timestamp correctness. [mdn-js-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules