Skip to content

Commit 1fa8e30

Browse files
committed
Auto merge of #538 - malbarbo:ci-android, r=alexcrichton
Add and fix tests for {i686, aarch64}-linux-android targets I think that these changes do not breaks compatibility. There are some types and constants changes to i686 and aarch64, but I see these changes as bug fixes instead of breaking changes. Also the type time64_t was remove from aarch64 because it is not defined in this arch. Fixes #536
2 parents 331b179 + b2791db commit 1fa8e30

File tree

21 files changed

+463
-200
lines changed

21 files changed

+463
-200
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ matrix:
5151
- os: linux
5252
env: TARGET=arm-linux-androideabi
5353
rust: stable
54+
- os: linux
55+
env: TARGET=aarch64-linux-android
56+
rust: stable
57+
- os: linux
58+
env: TARGET=i686-linux-android
59+
rust: stable
5460
- os: linux
5561
env: TARGET=x86_64-unknown-linux-musl
5662
rust: stable

ci/docker/arm-linux-androideabi/install-ndk.sh renamed to ci/android-install-ndk.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,24 @@ set -ex
1313

1414
curl -O https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip
1515
unzip -q android-ndk-r13b-linux-x86_64.zip
16+
17+
case "$1" in
18+
aarch64)
19+
arch=arm64
20+
;;
21+
22+
i686)
23+
arch=x86
24+
;;
25+
26+
*)
27+
arch=$1
28+
;;
29+
esac;
30+
1631
android-ndk-r13b/build/tools/make_standalone_toolchain.py \
17-
--install-dir /android/ndk-arm \
18-
--arch arm \
32+
--install-dir /android/ndk-$1 \
33+
--arch $arch \
1934
--api 24
2035

2136
rm -rf ./android-ndk-r13b-linux-x86_64.zip ./android-ndk-r13b

ci/docker/arm-linux-androideabi/install-sdk.sh renamed to ci/android-install-sdk.sh

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,35 @@ set -ex
1919
# which apparently magically accepts the licenses.
2020

2121
mkdir sdk
22-
curl https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz | \
23-
tar xzf - -C sdk --strip-components=1
22+
curl https://dl.google.com/android/repository/tools_r25.2.5-linux.zip -O
23+
unzip -d sdk tools_r25.2.5-linux.zip
2424

25-
filter="platform-tools,android-21"
26-
filter="$filter,sys-img-armeabi-v7a-android-21"
25+
filter="platform-tools,android-24"
2726

28-
./accept-licenses.sh "android - update sdk -a --no-ui --filter $filter"
27+
case "$1" in
28+
arm | armv7)
29+
abi=armeabi-v7a
30+
;;
31+
32+
aarch64)
33+
abi=arm64-v8a
34+
;;
35+
36+
i686)
37+
abi=x86
38+
;;
39+
40+
*)
41+
echo "invalid arch: $1"
42+
exit 1
43+
;;
44+
esac;
45+
46+
filter="$filter,sys-img-$abi-android-24"
47+
48+
./android-accept-licenses.sh "android - update sdk -a --no-ui --filter $filter"
2949

3050
echo "no" | android create avd \
31-
--name arm-21 \
32-
--target android-21 \
33-
--abi armeabi-v7a
51+
--name $1 \
52+
--target android-24 \
53+
--abi $abi
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=aarch64
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_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \
32+
HOME=/tmp

ci/docker/arm-linux-androideabi/Dockerfile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@ RUN dpkg --add-architecture i386 && \
1111
expect \
1212
openjdk-9-jre \
1313
libstdc++6:i386 \
14+
libpulse0 \
1415
gcc \
1516
libc6-dev
1617

1718
WORKDIR /android/
19+
COPY android* /android/
1820

19-
COPY install-ndk.sh /android/
20-
RUN sh /android/install-ndk.sh
21+
ENV ANDROID_ARCH=arm
22+
ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools
2123

