Skip to content

Commit

Permalink
Fix dylib reuse with uplift.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Oct 12, 2018
1 parent 714f82a commit b29d4d4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ impl<'cfg> Compilation<'cfg> {
} else {
let mut search_path =
super::filter_dynamic_search_path(self.native_dirs.iter(), &self.root_output);
search_path.push(self.root_output.clone());
search_path.push(self.deps_output.clone());
search_path.push(self.root_output.clone());
search_path.extend(self.target_dylib_path.clone());
search_path
};
Expand Down
61 changes: 61 additions & 0 deletions tests/testsuite/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1669,3 +1669,64 @@ fn all_features_all_crates() {

p.cargo("build --all-features --all").run();
}

#[test]
fn feature_off_dylib() {
let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
members = ["bar"]
[package]
name = "foo"
version = "0.0.1"
[lib]
crate-type = ["dylib"]
[features]
f1 = []
"#,
)
.file(
"src/lib.rs",
r#"
pub fn hello() -> &'static str {
if cfg!(feature = "f1") {
"f1"
} else {
"no f1"
}
}
"#,
)
.file(
"bar/Cargo.toml",
r#"
[package]
name = "bar"
version = "0.0.1"
[dependencies]
foo = { path = ".." }
"#,
)
.file(
"bar/src/main.rs",
r#"
extern crate foo;
fn main() {
assert_eq!(foo::hello(), "no f1");
}
"#,
)
.build();

// Build the dylib with `f1` feature.
p.cargo("build --features f1").run();
// Check that building without `f1` uses a dylib without `f1`.
p.cargo("run -p bar").run();
}

0 comments on commit b29d4d4

Please sign in to comment.