about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYoung-il Choi <duddlf.choi@samsung.com>2013-03-05 13:12:23 +0900
committerYoung-il Choi <duddlf.choi@samsung.com>2013-03-05 13:12:23 +0900
commita35dc959693afc714989d039c83853abb0f2d650 (patch)
treec90d80d7aa848307028b106cbbd5248a9951c609
parent995a019dffc9c0b91392f2afe0be5685be045c2f (diff)
mk: --android-cross-path to rustc
-rw-r--r--mk/platform.mk1
-rw-r--r--src/librustc/back/link.rs19
-rw-r--r--src/librustc/driver/driver.rs7
-rw-r--r--src/librustc/driver/session.rs4
-rw-r--r--src/rt/rust_crate_map.h3
-rw-r--r--src/rt/rust_log.cpp6
6 files changed, 29 insertions, 11 deletions
diff --git a/mk/platform.mk b/mk/platform.mk
index 69a0845f1bd..fd1bb049e38 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 b30f9fcb9dd..b6ac068ff7f 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 50e31482587..e2647885d6a 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 2e8e4a6d51e..65a81f39845 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 285473e1938..a57840ffe09 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<const cratemap_v0 *>(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 26c038e2507..2b86db6defe 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);