Skip to content

Commit e6490cb

Browse files
committed
librustc: add get_system_tools for target specific environment
1 parent c8c9942 commit e6490cb

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/librustc/back/link.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -724,32 +724,39 @@ pub fn get_cc_prog(sess: Session) -> ~str {
724724
// instead of hard-coded gcc.
725725
// For win32, there is no cc command, so we add a condition to make it use gcc.
726726
match sess.targ_cfg.os {
727-
abi::OsAndroid => match sess.opts.android_cross_path {
728-
Some(ref path) => format!("{}/bin/arm-linux-androideabi-gcc", *path),
729-
None => {
730-
sess.fatal("need Android NDK path for linking \
731-
(--android-cross-path)")
732-
}
733-
},
734-
abi::OsWin32 => ~"gcc",
735-
_ => ~"cc",
727+
abi::OsWin32 => return ~"gcc",
728+
_ => {},
736729
}
730+
731+
get_system_tool(sess, "cc")
737732
}
738733

739734
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 {
740744
match sess.targ_cfg.os {
741745
abi::OsAndroid => match sess.opts.android_cross_path {
742-
Some(ref path) => format!("{}/bin/arm-linux-androideabi-ar", *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+
}
743753
None => {
744-
sess.fatal("need Android NDK path for linking \
745-
(--android-cross-path)")
754+
sess.fatal(format!("need Android NDK path for the '{}' tool \
755+
(--android-cross-path)", tool))
746756
}
747757
},
748-
_ => match sess.opts.ar {
749-
Some(ref ar) => format!("{}", *ar),
750-
None => ~"ar"
751-
},
752-
}
758+
_ => tool.to_owned(),
759+
}
753760
}
754761

755762
/// Perform the linkage portion of the compilation phase. This will generate all

0 commit comments

Comments
 (0)