Skip to content

Commit c34a802

Browse files
committed
Auto merge of rust-lang#572 - malbarbo:android-x86_64, r=alexcrichton
Add x86_64-linux-android support When rust add support for x86_64-linux-android, the tests may be run with: `rustup target add x86_64-linux-android && bash ci/run-docker.sh x86_64-linux-android`. Android x86_64 emulator does not work without hardware acceleration, so we are not able to run tests on travis.
2 parents 9dbdbb1 + 3ca6ad9 commit c34a802

File tree

9 files changed

+171
-58
lines changed

9 files changed

+171
-58
lines changed

ci/android-install-sdk.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ case "$1" in
3737
abi=x86
3838
;;
3939

40+
x86_64)
41+
abi=x86_64
42+
;;
43+
4044
*)
4145
echo "invalid arch: $1"
4246
exit 1
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM ubuntu:16.04
2+
3+
RUN dpkg --add-architecture i386 && \
4+
apt-get update && \
5+
apt-get install -y --no-install-recommends \
6+
file \
7+
curl \
8+
ca-certificates \
9+
python \
10+
unzip \
11+
expect \
12+
openjdk-9-jre \
13+
libstdc++6:i386 \
14+
libpulse0 \
15+
gcc \
16+
libc6-dev
17+
18+
WORKDIR /android/
19+
COPY android* /android/
20+
21+
ENV ANDROID_ARCH=x86_64
22+
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
23+
24+
RUN sh /android/android-install-ndk.sh $ANDROID_ARCH
25+
RUN sh /android/android-install-sdk.sh $ANDROID_ARCH
26+
RUN mv /root/.android /tmp
27+
RUN chmod 777 -R /tmp/.android
28+
RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/*
29+
30+
ENV PATH=$PATH:/rust/bin \
31+
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \
32+
HOME=/tmp

ci/run-docker.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ run() {
88
# use -f so we can use ci/ as build context
99
docker build -t libc -f ci/docker/$1/Dockerfile ci/
1010
mkdir -p target
11+
if [ -w /dev/kvm ]; then
12+
kvm="--volume /dev/kvm:/dev/kvm"
13+
fi
1114
docker run \
1215
--user `id -u`:`id -g` \
1316
--rm \
1417
--volume $HOME/.cargo:/cargo \
18+
$kvm \
1519
--env CARGO_HOME=/cargo \
1620
--volume `rustc --print sysroot`:/rust:ro \
1721
--volume `pwd`:/checkout:ro \

ci/run.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,17 @@ case "$TARGET" in
105105
esac
106106

107107
case "$TARGET" in
108-
arm-linux-androideabi | aarch64-linux-android | i686-linux-android)
108+
arm-linux-androideabi | aarch64-linux-android | i686-linux-android | x86_64-linux-android)
109109
# set SHELL so android can detect a 64bits system, see
110110
# http://stackoverflow.com/a/41789144
111111
# https://issues.jenkins-ci.org/browse/JENKINS-26930?focusedCommentId=230791&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230791
112112
export SHELL=/bin/dash
113113
arch=$(echo $TARGET | cut -d- -f1)
114-
emulator @$arch -no-window -no-accel &
114+
accel="-no-accel"
115+
if emulator -accel-check; then
116+
accel=""
117+
fi
118+
emulator @$arch -no-window $accel &
115119
adb wait-for-device
116120
adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/local/tmp/libc-test
117121
adb shell /data/local/tmp/libc-test 2>&1 | tee /tmp/out

libc-test/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ fn main() {
106106
}
107107

108108
if android {
109-
if !aarch64 {
110-
// time64_t is not define for aarch64
109+
if !aarch64 && !x86_64 {
110+
// time64_t is not define for aarch64 and x86_64
111111
// If included it will generate the error 'Your time_t is already 64-bit'
112112
cfg.header("time64.h");
113113
}

src/unix/notbsd/android/b32/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// The following definitions are correct for arm and i686,
2+
// but may be wrong for mips
3+
14
pub type c_long = i32;
25
pub type c_ulong = u32;
36
pub type mode_t = u16;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
pub type c_char = u8;
2+
pub type wchar_t = u32;
3+
4+
s! {
5+
pub struct stat {
6+
pub st_dev: ::dev_t,
7+
pub st_ino: ::ino_t,
8+
pub st_mode: ::c_uint,
9+
pub st_nlink: ::c_uint,
10+
pub st_uid: ::uid_t,
11+
pub st_gid: ::gid_t,
12+
pub st_rdev: ::dev_t,
13+
__pad1: ::c_ulong,
14+
pub st_size: ::off64_t,
15+
pub st_blksize: ::c_int,
16+
__pad2: ::c_int,
17+
pub st_blocks: ::c_long,
18+
pub st_atime: ::time_t,
19+
pub st_atime_nsec: ::c_ulong,
20+
pub st_mtime: ::time_t,
21+
pub st_mtime_nsec: ::c_ulong,
22+
pub st_ctime: ::time_t,
23+
pub st_ctime_nsec: ::c_ulong,
24+
__unused4: ::c_uint,
25+
__unused5: ::c_uint,
26+
}
27+
28+
pub struct stat64 {
29+
pub st_dev: ::dev_t,
30+
pub st_ino: ::ino_t,
31+
pub st_mode: ::c_uint,
32+
pub st_nlink: ::c_uint,
33+
pub st_uid: ::uid_t,
34+
pub st_gid: ::gid_t,
35+
pub st_rdev: ::dev_t,
36+
__pad1: ::c_ulong,
37+
pub st_size: ::off64_t,
38+
pub st_blksize: ::c_int,
39+
__pad2: ::c_int,
40+
pub st_blocks: ::c_long,
41+
pub st_atime: ::time_t,
42+
pub st_atime_nsec: ::c_ulong,
43+
pub st_mtime: ::time_t,
44+
pub st_mtime_nsec: ::c_ulong,
45+
pub st_ctime: ::time_t,
46+
pub st_ctime_nsec: ::c_ulong,
47+
__unused4: ::c_uint,
48+
__unused5: ::c_uint,
49+
}
50+
}
51+
52+
pub const O_DIRECT: ::c_int = 0x10000;
53+
pub const O_DIRECTORY: ::c_int = 0x4000;
54+
pub const O_NOFOLLOW: ::c_int = 0x8000;
55+
56+
pub const SYS_gettid: ::c_long = 178;

src/unix/notbsd/android/b64/mod.rs

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// The following definitions are correct for aarch64 and may be wrong for x86_64
1+
// The following definitions are correct for aarch64 and x86_64,
2+
// but may be wrong for mips64
23

3-
pub type c_char = u8;
44
pub type c_long = i64;
55
pub type c_ulong = u64;
66
pub type mode_t = u32;
77
pub type off64_t = i64;
88
pub type socklen_t = u32;
9-
pub type wchar_t = u32;
109

1110
s! {
1211
pub struct sigset_t {
@@ -25,52 +24,6 @@ s! {
2524
pub rlim_max: ::c_ulonglong,
2625
}
2726

28-
pub struct stat {
29-
pub st_dev: ::dev_t,
30-
pub st_ino: ::ino_t,
31-
pub st_mode: ::c_uint,
32-
pub st_nlink: ::c_uint,
33-
pub st_uid: ::uid_t,
34-
pub st_gid: ::gid_t,
35-
pub st_rdev: ::dev_t,
36-
__pad1: ::c_ulong,
37-
pub st_size: ::off64_t,
38-
pub st_blksize: ::c_int,
39-
__pad2: ::c_int,
40-
pub st_blocks: ::c_long,
41-
pub st_atime: ::time_t,
42-
pub st_atime_nsec: ::c_ulong,
43-
pub st_mtime: ::time_t,
44-
pub st_mtime_nsec: ::c_ulong,
45-
pub st_ctime: ::time_t,
46-
pub st_ctime_nsec: ::c_ulong,
47-
__unused4: ::c_uint,
48-
__unused5: ::c_uint,
49-
}
50-
51-
pub struct stat64 {
52-
pub st_dev: ::dev_t,
53-
pub st_ino: ::ino_t,
54-
pub st_mode: ::c_uint,
55-
pub st_nlink: ::c_uint,
56-
pub st_uid: ::uid_t,
57-
pub st_gid: ::gid_t,
58-
pub st_rdev: ::dev_t,
59-
__pad1: ::c_ulong,
60-
pub st_size: ::off64_t,
61-
pub st_blksize: ::c_int,
62-
__pad2: ::c_int,
63-
pub st_blocks: ::c_long,
64-
pub st_atime: ::time_t,
65-
pub st_atime_nsec: ::c_ulong,
66-
pub st_mtime: ::time_t,
67-
pub st_mtime_nsec: ::c_ulong,
68-
pub st_ctime: ::time_t,
69-
pub st_ctime_nsec: ::c_ulong,
70-
__unused4: ::c_uint,
71-
__unused5: ::c_uint,
72-
}
73-
7427
pub struct pthread_attr_t {
7528
pub flags: ::uint32_t,
7629
pub stack_base: *mut ::c_void,
@@ -143,15 +96,10 @@ s! {
14396
}
14497
}
14598

146-
pub const O_DIRECT: ::c_int = 0x10000;
147-
pub const O_DIRECTORY: ::c_int = 0x4000;
148-
pub const O_NOFOLLOW: ::c_int = 0x8000;
149-
15099
pub const RTLD_GLOBAL: ::c_int = 0x00100;
151100
pub const RTLD_NOW: ::c_int = 2;
152101
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
153102

154-
pub const SYS_gettid: ::c_long = 178;
155103
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
156104
value: 0,
157105
__reserved: [0; 36],
@@ -200,3 +148,15 @@ extern {
200148
// the return type should be ::ssize_t, but it is c_int!
201149
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::c_int;
202150
}
151+
152+
cfg_if! {
153+
if #[cfg(target_arch = "x86_64")] {
154+
mod x86_64;
155+
pub use self::x86_64::*;
156+
} else if #[cfg(target_arch = "aarch64")] {
157+
mod aarch64;
158+
pub use self::aarch64::*;
159+
} else {
160+
// Unknown target_arch
161+
}
162+
}

src/unix/notbsd/android/b64/x86_64.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
pub type c_char = i8;
2+
pub type wchar_t = i32;
3+
4+
s! {
5+
pub struct stat {
6+
pub st_dev: ::dev_t,
7+
pub st_ino: ::ino_t,
8+
pub st_nlink: ::c_ulong,
9+
pub st_mode: ::c_uint,
10+
pub st_uid: ::uid_t,
11+
pub st_gid: ::gid_t,
12+
pub st_rdev: ::dev_t,
13+
pub st_size: ::off64_t,
14+
pub st_blksize: ::c_long,
15+
pub st_blocks: ::c_long,
16+
pub st_atime: ::c_ulong,
17+
pub st_atime_nsec: ::c_ulong,
18+
pub st_mtime: ::c_ulong,
19+
pub st_mtime_nsec: ::c_ulong,
20+
pub st_ctime: ::c_ulong,
21+
pub st_ctime_nsec: ::c_ulong,
22+
__unused: [::c_long; 3],
23+
}
24+
25+
pub struct stat64 {
26+
pub st_dev: ::dev_t,
27+
pub st_ino: ::ino_t,
28+
pub st_nlink: ::c_ulong,
29+
pub st_mode: ::c_uint,
30+
pub st_uid: ::uid_t,
31+
pub st_gid: ::gid_t,
32+
pub st_rdev: ::dev_t,
33+
pub st_size: ::off64_t,
34+
pub st_blksize: ::c_long,
35+
pub st_blocks: ::c_long,
36+
pub st_atime: ::c_ulong,
37+
pub st_atime_nsec: ::c_ulong,
38+
pub st_mtime: ::c_ulong,
39+
pub st_mtime_nsec: ::c_ulong,
40+
pub st_ctime: ::c_ulong,
41+
pub st_ctime_nsec: ::c_ulong,
42+
__unused: [::c_long; 3],
43+
}
44+
}
45+
46+
pub const O_DIRECT: ::c_int = 0x4000;
47+
pub const O_DIRECTORY: ::c_int = 0x10000;
48+
pub const O_NOFOLLOW: ::c_int = 0x20000;
49+
50+
pub const SYS_gettid: ::c_long = 186;

0 commit comments

Comments
 (0)