Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document wasm_import_module for #[link]. #554

Merged
merged 2 commits into from
Mar 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/items/external-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,24 @@ The following [attributes] control the behavior of external blocks.
### The `link` attribute

The *`link` attribute* specifies the name of a native library that the
compiler should link with. It uses the [_MetaListNameValueStr_] syntax to
specify its inputs. The `name` key is the name of the native library to link.
The `kind` key is an optional value which specifies the kind of library with
the following possible values:
compiler should link with for the items within an `extern` block. It uses the
[_MetaListNameValueStr_] syntax to specify its inputs. The `name` key is the
name of the native library to link. The `kind` key is an optional value which
specifies the kind of library with the following possible values:

- `dylib` — Indicates a dynamic library. This is the default if `kind` is not
specified.
- `static` — Indicates a static library.
- `framework` — Indicates a macOS framework. This is only valid for macOS
targets.

The `name` key must be included if `kind` is specified.

The `wasm_import_module` key may be used to specify the [WebAssembly module]
name for the items within an `extern` block when importing symbols from the
host environment. The default module name is `env` if `wasm_import_module` is
not specified.

```rust,ignore
#[link(name = "crypto")]
extern {
Expand All @@ -131,6 +138,11 @@ extern {
extern {
// …
}

#[link(wasm_import_module = "foo")]
Centril marked this conversation as resolved.
Show resolved Hide resolved
extern {
// …
}
```

It is valid to add the `link` attribute on an empty extern block. You can use
Expand All @@ -152,6 +164,7 @@ extern {
```

[IDENTIFIER]: identifiers.html
[WebAssembly module]: https://webassembly.github.io/spec/core/syntax/modules.html
[_Abi_]: items/functions.html
[_FunctionParam_]: items/functions.html
[_FunctionParameters_]: items/functions.html
Expand Down