Browse the docs

silk.platform.wasm.start.

The program entry for the standalone LLVM-to-WebAssembly profile.

When to use#

Select this module as the runtime root for a wasm32 program with no host services. The host calls the exported main function with no arguments and gets an i32 exit status.

Details#

main in the application can return one of these types:

main returnsExit status
i32The value
()0
Effect<() ! E>0 on success, 1 on a failure (E must implement Debug)

The application runs inside its own Execution. Nested transfers complete before the exported main returns. If the application is still parked at the end, or the Execution cannot be allocated, the status is 1.

With the threading profile set to multi, the module also exports the entry that runs each thread NativeThread.spawn starts.

Gotchas#

  • The host gives no arguments and no services. The application source supplies each service requirement.

  • The complete application call must satisfy Intrinsic.NonParking. To park on an external event, the application must own that wait itself.

  • A module has no descriptors, so the report of an unhandled error or a trap goes to a buffer in the module. The host reads it through the exported silk_report (its address) and silk_report_length; the std lib's host/wasm-runner.mjs prints it, and rejects a trap with an Error that carries it. A report longer than 8 KiB is cut short.

  • A fatal trap writes its report, then executes unreachable, with no cleanup.

  • A debug build keeps its DWARF out of the module: silk build writes it as <output>.debug.wasm, which the module names in external_debug_info, and a source map as <output>.map, which it names in sourceMappingURL. Serve both beside the module.

Public declarations: 0.

This module declares no public items.

Category: Native platform.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.

View the source of this page