From a35dc959693afc714989d039c83853abb0f2d650 Mon Sep 17 00:00:00 2001 From: Young-il Choi Date: Tue, 5 Mar 2013 13:12:23 +0900 Subject: [PATCH] mk: --android-cross-path to rustc --- mk/platform.mk | 1 + src/librustc/back/link.rs | 19 ++++++++++++------- src/librustc/driver/driver.rs | 7 ++++++- src/librustc/driver/session.rs | 4 +++- src/rt/rust_crate_map.h | 3 +++ src/rt/rust_log.cpp | 6 ++++-- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/mk/platform.mk b/mk/platform.mk index 69a0845f1bd2..fd1bb049e38a 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -143,6 +143,7 @@ CFG_PATH_MUNGE_arm-unknown-android := true CFG_LDPATH_arm-unknown-android := CFG_RUN_arm-unknown-android= CFG_RUN_TARG_arm-unknown-android= +RUSTC_FLAGS_arm-unknown-android :=--android-cross-path='$(CFG_ANDROID_CROSS_PATH)' # i686-pc-mingw32 configuration CFG_LIB_NAME_i686-pc-mingw32=$(1).dll diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index b30f9fcb9dd8..b6ac068ff7f3 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -774,11 +774,18 @@ pub fn link_binary(sess: Session, // instead of hard-coded gcc. // For win32, there is no cc command, // so we add a condition to make it use gcc. - let cc_prog: ~str = - if sess.targ_cfg.os == session::os_android { - ~"arm-linux-androideabi-g++" - } else if sess.targ_cfg.os == session::os_win32 { ~"gcc" } - else { ~"cc" }; + let cc_prog: ~str = if sess.targ_cfg.os == session::os_android { + match &sess.opts.android_cross_path { + &Some(copy path) => { + fmt!("%s/bin/arm-linux-androideabi-gcc", path) + } + &None => { + sess.fatal(~"need Android NDK path for linking \ + (--android-cross-path)") + } + } + } else if sess.targ_cfg.os == session::os_win32 { ~"gcc" } + else { ~"cc" }; // The invocations of cc share some flags across platforms let mut cc_args = @@ -876,9 +883,7 @@ pub fn link_binary(sess: Session, } // Stack growth requires statically linking a __morestack function - if sess.targ_cfg.os != session::os_android { cc_args.push(~"-lmorestack"); - } // FIXME (#2397): At some point we want to rpath our guesses as to where // extern libraries might live, based on the addl_lib_search_paths diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 50e314825872..e2647885d6ac 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -641,6 +641,8 @@ pub fn build_session_options(+binary: ~str, .map(|s| Path(*s)); let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg")); let test = opt_present(matches, ~"test"); + let android_cross_path = getopts::opt_maybe_str( + matches, ~"android-cross-path"); let sopts = @session::options { crate_type: crate_type, is_static: static, @@ -660,7 +662,8 @@ pub fn build_session_options(+binary: ~str, test: test, parse_only: parse_only, no_trans: no_trans, - debugging_opts: debugging_opts + debugging_opts: debugging_opts, + android_cross_path: android_cross_path }; return sopts; } @@ -764,6 +767,8 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] { to compile for (see http://sources.redhat.com/autobook/autobook/autobook_17.html for detail)", ~"TRIPLE"), + optopt(~"", ~"android-cross-path", + ~"The path to the Android NDK", "PATH"), optmulti(~"W", ~"warn", ~"Set lint warnings", ~"OPT"), optmulti(~"A", ~"allow", diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 2e8e4a6d51e0..65a81f39845b 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -140,6 +140,7 @@ pub struct options { parse_only: bool, no_trans: bool, debugging_opts: uint, + android_cross_path: Option<~str> } pub struct crate_metadata { @@ -289,7 +290,8 @@ pub fn basic_options() -> @options { test: false, parse_only: false, no_trans: false, - debugging_opts: 0u + debugging_opts: 0u, + android_cross_path: None } } diff --git a/src/rt/rust_crate_map.h b/src/rt/rust_crate_map.h index 285473e19389..a57840ffe095 100644 --- a/src/rt/rust_crate_map.h +++ b/src/rt/rust_crate_map.h @@ -49,6 +49,7 @@ public: case 0: return NULL; case 1: return m_annihilate_fn; default: assert(false && "Unknown crate map version!"); + return NULL; // Appease -Werror=return-type } } @@ -57,6 +58,7 @@ public: case 0: return reinterpret_cast(this)->m_entries; case 1: return m_entries; default: assert(false && "Unknown crate map version!"); + return NULL; // Appease -Werror=return-type } } @@ -68,6 +70,7 @@ public: case 1: return &m_children[1]; default: assert(false && "Unknown crate map version!"); + return NULL; // Appease -Werror=return-type } } diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp index 26c038e2507e..2b86db6defe0 100644 --- a/src/rt/rust_log.cpp +++ b/src/rt/rust_log.cpp @@ -314,9 +314,11 @@ void update_log_settings(void* crate_map, char* settings) { n_dirs, &n_matches); if (n_matches < n_dirs) { - printf("warning: got %" PRIdPTR " RUST_LOG specs, " + // NOTE: Android compiler is complaining about format specifiers here + // and I don't understand why + /*printf("warning: got %" PRIdPTR " RUST_LOG specs, " "enabled %" PRIdPTR " flags.", - (uintptr_t)n_dirs, (uintptr_t)n_matches); + (uintptr_t)n_dirs, (uintptr_t)n_matches);*/ } free(buffer);