22-
ENV PATH=$PATH:/android/ndk-arm/bin:/android/sdk/tools:/android/sdk/platform-tools
23-
24-
COPY install-sdk.sh accept-licenses.sh /android/
25-
RUN sh /android/install-sdk.sh
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/*
2629

2730
ENV PATH=$PATH:/rust/bin \
2831
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \
29-
ANDROID_EMULATOR_FORCE_32BIT=1 \
3032
HOME=/tmp
31-
RUN chmod 755 /android/sdk/tools/*
32-
33-
RUN cp -r /root/.android /tmp
34-
RUN chmod 777 -R /tmp/.android
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=i686
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_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \
32+
HOME=/tmp

ci/run-docker.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -ex
55

66
run() {
77
echo $1
8-
docker build -t libc ci/docker/$1
8+
# use -f so we can use ci/ as build context
9+
docker build -t libc -f ci/docker/$1/Dockerfile ci/
910
mkdir -p target
1011
docker run \
1112
--user `id -u`:`id -g` \

ci/run.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ case "$TARGET" in
105105
esac
106106

107107
case "$TARGET" in
108-
arm-linux-androideabi)
109-
emulator @arm-21 -no-window &
108+
arm-linux-androideabi | aarch64-linux-android | i686-linux-android)
109+
# set SHELL so android can detect a 64bits system, see
110+
# http://stackoverflow.com/a/41789144
111+
# https://issues.jenkins-ci.org/browse/JENKINS-26930?focusedCommentId=230791&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-230791
112+
export SHELL=/bin/dash
113+
arch=$(echo $TARGET | cut -d- -f1)
114+
emulator @$arch -no-window -no-accel &
110115
adb wait-for-device
111-
adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/libc-test
112-
adb shell /data/libc-test 2>&1 | tee /tmp/out
116+
adb push $CARGO_TARGET_DIR/$TARGET/debug/libc-test /data/local/tmp/libc-test
117+
adb shell /data/local/tmp/libc-test 2>&1 | tee /tmp/out
113118
grep "^PASSED .* tests" /tmp/out
114119
;;
115120

libc-test/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::env;
66

77
fn main() {
88
let target = env::var("TARGET").unwrap();
9+
let aarch64 = target.contains("aarch64");
910
let x86_64 = target.contains("x86_64");
1011
let windows = target.contains("windows");
1112
let mingw = target.contains("windows-gnu");
@@ -105,8 +106,12 @@ fn main() {
105106
}
106107

107108
if android {
109+
if !aarch64 {
110+
// time64_t is not define for aarch64
111+
// If included it will generate the error 'Your time_t is already 64-bit'
112+
cfg.header("time64.h");
113+
}
108114
cfg.header("arpa/inet.h");
109-
cfg.header("time64.h");
110115
cfg.header("xlocale.h");
111116
cfg.header("utmp.h");
112117
} else if !windows {

src/unix/bsd/mod.rs

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dox::mem;
1+
use dox::{mem, Option};
22

33
pub type c_char = i8;
44
pub type wchar_t = i32;
@@ -361,6 +361,75 @@ extern {
361361
pub fn getpeereid(socket: ::c_int,
362362
euid: *mut ::uid_t,
363363
egid: *mut ::gid_t) -> ::c_int;
364+
365+
#[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
366+
#[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
367+
pub fn glob(pattern: *const ::c_char,
368+
flags: ::c_int,
369+
errfunc: Option<extern fn(epath: *const ::c_char,
370+
errno: ::c_int) -> ::c_int>,
371+
pglob: *mut ::glob_t) -> ::c_int;
372+
#[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
373+
pub fn globfree(pglob: *mut ::glob_t);
374+
375+
pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
376+
-> ::c_int;
377+
378+
pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
379+
380+
#[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
381+
link_name = "seekdir$INODE64")]
382+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
383+
link_name = "seekdir$INODE64$UNIX2003")]
384+
pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
385+
386+
#[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
387+
link_name = "telldir$INODE64")]
388+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
389+
link_name = "telldir$INODE64$UNIX2003")]
390+
pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
391+
pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
392+
-> ::c_int;
393+
394+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
395+
link_name = "msync$UNIX2003")]
396+
#[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
397+
pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
398+
399+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
400+
link_name = "recvfrom$UNIX2003")]
401+
pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
402+
flags: ::c_int, addr: *mut ::sockaddr,
403+
addrlen: *mut ::socklen_t) -> ::ssize_t;
404+
pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
405+
pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
406+
pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
407+
408+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
409+
link_name = "bind$UNIX2003")]
410+
pub fn bind(socket: ::c_int, address: *const ::sockaddr,
411+
address_len: ::socklen_t) -> ::c_int;
412+
413+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
414+
link_name = "writev$UNIX2003")]
415+
pub fn writev(fd: ::c_int,
416+
iov: *const ::iovec,
417+
iovcnt: ::c_int) -> ::ssize_t;
418+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
419+
link_name = "readv$UNIX2003")]
420+
pub fn readv(fd: ::c_int,
421+
iov: *const ::iovec,
422+
iovcnt: ::c_int) -> ::ssize_t;
423+
424+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
425+
link_name = "sendmsg$UNIX2003")]
426+
pub fn sendmsg(fd: ::c_int,
427+
msg: *const ::msghdr,
428+
flags: ::c_int) -> ::ssize_t;
429+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
430+
link_name = "recvmsg$UNIX2003")]
431+
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
432+
-> ::ssize_t;
364433
}
365434

366435
cfg_if! {

src/unix/haiku/mod.rs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dox::mem;
1+
use dox::{mem, Option};
22

33
pub type rlim_t = ::uintptr_t;
44
pub type sa_family_t = u8;
@@ -760,6 +760,49 @@ extern {
760760
abstime: *const ::timespec) -> ::c_int;
761761
pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
762762
options: ::c_int) -> ::c_int;
763+
764+
pub fn glob(pattern: *const ::c_char,
765+
flags: ::c_int,
766+
errfunc: Option<extern fn(epath: *const ::c_char,
767+
errno: ::c_int) -> ::c_int>,
768+
pglob: *mut ::glob_t) -> ::c_int;
769+
pub fn globfree(pglob: *mut ::glob_t);
770+
771+
pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
772+
-> ::c_int;
773+
774+
pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
775+
776+
pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
777+
778+
pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
779+
pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
780+
-> ::c_int;
781+
782+
pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
783+
784+
pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
785+
flags: ::c_int, addr: *mut ::sockaddr,
786+
addrlen: *mut ::socklen_t) -> ::ssize_t;
787+
pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
788+
pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
789+
pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
790+
791+
pub fn bind(socket: ::c_int, address: *const ::sockaddr,
792+
address_len: ::socklen_t) -> ::c_int;
793+
794+
pub fn writev(fd: ::c_int,
795+
iov: *const ::iovec,
796+
iovcnt: ::c_int) -> ::ssize_t;
797+
pub fn readv(fd: ::c_int,
798+
iov: *const ::iovec,
799+
iovcnt: ::c_int) -> ::ssize_t;
800+
801+
pub fn sendmsg(fd: ::c_int,
802+
msg: *const ::msghdr,
803+
flags: ::c_int) -> ::ssize_t;
804+
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
805+
-> ::ssize_t;
763806
}
764807

765808
cfg_if! {

0 commit comments

Comments
 (0)