Skip to content

Commit a63eb3c

Browse files
committed
Clarify --extern documentation.
Fixes rust-lang#64731, rust-lang#73531. See also rust-lang#64402#issuecomment-530852886
1 parent f455e46 commit a63eb3c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/doc/rustc/src/command-line-arguments.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,18 @@ This flag, when combined with other flags, makes them produce extra output.
273273
This flag allows you to pass the name and location for an external crate of a
274274
direct dependency. Indirect dependencies (dependencies of dependencies) are
275275
located using the [`-L` flag](#option-l-search-path). The given crate name is
276-
added to the [extern prelude], which is the same as specifying `extern crate`
277-
within the root module. The given crate name does not need to match the name
276+
added to the [extern prelude], similar to specifying `extern crate` within the
277+
root module. The given crate name does not need to match the name
278278
the library was built with.
279279

280+
Specifying `--extern` has one behavior difference from `extern crate`:
281+
`--extern` merely makes the crate a _candidate_ for being linked; it does not
282+
actually link it unless it's actively used. In rare occasions you may wish
283+
to ensure a crate is linked even if you don't actively use it from your
284+
code: for example, if it changes the global allocator or if it contains
285+
`#[no_mangle]` symbols for use by other programming languages. In such
286+
cases you'll need to use `extern crate`.
287+
280288
This flag may be specified multiple times. This flag takes an argument with
281289
either of the following formats:
282290

0 commit comments

Comments
 (0)