1
Fork 0

Rollup merge of #99993 - petrochenkov:linkdated, r=bjorn3

linker: Update some outdated comments

r? ``@bjorn3``
This commit is contained in:
Matthias Krüger 2022-08-24 18:20:07 +02:00 committed by GitHub
commit bc05045a01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 18 deletions

View file

@ -1958,7 +1958,6 @@ fn linker_with_args<'a>(
// Upstream rust libraries are not supposed to depend on our local native // Upstream rust libraries are not supposed to depend on our local native
// libraries as that would violate the structure of the DAG, in that // libraries as that would violate the structure of the DAG, in that
// scenario they are required to link to them as well in a shared fashion. // scenario they are required to link to them as well in a shared fashion.
// (The current implementation still doesn't prevent it though, see the FIXME below.)
// //
// Note that upstream rust libraries may contain native dependencies as // Note that upstream rust libraries may contain native dependencies as
// well, but they also can't depend on what we just started to add to the // 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>(
// and move this option back to the top. // and move this option back to the top.
cmd.add_as_needed(); cmd.add_as_needed();
// FIXME: Move this below to other native libraries // Local native libraries of all kinds.
// (or alternatively link all native libraries after their respective crates). //
// This change is somewhat breaking in practice due to local static libraries being linked // If `-Zlink-native-libraries=false` is set, then the assumption is that an
// as whole-archive (#85144), so removing whole-archive may be a pre-requisite. // external build system already has the native dependencies defined, and it
// will provide them to the linker itself.
if sess.opts.unstable_opts.link_native_libraries { if sess.opts.unstable_opts.link_native_libraries {
add_local_native_libraries(cmd, sess, codegen_results); add_local_native_libraries(cmd, sess, codegen_results);
} }
// Upstream rust libraries and their non-bundled static libraries // Upstream rust libraries and their (possibly bundled) static native libraries.
add_upstream_rust_crates( add_upstream_rust_crates(
cmd, cmd,
sess, sess,
@ -1997,11 +1997,11 @@ fn linker_with_args<'a>(
tmpdir, tmpdir,
); );
// Upstream dynamic native libraries linked with `#[link]` attributes at and `-l` // Dynamic native libraries from upstream crates.
// command line options. //
// If -Zlink-native-libraries=false is set, then the assumption is that an // FIXME: Merge this to `add_upstream_rust_crates` so that all native libraries are linked
// external build system already has the native dependencies defined, and it // together with their respective upstream crates, and in their originally specified order.
// will provide them to the linker itself. // This may be slightly breaking due to our use of `--as-needed` and needs a crater run.
if sess.opts.unstable_opts.link_native_libraries { if sess.opts.unstable_opts.link_native_libraries {
add_upstream_native_libraries(cmd, sess, codegen_results); add_upstream_native_libraries(cmd, sess, codegen_results);
} }
@ -2415,7 +2415,7 @@ fn add_upstream_rust_crates<'a>(
// or is an rlib already included via some other dylib crate, the symbols from // or is an rlib already included via some other dylib crate, the symbols from
// native libs will have already been included in that dylib. // native libs will have already been included in that dylib.
// //
// If -Zlink-native-libraries=false is set, then the assumption is that an // If `-Zlink-native-libraries=false` is set, then the assumption is that an
// external build system already has the native dependencies defined, and it // external build system already has the native dependencies defined, and it
// will provide them to the linker itself. // will provide them to the linker itself.
if sess.opts.unstable_opts.link_native_libraries { if sess.opts.unstable_opts.link_native_libraries {

View file

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