Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,12 @@ impl<'cfg> Compilation<'cfg> {
is_rustc_tool: bool,
) -> CargoResult<ProcessBuilder> {
let mut search_path = Vec::new();
// this divides rustc/rustdoc invocations and other executions of build artifacts
if is_rustc_tool {
search_path.extend(super::filter_dynamic_search_path(
self.native_dirs.iter(),
&self.root_output[&CompileKind::Host],
));
search_path.push(self.deps_output[&CompileKind::Host].clone());
search_path.push(self.sysroot_host_libdir.clone());
} else {
Expand Down
21 changes: 20 additions & 1 deletion tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,9 +1175,27 @@ fn run_with_library_paths() {
)
.file(
"src/main.rs",
r##"
extern crate foo;

fn main() {
foo::assert_search_path();
}
"##,
)
.file(
"src/lib.rs",
&format!(
r##"
fn main() {{
#[test]
fn test_search_path() {{
assert_search_path();
}}

/// ```
/// foo::assert_search_path();
/// ```
pub fn assert_search_path() {{
let search_path = std::env::var_os("{}").unwrap();
let paths = std::env::split_paths(&search_path).collect::<Vec<_>>();
println!("{{:#?}}", paths);
Expand All @@ -1193,6 +1211,7 @@ fn run_with_library_paths() {
.build();

p.cargo("run").run();
p.cargo("test").run();
}

#[cargo_test]
Expand Down