@@ -279,12 +279,12 @@ pub fn emit_metadata(sess: &Session, metadata: &EncodedMetadata, tmpdir: &MaybeT
279
279
out_filename
280
280
}
281
281
282
- // Create an 'rlib'
283
- //
284
- // An rlib in its current incarnation is essentially a renamed .a file. The
285
- // rlib primarily contains the object file of the crate, but it also contains
286
- // all of the object files from native libraries. This is done by unzipping
287
- // native libraries and inserting all of the contents into this archive.
282
+ /// Create an 'rlib'.
283
+ ///
284
+ /// An rlib in its current incarnation is essentially a renamed .a file. The rlib primarily contains
285
+ /// the object file of the crate, but it also contains all of the object files from native
286
+ /// libraries. This is done by unzipping native libraries and inserting all of the contents into
287
+ /// this archive.
288
288
fn link_rlib < ' a , B : ArchiveBuilder < ' a > > (
289
289
sess : & ' a Session ,
290
290
codegen_results : & CodegenResults ,
@@ -379,18 +379,17 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
379
379
ab
380
380
}
381
381
382
- // Create a static archive
383
- //
384
- // This is essentially the same thing as an rlib, but it also involves adding
385
- // all of the upstream crates' objects into the archive. This will slurp in
386
- // all of the native libraries of upstream dependencies as well.
387
- //
388
- // Additionally, there's no way for us to link dynamic libraries, so we warn
389
- // about all dynamic library dependencies that they're not linked in.
390
- //
391
- // There's no need to include metadata in a static archive, so ensure to not
392
- // link in the metadata object file (and also don't prepare the archive with a
393
- // metadata file).
382
+ /// Create a static archive.
383
+ ///
384
+ /// This is essentially the same thing as an rlib, but it also involves adding all of the upstream
385
+ /// crates' objects into the archive. This will slurp in all of the native libraries of upstream
386
+ /// dependencies as well.
387
+ ///
388
+ /// Additionally, there's no way for us to link dynamic libraries, so we warn about all dynamic
389
+ /// library dependencies that they're not linked in.
390
+ ///
391
+ /// There's no need to include metadata in a static archive, so ensure to not link in the metadata
392
+ /// object file (and also don't prepare the archive with a metadata file).
394
393
fn link_staticlib < ' a , B : ArchiveBuilder < ' a > > (
395
394
sess : & ' a Session ,
396
395
codegen_results : & CodegenResults ,
@@ -447,10 +446,10 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
447
446
}
448
447
}
449
448
450
- // Create a dynamic library or executable
451
- //
452
- // This will invoke the system linker/cc to create the resulting file. This
453
- // links to all upstream files as well.
449
+ /// Create a dynamic library or executable.
450
+ ///
451
+ /// This will invoke the system linker/cc to create the resulting file. This links to all upstream
452
+ /// files as well.
454
453
fn link_natively < ' a , B : ArchiveBuilder < ' a > > (
455
454
sess : & ' a Session ,
456
455
crate_type : CrateType ,
@@ -1677,17 +1676,15 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
1677
1676
cmd. take_cmd ( )
1678
1677
}
1679
1678
1680
- // # Native library linking
1681
- //
1682
- // User-supplied library search paths (-L on the command line). These are
1683
- // the same paths used to find Rust crates, so some of them may have been
1684
- // added already by the previous crate linking code. This only allows them
1685
- // to be found at compile time so it is still entirely up to outside
1686
- // forces to make sure that library can be found at runtime.
1687
- //
1688
- // Also note that the native libraries linked here are only the ones located
1689
- // in the current crate. Upstream crates with native library dependencies
1690
- // may have their native library pulled in above.
1679
+ /// # Native library linking
1680
+ ///
1681
+ /// User-supplied library search paths (-L on the command line). These are the same paths used to
1682
+ /// find Rust crates, so some of them may have been added already by the previous crate linking
1683
+ /// code. This only allows them to be found at compile time so it is still entirely up to outside
1684
+ /// forces to make sure that library can be found at runtime.
1685
+ ///
1686
+ /// Also note that the native libraries linked here are only the ones located in the current crate.
1687
+ /// Upstream crates with native library dependencies may have their native library pulled in above.
1691
1688
fn add_local_native_libraries (
1692
1689
cmd : & mut dyn Linker ,
1693
1690
sess : & Session ,
@@ -1727,11 +1724,10 @@ fn add_local_native_libraries(
1727
1724
}
1728
1725
}
1729
1726
1730
- // # Rust Crate linking
1731
- //
1732
- // Rust crates are not considered at all when creating an rlib output. All
1733
- // dependencies will be linked when producing the final output (instead of
1734
- // the intermediate rlib version)
1727
+ /// # Rust Crate linking
1728
+ ///
1729
+ /// Rust crates are not considered at all when creating an rlib output. All dependencies will be
1730
+ /// linked when producing the final output (instead of the intermediate rlib version).
1735
1731
fn add_upstream_rust_crates < ' a , B : ArchiveBuilder < ' a > > (
1736
1732
cmd : & mut dyn Linker ,
1737
1733
sess : & ' a Session ,
@@ -1996,24 +1992,21 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
1996
1992
}
1997
1993
}
1998
1994
1999
- // Link in all of our upstream crates' native dependencies. Remember that
2000
- // all of these upstream native dependencies are all non-static
2001
- // dependencies. We've got two cases then:
2002
- //
2003
- // 1. The upstream crate is an rlib. In this case we *must* link in the
2004
- // native dependency because the rlib is just an archive.
2005
- //
2006
- // 2. The upstream crate is a dylib. In order to use the dylib, we have to
2007
- // have the dependency present on the system somewhere. Thus, we don't
2008
- // gain a whole lot from not linking in the dynamic dependency to this
2009
- // crate as well.
2010
- //
2011
- // The use case for this is a little subtle. In theory the native
2012
- // dependencies of a crate are purely an implementation detail of the crate
2013
- // itself, but the problem arises with generic and inlined functions. If a
2014
- // generic function calls a native function, then the generic function must
2015
- // be instantiated in the target crate, meaning that the native symbol must
2016
- // also be resolved in the target crate.
1995
+ /// Link in all of our upstream crates' native dependencies. Remember that all of these upstream
1996
+ /// native dependencies are all non-static dependencies. We've got two cases then:
1997
+ ///
1998
+ /// 1. The upstream crate is an rlib. In this case we *must* link in the native dependency because
1999
+ /// the rlib is just an archive.
2000
+ ///
2001
+ /// 2. The upstream crate is a dylib. In order to use the dylib, we have to have the dependency
2002
+ /// present on the system somewhere. Thus, we don't gain a whole lot from not linking in the
2003
+ /// dynamic dependency to this crate as well.
2004
+ ///
2005
+ /// The use case for this is a little subtle. In theory the native dependencies of a crate are
2006
+ /// purely an implementation detail of the crate itself, but the problem arises with generic and
2007
+ /// inlined functions. If a generic function calls a native function, then the generic function
2008
+ /// must be instantiated in the target crate, meaning that the native symbol must also be resolved
2009
+ /// in the target crate.
2017
2010
fn add_upstream_native_libraries (
2018
2011
cmd : & mut dyn Linker ,
2019
2012
sess : & Session ,
0 commit comments