Skip to content

Commit c8c9942

Browse files
committed
librustc: move target dependent logic to back::link
1 parent 19e97f5 commit c8c9942

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/librustc/back/archive.rs

Lines changed: 2 additions & 8 deletions
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,14 +38,7 @@ pub struct ArchiveRO {
3738

3839
fn run_ar(sess: Session, args: &str, cwd: Option<&Path>,
3940
paths: &[&Path]) -> ProcessOutput {
40-
let ar = if sess.opts.target_triple == ~"arm-linux-androideabi" {
41-
match sess.opts.android_cross_path {
42-
Some(ref path) => *path + "/bin/" + "arm-linux-androideabi-ar",
43-
None => ~"arm-linux-androideabi-ar"
44-
}
45-
} else {
46-
sess.opts.ar.clone().unwrap_or_else(|| ~"ar")
47-
};
41+
let ar = get_ar_prog(sess);
4842

4943
let mut args = ~[args.to_owned()];
5044
let mut paths = paths.iter().map(|p| p.as_str().unwrap().to_owned());

src/librustc/back/link.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,22 @@ pub fn get_cc_prog(sess: Session) -> ~str {
736736
}
737737
}
738738

739+
pub fn get_ar_prog(sess: Session) -> ~str {
740+
match sess.targ_cfg.os {
741+
abi::OsAndroid => match sess.opts.android_cross_path {
742+
Some(ref path) => format!("{}/bin/arm-linux-androideabi-ar", *path),
743+
None => {
744+
sess.fatal("need Android NDK path for linking \
745+
(--android-cross-path)")
746+
}
747+
},
748+
_ => match sess.opts.ar {
749+
Some(ref ar) => format!("{}", *ar),
750+
None => ~"ar"
751+
},
752+
}
753+
}
754+
739755
/// Perform the linkage portion of the compilation phase. This will generate all
740756
/// of the requested outputs for this compilation session.
741757
pub fn link_binary(sess: Session,

0 commit comments

Comments
 (0)