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