@@ -1958,7 +1958,6 @@ fn linker_with_args<'a>(
1958
1958
// Upstream rust libraries are not supposed to depend on our local native
1959
1959
// libraries as that would violate the structure of the DAG, in that
1960
1960
// 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.)
1962
1961
//
1963
1962
// Note that upstream rust libraries may contain native dependencies as
1964
1963
// 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>(
1979
1978
// and move this option back to the top.
1980
1979
cmd. add_as_needed ( ) ;
1981
1980
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.
1986
1986
if sess. opts . unstable_opts . link_native_libraries {
1987
1987
add_local_native_libraries ( cmd, sess, codegen_results) ;
1988
1988
}
1989
1989
1990
- // Upstream rust libraries and their non- bundled static libraries
1990
+ // Upstream rust libraries and their (possibly bundled) static native libraries.
1991
1991
add_upstream_rust_crates (
1992
1992
cmd,
1993
1993
sess,
@@ -1997,11 +1997,11 @@ fn linker_with_args<'a>(
1997
1997
tmpdir,
1998
1998
) ;
1999
1999
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 .
2005
2005
if sess. opts . unstable_opts . link_native_libraries {
2006
2006
add_upstream_native_libraries ( cmd, sess, codegen_results) ;
2007
2007
}
@@ -2415,7 +2415,7 @@ fn add_upstream_rust_crates<'a>(
2415
2415
// or is an rlib already included via some other dylib crate, the symbols from
2416
2416
// native libs will have already been included in that dylib.
2417
2417
//
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
2419
2419
// external build system already has the native dependencies defined, and it
2420
2420
// will provide them to the linker itself.
2421
2421
if sess. opts . unstable_opts . link_native_libraries {
0 commit comments