Skip to content

Commit 0305358

Browse files
committed
auto merge of #14179 : luqmana/rust/acp, r=alexcrichton
It's a bit odd to single out just android when we don't do this for any other cross compiling targets. Android builds will still work since we just pass the full path for gcc and ar with `-C linker` and `-C ar`. I did add the flag to compiletest though so it can find gdb. Though, i'm pretty sure we don't run debuginfo tests on android anyways right now. [breaking-change]
2 parents db5ca23 + d0d800f commit 0305358

File tree

9 files changed

+17
-49
lines changed

9 files changed

+17
-49
lines changed

man/rustc.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ A space-separated list of arguments to pass through to LLVM.
138138
If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated
139139
throughout compilation in the output directory.
140140
.TP
141-
\fBandroid-cross-path\fR=path/to/ndk/bin
142-
Directory to find the Android NDK cross-compilation tools
143-
.TP
144141
\fBno-rpath\fR
145142
If specified, then the rpath value for dynamic libraries will not be set in
146143
either dynamic library or executable outputs.

mk/platform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ CFG_LDPATH_arm-linux-androideabi :=
307307
CFG_RUN_arm-linux-androideabi=
308308
CFG_RUN_TARG_arm-linux-androideabi=
309309
RUSTC_FLAGS_arm-linux-androideabi :=
310-
RUSTC_CROSS_FLAGS_arm-linux-androideabi :=-C android-cross-path=$(CFG_ANDROID_CROSS_PATH)
310+
RUSTC_CROSS_FLAGS_arm-linux-androideabi :=
311311

312312
# arm-unknown-linux-gnueabihf configuration
313313
CROSS_PREFIX_arm-unknown-linux-gnueabihf=arm-linux-gnueabihf-

mk/tests.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
601601
--stage-id stage$(1)-$(2) \
602602
--target $(2) \
603603
--host $(3) \
604+
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
604605
--adb-path=$(CFG_ADB) \
605606
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
606607
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \

src/compiletest/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ pub struct Config {
126126
// Host triple for the compiler being invoked
127127
pub host: ~str,
128128

129+
// Path to the android tools
130+
pub android_cross_path: Path,
131+
129132
// Extra parameter to run adb on arm-linux-androideabi
130133
pub adb_path: ~str,
131134

src/compiletest/compiletest.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
7979
optflag("", "jit", "run tests under the JIT"),
8080
optopt("", "target", "the target to build for", "TARGET"),
8181
optopt("", "host", "the host to build for", "HOST"),
82+
optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
8283
optopt("", "adb-path", "path to the android debugger", "PATH"),
8384
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
8485
optopt("", "lldb-python-dir", "directory containing LLDB's python module", "PATH"),
@@ -142,6 +143,7 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
142143
jit: matches.opt_present("jit"),
143144
target: opt_str2(matches.opt_str("target")).to_str(),
144145
host: opt_str2(matches.opt_str("host")).to_str(),
146+
android_cross_path: opt_path(matches, "android-cross-path"),
145147
adb_path: opt_str2(matches.opt_str("adb-path")).to_str(),
146148
adb_test_dir:
147149
opt_str2(matches.opt_str("adb-test-dir")).to_str(),
@@ -173,6 +175,7 @@ pub fn log_config(config: &Config) {
173175
logv(c, format!("jit: {}", config.jit));
174176
logv(c, format!("target: {}", config.target));
175177
logv(c, format!("host: {}", config.host));
178+
logv(c, format!("android-cross-path: {}", config.android_cross_path.display()));
176179
logv(c, format!("adb_path: {}", config.adb_path));
177180
logv(c, format!("adb_test_dir: {}", config.adb_test_dir));
178181
logv(c, format!("adb_device_status: {}", config.adb_device_status));

src/compiletest/runtest.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,18 +347,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
347347
break;
348348
}
349349

350-
let args = split_maybe_args(&config.target_rustcflags);
351-
let mut tool_path = StrBuf::new();
352-
for arg in args.iter() {
353-
if arg.contains("android-cross-path=") {
354-
tool_path = StrBuf::from_str(arg.replace("android-cross-path=", ""));
355-
break;
356-
}
357-
}
358-
359-
if tool_path.is_empty() {
360-
fatal("cannot found android cross path".to_owned());
361-
}
350+
let tool_path = match config.android_cross_path.as_str() {
351+
Some(x) => x.to_strbuf(),
352+
None => fatal("cannot find android cross path".to_owned())
353+
};
362354

363355
let debugger_script = make_out_name(config, testfile, "debugger.script");
364356
// FIXME (#9639): This needs to handle non-utf8 paths

src/etc/zsh/_rust

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ local -a _rustc_opts_switches _rustc_opts_lint _rustc_opts_debug
55
typeset -A opt_args
66

77
_rustc_opts_switches=(
8-
--android-cross-path'[The path to the Android NDK]'
98
--ar'[Program to use for managing archives instead of the default.]'
109
-c'[Compile and assemble, but do not link]'
1110
--cfg'[Configure the compilation environment]'

src/librustc/back/link.rs

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -757,40 +757,15 @@ pub fn get_cc_prog(sess: &Session) -> StrBuf {
757757
// instead of hard-coded gcc.
758758
// For win32, there is no cc command, so we add a condition to make it use gcc.
759759
match sess.targ_cfg.os {
760-
abi::OsWin32 => return "gcc".to_strbuf(),
761-
_ => {},
762-
}
763-
764-
get_system_tool(sess, "cc")
760+
abi::OsWin32 => "gcc",
761+
_ => "cc",
762+
}.to_strbuf()
765763
}
766764

767765
pub fn get_ar_prog(sess: &Session) -> StrBuf {
768766
match sess.opts.cg.ar {
769-
Some(ref ar) => return (*ar).clone(),
770-
None => {}
771-
}
772-
773-
get_system_tool(sess, "ar")
774-
}
775-
776-
fn get_system_tool(sess: &Session, tool: &str) -> StrBuf {
777-
match sess.targ_cfg.os {
778-
abi::OsAndroid => match sess.opts.cg.android_cross_path {
779-
Some(ref path) => {
780-
let tool_str = match tool {
781-
"cc" => "gcc",
782-
_ => tool
783-
};
784-
format_strbuf!("{}/bin/arm-linux-androideabi-{}",
785-
*path,
786-
tool_str)
787-
}
788-
None => {
789-
sess.fatal(format!("need Android NDK path for the '{}' tool \
790-
(-C android-cross-path)", tool))
791-
}
792-
},
793-
_ => tool.to_strbuf(),
767+
Some(ref ar) => (*ar).clone(),
768+
None => "ar".to_strbuf()
794769
}
795770
}
796771

src/librustc/driver/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ cgoptions!(
294294
"a list of arguments to pass to llvm (space separated)"),
295295
save_temps: bool = (false, parse_bool,
296296
"save all temporary output files during compilation"),
297-
android_cross_path: Option<StrBuf> = (None, parse_opt_string,
298-
"the path to the Android NDK"),
299297
no_rpath: bool = (false, parse_bool,
300298
"disables setting the rpath in libs/exes"),
301299
no_prepopulate_passes: bool = (false, parse_bool,

0 commit comments

Comments
 (0)