Skip to content

Commit ac4b345

Browse files
committed
Auto merge of #95606 - petrochenkov:linkregr, r=wesleywiser
linker: Implicitly link native libs as whole-archive in some more cases Partially revert changes from #93901 to address regressions like #95561. Fixes #95561 r? `@wesleywiser`
2 parents 596dece + a169d33 commit ac4b345

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
@@ -2080,9 +2080,14 @@ fn add_local_native_libraries(
20802080
NativeLibKind::Framework { as_needed } => {
20812081
cmd.link_framework(name, as_needed.unwrap_or(true))
20822082
}
2083-
NativeLibKind::Static { whole_archive, .. } => {
2083+
NativeLibKind::Static { whole_archive, bundle, .. } => {
20842084
if whole_archive == Some(true)
20852085
|| (whole_archive == None && default_to_whole_archive(sess, crate_type, cmd))
2086+
// Backward compatibility case: this can be a rlib (so `+whole-archive` cannot
2087+
// be added explicitly if necessary, see the error in `fn link_rlib`) compiled
2088+
// as an executable due to `--test`. Use whole-archive implicitly, like before
2089+
// the introduction of native lib modifiers.
2090+
|| (bundle != Some(false) && sess.opts.test)
20862091
{
20872092
cmd.link_whole_staticlib(
20882093
name,

0 commit comments

Comments
 (0)