Skip to content

Commit 288e405

Browse files
committed
---
yaml --- r: 120223 b: refs/heads/dist-snap c: e798b97 h: refs/heads/master i: 120221: 14c828f 120219: 85230ad 120215: 049f1be 120207: 58acfd5 120191: e55e42f v: v3
1 parent cafa6e1 commit 288e405

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 06ea9893d58624e348cc0b4bcc3da0bda6c28327
9+
refs/heads/dist-snap: e798b97ce9b4a071e801ff4bf0cc1b19d68f3cdc
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/doc/rust.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4006,45 +4006,45 @@ compiler must at some point make a choice between these two formats. With this
40064006
in mind, the compiler follows these rules when determining what format of
40074007
dependencies will be used:
40084008

4009-
1. If a dynamic library is being produced, then it is required for all upstream
4010-
Rust dependencies to also be dynamic. This is a limitation of the current
4011-
implementation of the linkage model. The reason behind this limitation is to
4012-
prevent multiple copies of the same upstream library from showing up, and in
4013-
the future it is planned to support a mixture of dynamic and static linking.
4014-
4015-
When producing a dynamic library, the compiler will generate an error if an
4016-
upstream dependency could not be found, and also if an upstream dependency
4017-
could only be found in an `rlib` format. Remember that `staticlib` formats
4018-
are always ignored by `rustc` for crate-linking purposes.
4019-
4020-
2. If a static library is being produced, all upstream dependencies are
4009+
1. If a static library is being produced, all upstream dependencies are
40214010
required to be available in `rlib` formats. This requirement stems from the
4022-
same reasons that a dynamic library must have all dynamic dependencies.
4011+
reason that a dynamic library cannot be converted into a static format.
40234012

40244013
Note that it is impossible to link in native dynamic dependencies to a static
40254014
library, and in this case warnings will be printed about all unlinked native
40264015
dynamic dependencies.
40274016

4028-
3. If an `rlib` file is being produced, then there are no restrictions on what
4017+
2. If an `rlib` file is being produced, then there are no restrictions on what
40294018
format the upstream dependencies are available in. It is simply required that
40304019
all upstream dependencies be available for reading metadata from.
40314020

40324021
The reason for this is that `rlib` files do not contain any of their upstream
40334022
dependencies. It wouldn't be very efficient for all `rlib` files to contain a
40344023
copy of `libstd.rlib`!
40354024

4036-
4. If an executable is being produced, then things get a little interesting. As
4037-
with the above limitations in dynamic and static libraries, it is required
4038-
for all upstream dependencies to be in the same format. The next question is
4039-
whether to prefer a dynamic or a static format. The compiler currently favors
4040-
static linking over dynamic linking, but this can be inverted with the `-C
4041-
prefer-dynamic` flag to the compiler.
4042-
4043-
What this means is that first the compiler will attempt to find all upstream
4044-
dependencies as `rlib` files, and if successful, it will create a statically
4045-
linked executable. If an upstream dependency is missing as an `rlib` file,
4046-
then the compiler will force all dependencies to be dynamic and will generate
4047-
errors if dynamic versions could not be found.
4025+
3. If an executable is being produced and the `-C prefer-dynamic` flag is not
4026+
specified, then dependencies are first attempted to be found in the `rlib`
4027+
format. If some dependencies are not available in an rlib format, then
4028+
dynamic linking is attempted (see below).
4029+
4030+
4. If a dynamic library or an executable that is being dynamically linked is
4031+
being produced, then the compiler will attempt to reconcile the available
4032+
dependencies in either the rlib or dylib format to create a final product.
4033+
4034+
A major goal of the compiler is to ensure that a library never appears more
4035+
than once in any artifact. For example, if dynamic libraries B and C were
4036+
each statically linked to library A, then a crate could not link to B and C
4037+
together because there would be two copies of A. The compiler allows mixing
4038+
the rlib and dylib formats, but this restriction must be satisfied.
4039+
4040+
The compiler currently implements no method of hinting what format a library
4041+
should be linked with. When dynamically linking, the compiler will attempt to
4042+
maximize dynamic dependencies while still allowing some dependencies to be
4043+
linked in via an rlib.
4044+
4045+
For most situations, having all libraries available as a dylib is recommended
4046+
if dynamically linking. For other situations, the compiler will emit a
4047+
warning if it is unable to determine which formats to link each library with.
40484048

40494049
In general, `--crate-type=bin` or `--crate-type=lib` should be sufficient for
40504050
all compilation needs, and the other options are just available if more

0 commit comments

Comments
 (0)