Skip to content

Commit 04a7fef

Browse files
committed
linker: Update some outdated comments
1 parent 3405e40 commit 04a7fef

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
@@ -1947,7 +1947,6 @@ fn linker_with_args<'a>(
19471947
// Upstream rust libraries are not supposed to depend on our local native
19481948
// libraries as that would violate the structure of the DAG, in that
19491949
// scenario they are required to link to them as well in a shared fashion.
1950-
// (The current implementation still doesn't prevent it though, see the FIXME below.)
19511950
//
19521951
// Note that upstream rust libraries may contain native dependencies as
19531952
// well, but they also can't depend on what we just started to add to the
@@ -1968,15 +1967,16 @@ fn linker_with_args<'a>(
19681967
// and move this option back to the top.
19691968
cmd.add_as_needed();
19701969

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

1979-
// Upstream rust libraries and their non-bundled static libraries
1979+
// Upstream rust libraries and their (possibly bundled) static native libraries.
19801980
add_upstream_rust_crates(
19811981
cmd,
19821982
sess,
@@ -1986,11 +1986,11 @@ fn linker_with_args<'a>(
19861986
tmpdir,
19871987
);
19881988

1989-
// Upstream dynamic native libraries linked with `#[link]` attributes at and `-l`
1990-
// command line options.
1991-
// If -Zlink-native-libraries=false is set, then the assumption is that an
1992-
// external build system already has the native dependencies defined, and it
1993-
// will provide them to the linker itself.
1989+
// Dynamic native libraries from upstream crates.
1990+
//
1991+
// FIXME: Merge this to `add_upstream_rust_crates` so that all native libraries are linked
1992+
// together with their respective upstream crates, and in their originally specified order.
1993+
// This may be slightly breaking due to our use of `--as-needed` and needs a crater run.
19941994
if sess.opts.unstable_opts.link_native_libraries {
19951995
add_upstream_native_libraries(cmd, sess, codegen_results);
19961996
}
@@ -2401,7 +2401,7 @@ fn add_upstream_rust_crates<'a>(
24012401
// or is an rlib already included via some other dylib crate, the symbols from
24022402
// native libs will have already been included in that dylib.
24032403
//
2404-
// If -Zlink-native-libraries=false is set, then the assumption is that an
2404+
// If `-Zlink-native-libraries=false` is set, then the assumption is that an
24052405
// external build system already has the native dependencies defined, and it
24062406
// will provide them to the linker itself.
24072407
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)