@@ -110,17 +110,24 @@ The following [attributes] control the behavior of external blocks.
110
110
### The ` link ` attribute
111
111
112
112
The * ` link ` attribute* specifies the name of a native library that the
113
- compiler should link with. It uses the [ _ MetaListNameValueStr _ ] syntax to
114
- specify its inputs. The ` name ` key is the name of the native library to link.
115
- The ` kind ` key is an optional value which specifies the kind of library with
116
- the following possible values:
113
+ compiler should link with for the items within an ` extern ` block . It uses the
114
+ [ _ MetaListNameValueStr _ ] syntax to specify its inputs. The ` name ` key is the
115
+ name of the native library to link. The ` kind ` key is an optional value which
116
+ specifies the kind of library with the following possible values:
117
117
118
118
- ` dylib ` — Indicates a dynamic library. This is the default if ` kind ` is not
119
119
specified.
120
120
- ` static ` — Indicates a static library.
121
121
- ` framework ` — Indicates a macOS framework. This is only valid for macOS
122
122
targets.
123
123
124
+ The ` name ` key must be included if ` kind ` is specified.
125
+
126
+ The ` wasm_import_module ` key may be used to specify the [ WebAssembly module]
127
+ name for the items within an ` extern ` block when importing symbols from the
128
+ host environment. The default module name is ` env ` if ` wasm_import_module ` is
129
+ not specified.
130
+
124
131
``` rust,ignore
125
132
#[link(name = "crypto")]
126
133
extern {
@@ -131,6 +138,11 @@ extern {
131
138
extern {
132
139
// …
133
140
}
141
+
142
+ #[link(wasm_import_module = "foo")]
143
+ extern {
144
+ // …
145
+ }
134
146
```
135
147
136
148
It is valid to add the ` link ` attribute on an empty extern block. You can use
@@ -152,6 +164,7 @@ extern {
152
164
```
153
165
154
166
[ IDENTIFIER ] : identifiers.html
167
+ [ WebAssembly module ] : https://webassembly.github.io/spec/core/syntax/modules.html
155
168
[ _Abi_ ] : items/functions.html
156
169
[ _FunctionParam_ ] : items/functions.html
157
170
[ _FunctionParameters_ ] : items/functions.html
0 commit comments