Skip to content

Commit a35dc95

Browse files
committed
mk: --android-cross-path to rustc
1 parent 995a019 commit a35dc95

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
lines changed

mk/platform.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ CFG_PATH_MUNGE_arm-unknown-android := true
143143
CFG_LDPATH_arm-unknown-android :=
144144
CFG_RUN_arm-unknown-android=
145145
CFG_RUN_TARG_arm-unknown-android=
146+
RUSTC_FLAGS_arm-unknown-android :=--android-cross-path='$(CFG_ANDROID_CROSS_PATH)'
146147

147148
# i686-pc-mingw32 configuration
148149
CFG_LIB_NAME_i686-pc-mingw32=$(1).dll

src/librustc/back/link.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -774,11 +774,18 @@ pub fn link_binary(sess: Session,
774774
// instead of hard-coded gcc.
775775
// For win32, there is no cc command,
776776
// so we add a condition to make it use gcc.
777-
let cc_prog: ~str =
778-
if sess.targ_cfg.os == session::os_android {
779-
~"arm-linux-androideabi-g++"
780-
} else if sess.targ_cfg.os == session::os_win32 { ~"gcc" }
781-
else { ~"cc" };
777+
let cc_prog: ~str = if sess.targ_cfg.os == session::os_android {
778+
match &sess.opts.android_cross_path {
779+
&Some(copy path) => {
780+
fmt!("%s/bin/arm-linux-androideabi-gcc", path)
781+
}
782+
&None => {
783+
sess.fatal(~"need Android NDK path for linking \
784+
(--android-cross-path)")
785+
}
786+
}
787+
} else if sess.targ_cfg.os == session::os_win32 { ~"gcc" }
788+
else { ~"cc" };
782789
// The invocations of cc share some flags across platforms
783790

784791
let mut cc_args =
@@ -876,9 +883,7 @@ pub fn link_binary(sess: Session,
876883
}
877884

878885
// Stack growth requires statically linking a __morestack function
879-
if sess.targ_cfg.os != session::os_android {
880886
cc_args.push(~"-lmorestack");
881-
}
882887

883888
// FIXME (#2397): At some point we want to rpath our guesses as to where
884889
// extern libraries might live, based on the addl_lib_search_paths

src/librustc/driver/driver.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ pub fn build_session_options(+binary: ~str,
641641
.map(|s| Path(*s));
642642
let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg"));
643643
let test = opt_present(matches, ~"test");
644+
let android_cross_path = getopts::opt_maybe_str(
645+
matches, ~"android-cross-path");
644646
let sopts = @session::options {
645647
crate_type: crate_type,
646648
is_static: static,
@@ -660,7 +662,8 @@ pub fn build_session_options(+binary: ~str,
660662
test: test,
661663
parse_only: parse_only,
662664
no_trans: no_trans,
663-
debugging_opts: debugging_opts
665+
debugging_opts: debugging_opts,
666+
android_cross_path: android_cross_path
664667
};
665668
return sopts;
666669
}
@@ -764,6 +767,8 @@ pub fn optgroups() -> ~[getopts::groups::OptGroup] {
764767
to compile for (see
765768
http://sources.redhat.com/autobook/autobook/autobook_17.html
766769
for detail)", ~"TRIPLE"),
770+
optopt(~"", ~"android-cross-path",
771+
~"The path to the Android NDK", "PATH"),
767772
optmulti(~"W", ~"warn",
768773
~"Set lint warnings", ~"OPT"),
769774
optmulti(~"A", ~"allow",

src/librustc/driver/session.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ pub struct options {
140140
parse_only: bool,
141141
no_trans: bool,
142142
debugging_opts: uint,
143+
android_cross_path: Option<~str>
143144
}
144145

145146
pub struct crate_metadata {
@@ -289,7 +290,8 @@ pub fn basic_options() -> @options {
289290
test: false,
290291
parse_only: false,
291292
no_trans: false,
292-
debugging_opts: 0u
293+
debugging_opts: 0u,
294+
android_cross_path: None
293295
}
294296
}
295297

src/rt/rust_crate_map.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class cratemap {
4949
case 0: return NULL;
5050
case 1: return m_annihilate_fn;
5151
default: assert(false && "Unknown crate map version!");
52+
return NULL; // Appease -Werror=return-type
5253
}
5354
}
5455

@@ -57,6 +58,7 @@ class cratemap {
5758
case 0: return reinterpret_cast<const cratemap_v0 *>(this)->m_entries;
5859
case 1: return m_entries;
5960
default: assert(false && "Unknown crate map version!");
61+
return NULL; // Appease -Werror=return-type
6062
}
6163
}
6264

@@ -68,6 +70,7 @@ class cratemap {
6870
case 1:
6971
return &m_children[1];
7072
default: assert(false && "Unknown crate map version!");
73+
return NULL; // Appease -Werror=return-type
7174
}
7275
}
7376

src/rt/rust_log.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,11 @@ void update_log_settings(void* crate_map, char* settings) {
314314
n_dirs, &n_matches);
315315

316316
if (n_matches < n_dirs) {
317-
printf("warning: got %" PRIdPTR " RUST_LOG specs, "
317+
// NOTE: Android compiler is complaining about format specifiers here
318+
// and I don't understand why
319+
/*printf("warning: got %" PRIdPTR " RUST_LOG specs, "
318320
"enabled %" PRIdPTR " flags.",
319-
(uintptr_t)n_dirs, (uintptr_t)n_matches);
321+
(uintptr_t)n_dirs, (uintptr_t)n_matches);*/
320322
}
321323

322324
free(buffer);

0 commit comments

Comments
 (0)