Skip to content

Commit d014edc

Browse files
committed
cargo: Use $sysroot/bin/rustc to compile crate
Closes #1806
1 parent f3dba33 commit d014edc

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/cargo/cargo.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@ fn test_one_crate(_c: cargo, _path: str, cf: str, _p: pkg) {
436436
let buildpath = fs::connect(_path, "/test");
437437
need_dir(buildpath);
438438
#debug("Testing: %s -> %s", cf, buildpath);
439-
let p = run::program_output("rustc", ["--out-dir", buildpath, "--test",
440-
cf]);
439+
let p = run::program_output(rustc_sysroot(),
440+
["--out-dir", buildpath, "--test", cf]);
441441
if p.status != 0 {
442442
error(#fmt["rustc failed: %d\n%s\n%s", p.status, p.err, p.out]);
443443
ret;
@@ -452,7 +452,8 @@ fn install_one_crate(c: cargo, _path: str, cf: str, _p: pkg) {
452452
let buildpath = fs::connect(_path, "/build");
453453
need_dir(buildpath);
454454
#debug("Installing: %s -> %s", cf, buildpath);
455-
let p = run::program_output("rustc", ["--out-dir", buildpath, cf]);
455+
let p = run::program_output(rustc_sysroot(),
456+
["--out-dir", buildpath, cf]);
456457
if p.status != 0 {
457458
error(#fmt["rustc failed: %d\n%s\n%s", p.status, p.err, p.out]);
458459
ret;
@@ -473,6 +474,19 @@ fn install_one_crate(c: cargo, _path: str, cf: str, _p: pkg) {
473474
}
474475
}
475476

477+
fn rustc_sysroot() -> str {
478+
alt os::get_exe_path() {
479+
some(_path) {
480+
let path = [_path, "..", "bin", "rustc"];
481+
check vec::is_not_empty(path);
482+
let rustc = fs::normalize(fs::connect_many(path));
483+
#debug(" rustc: %s", rustc);
484+
rustc
485+
}
486+
none { "rustc" }
487+
}
488+
}
489+
476490
fn install_source(c: cargo, path: str) {
477491
#debug("source: %s", path);
478492
fs::change_dir(path);

0 commit comments

Comments
 (0)