@@ -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 {
0 commit comments