Skip to content

Commit b29d4d4

Browse files
committed
Fix dylib reuse with uplift.
1 parent 714f82a commit b29d4d4

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

Diff for: src/cargo/core/compiler/compilation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ impl<'cfg> Compilation<'cfg> {
193193
} else {
194194
let mut search_path =
195195
super::filter_dynamic_search_path(self.native_dirs.iter(), &self.root_output);
196-
search_path.push(self.root_output.clone());
197196
search_path.push(self.deps_output.clone());
197+
search_path.push(self.root_output.clone());
198198
search_path.extend(self.target_dylib_path.clone());
199199
search_path
200200
};

Diff for: tests/testsuite/features.rs

+61
Original file line numberDiff line numberDiff line change
@@ -1669,3 +1669,64 @@ fn all_features_all_crates() {
16691669

16701670
p.cargo("build --all-features --all").run();
16711671
}
1672+
1673+
#[test]
1674+
fn feature_off_dylib() {
1675+
let p = project()
1676+
.file(
1677+
"Cargo.toml",
1678+
r#"
1679+
[workspace]
1680+
members = ["bar"]
1681+
1682+
[package]
1683+
name = "foo"
1684+
version = "0.0.1"
1685+
1686+
[lib]
1687+
crate-type = ["dylib"]
1688+
1689+
[features]
1690+
f1 = []
1691+
"#,
1692+
)
1693+
.file(
1694+
"src/lib.rs",
1695+
r#"
1696+
pub fn hello() -> &'static str {
1697+
if cfg!(feature = "f1") {
1698+
"f1"
1699+
} else {
1700+
"no f1"
1701+
}
1702+
}
1703+
"#,
1704+
)
1705+
.file(
1706+
"bar/Cargo.toml",
1707+
r#"
1708+
[package]
1709+
name = "bar"
1710+
version = "0.0.1"
1711+
1712+
[dependencies]
1713+
foo = { path = ".." }
1714+
"#,
1715+
)
1716+
.file(
1717+
"bar/src/main.rs",
1718+
r#"
1719+
extern crate foo;
1720+
1721+
fn main() {
1722+
assert_eq!(foo::hello(), "no f1");
1723+
}
1724+
"#,
1725+
)
1726+
.build();
1727+
1728+
// Build the dylib with `f1` feature.
1729+
p.cargo("build --features f1").run();
1730+
// Check that building without `f1` uses a dylib without `f1`.
1731+
p.cargo("run -p bar").run();
1732+
}

0 commit comments

Comments
 (0)