Skip to content

Commit a6d3e57

Browse files
committed
auto merge of #10900 : yichoi/rust/mac_android_cross, r=alexcrichton
this patch should be followed by alexcrichton/libuv#2
2 parents cdcf28d + 635002a commit a6d3e57

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

src/librustc/back/archive.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! A helper class for dealing with static archives
1212
13+
use back::link::{get_ar_prog};
1314
use driver::session::Session;
1415
use metadata::filesearch;
1516
use lib::llvm::{ArchiveRef, llvm};
@@ -37,7 +38,8 @@ pub struct ArchiveRO {
3738

3839
fn run_ar(sess: Session, args: &str, cwd: Option<&Path>,
3940
paths: &[&Path]) -> ProcessOutput {
40-
let ar = sess.opts.ar.clone().unwrap_or_else(|| ~"ar");
41+
let ar = get_ar_prog(sess);
42+
4143
let mut args = ~[args.to_owned()];
4244
let mut paths = paths.iter().map(|p| p.as_str().unwrap().to_owned());
4345
args.extend(&mut paths);

src/librustc/back/link.rs

+28-5
Original file line numberDiff line numberDiff line change
@@ -723,16 +723,39 @@ pub fn get_cc_prog(sess: Session) -> ~str {
723723
// It would be flexible to use cc (system's default C compiler)
724724
// instead of hard-coded gcc.
725725
// For win32, there is no cc command, so we add a condition to make it use gcc.
726+
match sess.targ_cfg.os {
727+
abi::OsWin32 => return ~"gcc",
728+
_ => {},
729+
}
730+
731+
get_system_tool(sess, "cc")
732+
}
733+
734+
pub fn get_ar_prog(sess: Session) -> ~str {
735+
match sess.opts.ar {
736+
Some(ref ar) => return ar.to_owned(),
737+
None => {}
738+
}
739+
740+
get_system_tool(sess, "ar")
741+
}
742+
743+
fn get_system_tool(sess: Session, tool: &str) -> ~str {
726744
match sess.targ_cfg.os {
727745
abi::OsAndroid => match sess.opts.android_cross_path {
728-
Some(ref path) => format!("{}/bin/arm-linux-androideabi-gcc", *path),
746+
Some(ref path) => {
747+
let tool_str = match tool {
748+
"cc" => "gcc",
749+
_ => tool
750+
};
751+
format!("{}/bin/arm-linux-androideabi-{}", *path, tool_str)
752+
}
729753
None => {
730-
sess.fatal("need Android NDK path for linking \
731-
(--android-cross-path)")
754+
sess.fatal(format!("need Android NDK path for the '{}' tool \
755+
(--android-cross-path)", tool))
732756
}
733757
},
734-
abi::OsWin32 => ~"gcc",
735-
_ => ~"cc",
758+
_ => tool.to_owned(),
736759
}
737760
}
738761

0 commit comments

Comments
 (0)