From b687be4a59d76020a8e8f26aca3b57ef10bfe9ea Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 24 Mar 2019 14:09:13 -0700 Subject: [PATCH 1/2] Document wasm_import_module for #[link]. --- src/items/external-blocks.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/items/external-blocks.md b/src/items/external-blocks.md index bdb9fc80608d8..a8b7d2dd2928e 100644 --- a/src/items/external-blocks.md +++ b/src/items/external-blocks.md @@ -110,10 +110,10 @@ 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. @@ -121,6 +121,13 @@ the following possible values: - `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 { @@ -131,6 +138,11 @@ extern { extern { // … } + +#[link(wasm_import_module = "foo")] +extern { + // … +} ``` It is valid to add the `link` attribute on an empty extern block. You can use @@ -152,6 +164,7 @@ extern { ``` [IDENTIFIER]: identifiers.html +[WebAssembly]: https://webassembly.org/ [_Abi_]: items/functions.html [_FunctionParam_]: items/functions.html [_FunctionParameters_]: items/functions.html From 6fe91bcc4ba7b966c42b90b34d20583f76598b61 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 25 Mar 2019 10:48:16 -0700 Subject: [PATCH 2/2] Apply suggestions from Centril Co-Authored-By: ehuss --- src/items/external-blocks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/items/external-blocks.md b/src/items/external-blocks.md index a8b7d2dd2928e..d265619990a4c 100644 --- a/src/items/external-blocks.md +++ b/src/items/external-blocks.md @@ -123,7 +123,7 @@ specifies the kind of library with the following possible values: The `name` key must be included if `kind` is specified. -The `wasm_import_module` key may be used to specify the [WebAssembly] module +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. @@ -164,7 +164,7 @@ extern { ``` [IDENTIFIER]: identifiers.html -[WebAssembly]: https://webassembly.org/ +[WebAssembly module]: https://webassembly.github.io/spec/core/syntax/modules.html [_Abi_]: items/functions.html [_FunctionParam_]: items/functions.html [_FunctionParameters_]: items/functions.html