Skip to content

Commit 6c065fc

Browse files
committed
Auto merge of #21774 - ejjeong:enable-test-for-android, r=alexcrichton
- Now "make check-stage2-T-aarch64-linux-android-H-x86_64-unknown-linux-gnu" works (#21773) - Fix & enable debuginfo tests for android (#10381) - Fix & enable more tests for android (both for arm/aarch64) - Enable many already-pass tests on android (both for arm/aarch64)
2 parents f9aeea7 + 194d96e commit 6c065fc

File tree

114 files changed

+91
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+91
-156
lines changed

mk/install.mk

+7-5
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ tmp/empty_dir:
5858
# Android runtime setup
5959
# FIXME: This probably belongs somewhere else
6060

61-
# target platform specific variables
62-
# for arm-linux-androidabi
61+
# target platform specific variables for android
6362
define DEF_ADB_DEVICE_STATUS
6463
CFG_ADB_DEVICE_STATUS=$(1)
6564
endef
6665

6766
$(foreach target,$(CFG_TARGET), \
68-
$(if $(findstring $(target),"arm-linux-androideabi"), \
67+
$(if $(findstring android, $(target)), \
6968
$(if $(findstring adb,$(CFG_ADB)), \
7069
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[_A-Za-z0-9-]+[[:blank:]]+device')), \
7170
$(info install: install-runtime-target for $(target) enabled \
@@ -117,8 +116,11 @@ install-runtime-target-$(1)-cleanup:
117116
$$(call ADB_SHELL,rm,$$(CFG_RUNTIME_PUSH_DIR)/$$(call CFG_LIB_GLOB_$(1),$$(crate)));)
118117
endef
119118

120-
$(eval $(call INSTALL_RUNTIME_TARGET_N,arm-linux-androideabi,$(CFG_BUILD)))
121-
$(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,arm-linux-androideabi))
119+
$(foreach target,$(CFG_TARGET), \
120+
$(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
121+
$(eval $(call INSTALL_RUNTIME_TARGET_N,$(taget),$(CFG_BUILD))) \
122+
$(eval $(call INSTALL_RUNTIME_TARGET_CLEANUP_N,$(target))) \
123+
))
122124

123125
install-runtime-target: \
124126
install-runtime-target-arm-linux-androideabi-cleanup \

mk/rt.mk

+1-3
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ ifeq ($$(CFG_WINDOWSY_$(1)), 1)
139139
JEMALLOC_ARGS_$(1) := --enable-lazy-lock
140140
else ifeq ($(OSTYPE_$(1)), apple-ios)
141141
JEMALLOC_ARGS_$(1) := --disable-tls
142-
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
143-
JEMALLOC_ARGS_$(1) := --disable-tls
144-
else ifeq ($(OSTYPE_$(1)), linux-android)
142+
else ifeq ($(findstring android, $(OSTYPE_$(1))), android)
145143
JEMALLOC_ARGS_$(1) := --disable-tls
146144
endif
147145

mk/tests.mk

+13-12
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,13 @@ endef
107107
$(foreach target,$(CFG_TARGET), \
108108
$(eval $(call DEF_TARGET_COMMANDS,$(target))))
109109

110-
# Target platform specific variables
111-
# for arm-linux-androidabi
110+
# Target platform specific variables for android
112111
define DEF_ADB_DEVICE_STATUS
113112
CFG_ADB_DEVICE_STATUS=$(1)
114113
endef
115114

116115
$(foreach target,$(CFG_TARGET), \
117-
$(if $(findstring $(target),"arm-linux-androideabi"), \
116+
$(if $(findstring android, $(target)), \
118117
$(if $(findstring adb,$(CFG_ADB)), \
119118
$(if $(findstring device,$(shell $(CFG_ADB) devices 2>/dev/null | grep -E '^[:_A-Za-z0-9-]+[[:blank:]]+device')), \
120119
$(info check: android device attached) \
@@ -135,12 +134,14 @@ $(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
135134
$(shell $(CFG_ADB) remount 1>/dev/null) \
136135
$(shell $(CFG_ADB) shell rm -r $(CFG_ADB_TEST_DIR) >/dev/null) \
137136
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)) \
138-
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/tmp) \
139137
$(shell $(CFG_ADB) push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
140-
$(foreach crate,$(TARGET_CRATES), \
141-
$(shell $(CFG_ADB) push $(TLIB2_T_arm-linux-androideabi_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_arm-linux-androideabi,$(crate)) \
142-
$(CFG_ADB_TEST_DIR))) \
143-
)
138+
$(foreach target,$(CFG_TARGET), \
139+
$(if $(findstring android, $(target)), \
140+
$(shell $(CFG_ADB) shell mkdir $(CFG_ADB_TEST_DIR)/$(target)) \
141+
$(foreach crate,$(TARGET_CRATES), \
142+
$(shell $(CFG_ADB) push $(TLIB2_T_$(target)_H_$(CFG_BUILD))/$(call CFG_LIB_GLOB_$(target),$(crate)) \
143+
$(CFG_ADB_TEST_DIR)/$(target))), \
144+
)))
144145
else
145146
CFG_ADB_TEST_DIR=
146147
endif
@@ -393,14 +394,14 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
393394
&& touch $$@
394395
endef
395396

396-
define DEF_TEST_CRATE_RULES_arm-linux-androideabi
397+
define DEF_TEST_CRATE_RULES_android
397398
check-stage$(1)-T-$(2)-H-$(3)-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4))
398399

399400
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
400401
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
401402
@$$(call E, run: $$< via adb)
402403
$$(Q)$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
403-
$$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
404+
$$(Q)$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=./$(2) \
404405
./$$(notdir $$<) \
405406
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
406407
$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) $(TESTARGS))' \
@@ -434,9 +435,9 @@ $(foreach host,$(CFG_HOST), \
434435
$(foreach crate, $(TEST_CRATES), \
435436
$(if $(findstring $(target),$(CFG_BUILD)), \
436437
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))), \
437-
$(if $(findstring $(target),"arm-linux-androideabi"), \
438+
$(if $(findstring android, $(target)), \
438439
$(if $(findstring $(CFG_ADB_DEVICE_STATUS),"true"), \
439-
$(eval $(call DEF_TEST_CRATE_RULES_arm-linux-androideabi,$(stage),$(target),$(host),$(crate))), \
440+
$(eval $(call DEF_TEST_CRATE_RULES_android,$(stage),$(target),$(host),$(crate))), \
440441
$(eval $(call DEF_TEST_CRATE_RULES_null,$(stage),$(target),$(host),$(crate))) \
441442
), \
442443
$(eval $(call DEF_TEST_CRATE_RULES,$(stage),$(target),$(host),$(crate))) \

src/compiletest/compiletest.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ pub fn parse_config(args: Vec<String> ) -> Config {
153153
lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
154154
android_cross_path: opt_path(matches, "android-cross-path"),
155155
adb_path: opt_str2(matches.opt_str("adb-path")),
156-
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
156+
adb_test_dir: format!("{}/{}",
157+
opt_str2(matches.opt_str("adb-test-dir")),
158+
opt_str2(matches.opt_str("target"))),
157159
adb_device_status:
158-
"arm-linux-androideabi" ==
159-
opt_str2(matches.opt_str("target")) &&
160-
"(none)" !=
161-
opt_str2(matches.opt_str("adb-test-dir")) &&
160+
opt_str2(matches.opt_str("target")).contains("android") &&
161+
"(none)" != opt_str2(matches.opt_str("adb-test-dir")) &&
162162
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
163163
lldb_python_dir: matches.opt_str("lldb-python-dir"),
164164
verbose: matches.opt_present("verbose"),
@@ -213,17 +213,17 @@ pub fn opt_str2(maybestr: Option<String>) -> String {
213213
}
214214

215215
pub fn run_tests(config: &Config) {
216-
if config.target == "arm-linux-androideabi" {
216+
if config.target.contains("android") {
217217
match config.mode {
218218
DebugInfoGdb => {
219-
println!("arm-linux-androideabi debug-info \
220-
test uses tcp 5039 port. please reserve it");
219+
println!("{} debug-info test uses tcp 5039 port.\
220+
please reserve it", config.target);
221221
}
222222
_ =>{}
223223
}
224224

225-
//arm-linux-androideabi debug-info test uses remote debugger
226-
//so, we test 1 task at once.
225+
// android debug-info test uses remote debugger
226+
// so, we test 1 task at once.
227227
// also trying to isolate problems with adb_run_wrapper.sh ilooping
228228
env::set_var("RUST_TEST_TASKS","1");
229229
}

src/compiletest/runtest.rs

+30-17
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use test::MetricMap;
4242
pub fn run(config: Config, testfile: String) {
4343
match &*config.target {
4444

45-
"arm-linux-androideabi" => {
45+
"arm-linux-androideabi" | "aarch64-linux-android" => {
4646
if !config.adb_device_status {
4747
panic!("android device not available");
4848
}
@@ -382,17 +382,26 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
382382

383383
let debugger_run_result;
384384
match &*config.target {
385-
"arm-linux-androideabi" => {
385+
"arm-linux-androideabi" | "aarch64-linux-android" => {
386386

387-
cmds = cmds.replace("run", "continue").to_string();
387+
cmds = cmds.replace("run", "continue");
388388

389389
// write debugger script
390-
let script_str = ["set charset UTF-8".to_string(),
391-
format!("file {}", exe_file.as_str().unwrap()
392-
.to_string()),
393-
"target remote :5039".to_string(),
394-
cmds,
395-
"quit".to_string()].connect("\n");
390+
let mut script_str = String::with_capacity(2048);
391+
script_str.push_str("set charset UTF-8\n");
392+
script_str.push_str(&format!("file {}\n", exe_file.as_str().unwrap()));
393+
script_str.push_str("target remote :5039\n");
394+
script_str.push_str(&format!("set solib-search-path \
395+
./{}/stage2/lib/rustlib/{}/lib/\n",
396+
config.host, config.target));
397+
for line in breakpoint_lines.iter() {
398+
script_str.push_str(&format!("break {:?}:{}\n",
399+
testfile.filename_display(),
400+
*line)[]);
401+
}
402+
script_str.push_str(&cmds);
403+
script_str.push_str("quit\n");
404+
396405
debug!("script_str = {}", script_str);
397406
dump_output_file(config,
398407
testfile,
@@ -425,8 +434,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
425434
.expect(&format!("failed to exec `{:?}`", config.adb_path));
426435

427436
let adb_arg = format!("export LD_LIBRARY_PATH={}; \
428-
gdbserver :5039 {}/{}",
437+
gdbserver{} :5039 {}/{}",
429438
config.adb_test_dir.clone(),
439+
if config.target.contains("aarch64")
440+
{"64"} else {""},
430441
config.adb_test_dir.clone(),
431442
str::from_utf8(
432443
exe_file.filename()
@@ -470,7 +481,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
470481
format!("-command={}", debugger_script.as_str().unwrap()));
471482

472483
let mut gdb_path = tool_path;
473-
gdb_path.push_str("/bin/arm-linux-androideabi-gdb");
484+
gdb_path.push_str(&format!("/bin/{}-gdb", config.target));
474485
let procsrv::Result {
475486
out,
476487
err,
@@ -484,7 +495,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
484495
.expect(&format!("failed to exec `{:?}`", gdb_path));
485496
let cmdline = {
486497
let cmdline = make_cmdline("",
487-
"arm-linux-androideabi-gdb",
498+
&format!("{}-gdb", config.target),
488499
&debugger_opts);
489500
logv(config, format!("executing {}", cmdline));
490501
cmdline
@@ -496,7 +507,9 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
496507
stderr: err,
497508
cmdline: cmdline
498509
};
499-
process.signal_kill().unwrap();
510+
if process.signal_kill().is_err() {
511+
println!("Adb process is already finished.");
512+
}
500513
}
501514

502515
_=> {
@@ -1135,7 +1148,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
11351148

11361149
match &*config.target {
11371150

1138-
"arm-linux-androideabi" => {
1151+
"arm-linux-androideabi" | "aarch64-linux-android" => {
11391152
_arm_exec_compiled_test(config, props, testfile, env)
11401153
}
11411154

@@ -1200,7 +1213,7 @@ fn compose_and_run_compiler(
12001213
}
12011214

12021215
match &*config.target {
1203-
"arm-linux-androideabi" => {
1216+
"arm-linux-androideabi" | "aarch64-linux-android" => {
12041217
_arm_push_aux_shared_library(config, testfile);
12051218
}
12061219
_ => {}
@@ -1499,7 +1512,7 @@ fn _arm_exec_compiled_test(config: &Config,
14991512
for (key, val) in env {
15001513
runargs.push(format!("{}={}", key, val));
15011514
}
1502-
runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir));
1515+
runargs.push(format!("{}/../adb_run_wrapper.sh", config.adb_test_dir));
15031516
runargs.push(format!("{}", config.adb_test_dir));
15041517
runargs.push(format!("{}", prog_short));
15051518

@@ -1595,7 +1608,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
15951608
file.as_str()
15961609
.unwrap()
15971610
.to_string(),
1598-
config.adb_test_dir.to_string()
1611+
config.adb_test_dir.to_string(),
15991612
],
16001613
vec!(("".to_string(),
16011614
"".to_string())),

src/etc/adb_run_wrapper.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ then
2424
then
2525
shift
2626

27+
# The length of binary path (i.e. ./$RUN) should be shorter than 128 characters.
2728
cd $TEST_PATH
28-
TEST_EXEC_ENV=22 LD_LIBRARY_PATH=$TEST_PATH PATH=$BIN_PATH:$TEST_PATH $TEST_PATH/$RUN $@ 1>$TEST_PATH/$RUN.stdout 2>$TEST_PATH/$RUN.stderr
29+
TEST_EXEC_ENV=22 LD_LIBRARY_PATH=$TEST_PATH PATH=$BIN_PATH:$TEST_PATH ./$RUN $@ 1>$TEST_PATH/$RUN.stdout 2>$TEST_PATH/$RUN.stderr
2930
L_RET=$?
3031

3132
echo $L_RET > $TEST_PATH/$RUN.exitcode

src/liblibc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5473,6 +5473,7 @@ pub mod funcs {
54735473
use types::os::arch::c95::{c_uchar, c_int, size_t};
54745474

54755475
extern {
5476+
#[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
54765477
pub fn getdtablesize() -> c_int;
54775478
pub fn ioctl(d: c_int, request: c_int, ...) -> c_int;
54785479
pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int)

src/librustc_back/target/aarch64_linux_android.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use target::Target;
1313
pub fn target() -> Target {
1414
let mut base = super::linux_base::opts();
1515
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string());
16+
base.is_like_android = true;
1617
base.position_independent_executables = true;
1718
Target {
1819
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\

src/librustc_back/target/arm_linux_androideabi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn target() -> Target {
1616
// Many of the symbols defined in compiler-rt are also defined in libgcc. Android
1717
// linker doesn't like that by default.
1818
base.pre_link_args.push("-Wl,--allow-multiple-definition".to_string());
19+
base.is_like_android = true;
1920
// FIXME #17437 (and #17448): Android doesn't support position dependent executables anymore.
2021
base.position_independent_executables = false;
2122

src/librustc_back/target/mod.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ pub struct TargetOptions {
158158
/// only realy used for figuring out how to find libraries, since Windows uses its own
159159
/// library naming convention. Defaults to false.
160160
pub is_like_windows: bool,
161+
/// Whether the target toolchain is like Android's. Only useful for compiling against Android.
162+
/// Defaults to false.
163+
pub is_like_android: bool,
161164
/// Whether the linker support GNU-like arguments such as -O. Defaults to false.
162165
pub linker_is_gnu: bool,
163166
/// Whether the linker support rpaths or not. Defaults to false.
@@ -197,6 +200,7 @@ impl Default for TargetOptions {
197200
staticlib_suffix: ".a".to_string(),
198201
is_like_osx: false,
199202
is_like_windows: false,
203+
is_like_android: false,
200204
linker_is_gnu: false,
201205
has_rpath: false,
202206
no_compiler_rt: false,
@@ -345,11 +349,13 @@ impl Target {
345349
mips_unknown_linux_gnu,
346350
mipsel_unknown_linux_gnu,
347351
powerpc_unknown_linux_gnu,
348-
arm_linux_androideabi,
349352
arm_unknown_linux_gnueabi,
350353
arm_unknown_linux_gnueabihf,
351354
aarch64_unknown_linux_gnu,
352355

356+
arm_linux_androideabi,
357+
aarch64_linux_android,
358+
353359
x86_64_unknown_freebsd,
354360

355361
i686_unknown_dragonfly,
@@ -363,7 +369,6 @@ impl Target {
363369
i386_apple_ios,
364370
x86_64_apple_ios,
365371
aarch64_apple_ios,
366-
aarch64_linux_android,
367372
armv7_apple_ios,
368373
armv7s_apple_ios,
369374

src/librustc_trans/trans/debuginfo.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,9 @@ pub fn finalize(cx: &CrateContext) {
736736
// instruct LLVM to emit an older version of dwarf, however,
737737
// for OS X to understand. For more info see #11352
738738
// This can be overridden using --llvm-opts -dwarf-version,N.
739-
if cx.sess().target.target.options.is_like_osx {
739+
// Android has the same issue (#22398)
740+
if cx.sess().target.target.options.is_like_osx ||
741+
cx.sess().target.target.options.is_like_android {
740742
llvm::LLVMRustAddModuleFlag(cx.llmod(),
741743
"Dwarf Version\0".as_ptr() as *const _,
742744
2)

src/libstd/sys/unix/process.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,22 @@ impl Process {
7070
K: BytesContainer + Eq + Hash<Hasher>, V: BytesContainer
7171
{
7272
use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
73-
use libc::funcs::bsd44::getdtablesize;
7473

7574
mod rustrt {
7675
extern {
7776
pub fn rust_unset_sigprocmask();
7877
}
7978
}
8079

80+
#[cfg(all(target_os = "android", target_arch = "aarch64"))]
81+
unsafe fn getdtablesize() -> c_int {
82+
libc::sysconf(libc::consts::os::sysconf::_SC_OPEN_MAX) as c_int
83+
}
84+
#[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
85+
unsafe fn getdtablesize() -> c_int {
86+
libc::funcs::bsd44::getdtablesize()
87+
}
88+
8189
unsafe fn set_cloexec(fd: c_int) {
8290
let ret = c::ioctl(fd, c::FIOCLEX);
8391
assert_eq!(ret, 0);

src/test/compile-fail-fulldeps/macro-crate-cannot-read-embedded-ident.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// aux-build:macro_crate_test.rs
1212
// ignore-stage1
13-
// ignore-android
1413
// error-pattern: unknown start of token: \u{0}
1514

1615
// Issue #15750 and #15962 : this test is checking that the standard

src/test/compile-fail-fulldeps/macro-crate-doesnt-resolve.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// aux-build:macro_crate_test.rs
1212
// ignore-stage1
13-
// ignore-android
1413

1514
#[macro_use] #[no_link]
1615
extern crate macro_crate_test;

0 commit comments

Comments
 (0)