Skip to content

Commit

Permalink
Auto merge of #3335 - alexcrichton:fix-xcomiple, r=brson
Browse files Browse the repository at this point in the history
Add host dependency path via -L for cross compiles

Now that proc-macro crates can reexport from their dependencies we need to be
able to find the other crates, so ensure that we pass an appropriate -L flag.

Closes #3334
  • Loading branch information
bors committed Dec 2, 2016
2 parents c99ae7e + a298346 commit 307a613
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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

0 comments on commit 307a613

Please sign in to comment.