@@ -1947,7 +1947,6 @@ fn linker_with_args<'a>(
1947
1947
// Upstream rust libraries are not supposed to depend on our local native
1948
1948
// libraries as that would violate the structure of the DAG, in that
1949
1949
// 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.)
1951
1950
//
1952
1951
// Note that upstream rust libraries may contain native dependencies as
1953
1952
// 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>(
1968
1967
// and move this option back to the top.
1969
1968
cmd. add_as_needed ( ) ;
1970
1969
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.
1975
1975
if sess. opts . unstable_opts . link_native_libraries {
1976
1976
add_local_native_libraries ( cmd, sess, codegen_results) ;
1977
1977
}
1978
1978
1979
- // Upstream rust libraries and their non- bundled static libraries
1979
+ // Upstream rust libraries and their (possibly bundled) static native libraries.
1980
1980
add_upstream_rust_crates (
1981
1981
cmd,
1982
1982
sess,
@@ -1986,11 +1986,11 @@ fn linker_with_args<'a>(
1986
1986
tmpdir,
1987
1987
) ;
1988
1988
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 .
1994
1994
if sess. opts . unstable_opts . link_native_libraries {
1995
1995
add_upstream_native_libraries ( cmd, sess, codegen_results) ;
1996
1996
}
@@ -2401,7 +2401,7 @@ fn add_upstream_rust_crates<'a>(
2401
2401
// or is an rlib already included via some other dylib crate, the symbols from
2402
2402
// native libs will have already been included in that dylib.
2403
2403
//
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
2405
2405
// external build system already has the native dependencies defined, and it
2406
2406
// will provide them to the linker itself.
2407
2407
if sess. opts . unstable_opts . link_native_libraries {
0 commit comments