Skip to content

Commit a169d33

Browse files
committed
linker: Implicitly link native libs as whole-archive in some more cases
1 parent b6a34f3 commit a169d33

File tree

1 file changed

+6
-1
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+6
-1
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -2079,9 +2079,14 @@ fn add_local_native_libraries(
20792079
NativeLibKind::Framework { as_needed } => {
20802080
cmd.link_framework(name, as_needed.unwrap_or(true))
20812081
}
2082-
NativeLibKind::Static { whole_archive, .. } => {
2082+
NativeLibKind::Static { whole_archive, bundle, .. } => {
20832083
if whole_archive == Some(true)
20842084
|| (whole_archive == None && default_to_whole_archive(sess, crate_type, cmd))
2085+
// Backward compatibility case: this can be a rlib (so `+whole-archive` cannot
2086+
// be added explicitly if necessary, see the error in `fn link_rlib`) compiled
2087+
// as an executable due to `--test`. Use whole-archive implicitly, like before
2088+
// the introduction of native lib modifiers.
2089+
|| (bundle != Some(false) && sess.opts.test)
20852090
{
20862091
cmd.link_whole_staticlib(
20872092
name,

0 commit comments

Comments
 (0)