Skip to content

Commit

Permalink
Auto merge of #9252 - ehuss:prefer-dynamic-ws, r=alexcrichton
Browse files Browse the repository at this point in the history
Fix logic for determining prefer-dynamic for a dylib.

The logic for determining if a dylib should use `prefer-dynamic` used to be something like "do not use prefer-dynamic if it is the current package".

The current logic has a strange behavior where it works as intended if there is only one package in the workspace, but a workspace with multiple packages will always use `prefer-dynamic`.

Instead of using `current_opt`, which isn't a good concept to use in a workspace, I switched this to be "primary" (a package selected on the command-line).

**History**
* 9879a0a Initial prefer-dynamic behavior.
* #3221 changed to the faulty logic (see comments at #3221 (comment)). I think there was some confusion there.
* #3478 fixed the logic for one of the changed conditions, but not the one for prefer-dynamic
  • Loading branch information
bors committed Mar 13, 2021
2 parents c4adfd5 + 48e0306 commit 32da9ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ fn build_base_args(
}

let prefer_dynamic = (unit.target.for_host() && !unit.target.is_custom_build())
|| (crate_types.contains(&CrateType::Dylib) && bcx.ws.members().any(|p| *p != unit.pkg));
|| (crate_types.contains(&CrateType::Dylib) && !cx.is_primary_package(unit));
if prefer_dynamic {
cmd.arg("-C").arg("prefer-dynamic");
}
Expand Down

0 comments on commit 32da9ea

Please sign in to comment.