Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/cargo/ops/cargo_rustc/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
self.layout(unit.kind).build().join(dir).join("out")
}

pub fn host_deps(&self) -> &Path {
self.host.deps()
}

/// Returns the appropriate output directory for the specified package and
/// target.
pub fn out_dir(&mut self, unit: &Unit) -> PathBuf {
Expand Down
10 changes: 10 additions & 0 deletions src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,16 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &mut Context, unit: &Unit)
deps
});

// Be sure that the host path is also listed. This'll ensure that proc-macro
// dependencies are correctly found (for reexported macros).
if let Kind::Target = unit.kind {
cmd.arg("-L").arg(&{
let mut deps = OsString::from("dependency=");
deps.push(cx.host_deps());
deps
});
}

for unit in cx.dep_targets(unit)?.iter() {
if unit.profile.run_custom_build {
cmd.env("OUT_DIR", &cx.build_script_out_dir(unit));
Expand Down
3 changes: 2 additions & 1 deletion tests/cross-compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ fn linker_and_ar() {
--emit=dep-info,link \
--target {target} \
-C ar=my-ar-tool -C linker=my-linker-tool \
-L dependency={dir}[/]target[/]{target}[/]debug[/]deps`
-L dependency={dir}[/]target[/]{target}[/]debug[/]deps \
-L dependency={dir}[/]target[/]debug[/]deps`
",
dir = p.root().display(),
url = p.url(),
Expand Down