@@ -723,16 +723,39 @@ pub fn get_cc_prog(sess: Session) -> ~str {
723
723
// It would be flexible to use cc (system's default C compiler)
724
724
// instead of hard-coded gcc.
725
725
// 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 {
726
744
match sess. targ_cfg . os {
727
745
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
+ }
729
753
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 ) )
732
756
}
733
757
} ,
734
- abi:: OsWin32 => ~"gcc",
735
- _ => ~"cc",
758
+ _ => tool. to_owned ( ) ,
736
759
}
737
760
}
738
761
0 commit comments