Skip to content

Commit bc05045

Browse files
authored
Rollup merge of #99993 - petrochenkov:linkdated, r=bjorn3
linker: Update some outdated comments r? ``@bjorn3``
2 parents 4a24f08 + 04a7fef commit bc05045

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,6 @@ fn linker_with_args<'a>(
19581958
// Upstream rust libraries are not supposed to depend on our local native
19591959
// libraries as that would violate the structure of the DAG, in that
19601960
// scenario they are required to link to them as well in a shared fashion.
1961-
// (The current implementation still doesn't prevent it though, see the FIXME below.)
19621961
//
19631962
// Note that upstream rust libraries may contain native dependencies as
19641963
// well, but they also can't depend on what we just started to add to the
@@ -1979,15 +1978,16 @@ fn linker_with_args<'a>(
19791978
// and move this option back to the top.
19801979
cmd.add_as_needed();
19811980

1982-
// FIXME: Move this below to other native libraries
1983-
// (or alternatively link all native libraries after their respective crates).
1984-
// This change is somewhat breaking in practice due to local static libraries being linked
1985-
// as whole-archive (#85144), so removing whole-archive may be a pre-requisite.
1981+
// Local native libraries of all kinds.
1982+
//
1983+
// If `-Zlink-native-libraries=false` is set, then the assumption is that an
1984+
// external build system already has the native dependencies defined, and it
1985+
// will provide them to the linker itself.
19861986
if sess.opts.unstable_opts.link_native_libraries {
19871987
add_local_native_libraries(cmd, sess, codegen_results);
19881988
}
19891989

1990-
// Upstream rust libraries and their non-bundled static libraries
1990+
// Upstream rust libraries and their (possibly bundled) static native libraries.
19911991
add_upstream_rust_crates(
19921992
cmd,
19931993
sess,
@@ -1997,11 +1997,11 @@ fn linker_with_args<'a>(
19971997
tmpdir,
19981998
);
19991999

2000-
// Upstream dynamic native libraries linked with `#[link]` attributes at and `-l`
2001-
// command line options.
2002-
// If -Zlink-native-libraries=false is set, then the assumption is that an
2003-
// external build system already has the native dependencies defined, and it
2004-
// will provide them to the linker itself.
2000+
// Dynamic native libraries from upstream crates.
2001+
//
2002+
// FIXME: Merge this to `add_upstream_rust_crates` so that all native libraries are linked
2003+
// together with their respective upstream crates, and in their originally specified order.
2004+
// This may be slightly breaking due to our use of `--as-needed` and needs a crater run.
20052005
if sess.opts.unstable_opts.link_native_libraries {
20062006
add_upstream_native_libraries(cmd, sess, codegen_results);
20072007
}
@@ -2415,7 +2415,7 @@ fn add_upstream_rust_crates<'a>(
24152415
// or is an rlib already included via some other dylib crate, the symbols from
24162416
// native libs will have already been included in that dylib.
24172417
//
2418-
// If -Zlink-native-libraries=false is set, then the assumption is that an
2418+
// If `-Zlink-native-libraries=false` is set, then the assumption is that an
24192419
// external build system already has the native dependencies defined, and it
24202420
// will provide them to the linker itself.
24212421
if sess.opts.unstable_opts.link_native_libraries {

compiler/rustc_codegen_ssa/src/back/metadata.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ pub enum MetadataPosition {
187187
Last,
188188
}
189189

190-
// For rlibs we "pack" rustc metadata into a dummy object file. When rustc
191-
// creates a dylib crate type it will pass `--whole-archive` (or the
192-
// platform equivalent) to include all object files from an rlib into the
193-
// final dylib itself. This causes linkers to iterate and try to include all
194-
// files located in an archive, so if metadata is stored in an archive then
195-
// it needs to be of a form that the linker will be able to process.
190+
// For rlibs we "pack" rustc metadata into a dummy object file.
191+
//
192+
// Historically it was needed because rustc linked rlibs as whole-archive in some cases.
193+
// In that case linkers try to include all files located in an archive, so if metadata is stored
194+
// in an archive then it needs to be of a form that the linker is able to process.
195+
// Now it's not clear whether metadata still needs to be wrapped into an object file or not.
196196
//
197197
// Note, though, that we don't actually want this metadata to show up in any
198198
// final output of the compiler. Instead this is purely for rustc's own

0 commit comments

Comments
 (0)