Skip to content

Commit a1b2deb

Browse files
committed
New cross target: i686-linux-android
- All the libstd tests are now passing in the optimized build against a Zenfone2 and the x86 Android simulator.
1 parent e617a17 commit a1b2deb

File tree

7 files changed

+77
-10
lines changed

7 files changed

+77
-10
lines changed

configure

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ valopt python "" "set path to python"
602602
valopt jemalloc-root "" "set directory where libjemalloc_pic.a is located"
603603
valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple"
604604
valopt android-cross-path "/opt/ndk_standalone" "Android NDK standalone path (deprecated)"
605+
valopt i686-linux-android-ndk "" "i686-linux-android NDK standalone path"
605606
valopt arm-linux-androideabi-ndk "" "arm-linux-androideabi NDK standalone path"
606607
valopt aarch64-linux-android-ndk "" "aarch64-linux-android NDK standalone path"
607608
valopt release-channel "dev" "the name of the release channel to build"
@@ -1693,6 +1694,7 @@ putvar CFG_LIBDIR_RELATIVE
16931694
putvar CFG_DISABLE_MANAGE_SUBMODULES
16941695
putvar CFG_AARCH64_LINUX_ANDROID_NDK
16951696
putvar CFG_ARM_LINUX_ANDROIDEABI_NDK
1697+
putvar CFG_I686_LINUX_ANDROID_NDK
16961698
putvar CFG_MANDIR
16971699

16981700
# Avoid spurious warnings from clang by feeding it original source on

mk/cfg/i686-linux-android.mk

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# i686-linux-android configuration
2+
CC_i686-linux-android=$(CFG_I686_LINUX_ANDROID_NDK)/bin/i686-linux-android-gcc
3+
CXX_i686-linux-android=$(CFG_I686_LINUX_ANDROID_NDK)/bin/i686-linux-android-g++
4+
CPP_i686-linux-android=$(CFG_I686_LINUX_ANDROID_NDK)/bin/i686-linux-android-gcc -E
5+
AR_i686-linux-android=$(CFG_I686_LINUX_ANDROID_NDK)/bin/i686-linux-android-ar
6+
CFG_LIB_NAME_i686-linux-android=lib$(1).so
7+
CFG_STATIC_LIB_NAME_i686-linux-android=lib$(1).a
8+
CFG_LIB_GLOB_i686-linux-android=lib$(1)-*.so
9+
CFG_LIB_DSYM_GLOB_i686-linux-android=lib$(1)-*.dylib.dSYM
10+
CFG_JEMALLOC_CFLAGS_i686-linux-android := -D__i686__ -DANDROID -D__ANDROID__ $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_i686-linux-android := -Wall -g -fPIC -D__i686__ -DANDROID -D__ANDROID__ $(CFLAGS)
12+
CFG_GCCISH_CXXFLAGS_i686-linux-android := -fno-rtti $(CXXFLAGS)
13+
CFG_GCCISH_LINK_FLAGS_i686-linux-android := -shared -fPIC -ldl -g -lm -lsupc++
14+
CFG_GCCISH_DEF_FLAG_i686-linux-android := -Wl,--export-dynamic,--dynamic-list=
15+
CFG_LLC_FLAGS_i686-linux-android :=
16+
CFG_INSTALL_NAME_i686-linux-android =
17+
CFG_EXE_SUFFIX_i686-linux-android :=
18+
CFG_WINDOWSY_i686-linux-android :=
19+
CFG_UNIXY_i686-linux-android := 1
20+
CFG_LDPATH_i686-linux-android :=
21+
CFG_RUN_i686-linux-android=
22+
CFG_RUN_TARG_i686-linux-android=
23+
RUSTC_FLAGS_i686-linux-android :=
24+
RUSTC_CROSS_FLAGS_i686-linux-android :=
25+
CFG_GNU_TRIPLE_i686-linux-android := i686-linux-android

src/liblibc/lib.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,18 +465,19 @@ pub mod types {
465465
pub type off_t = i32;
466466
pub type dev_t = u32;
467467
pub type ino_t = u32;
468+
468469
pub type pid_t = i32;
469470
pub type uid_t = u32;
470471
pub type gid_t = u32;
471472
pub type useconds_t = u32;
473+
472474
pub type mode_t = u16;
473475
pub type ssize_t = i32;
474476
}
475-
#[cfg(any(target_arch = "x86",
477+
#[cfg(any(all(any(target_arch = "arm", target_arch = "x86"),
478+
not(target_os = "android")),
476479
target_arch = "le32",
477-
target_arch = "powerpc",
478-
all(any(target_arch = "arm", target_arch = "x86"),
479-
not(target_os = "android"))))]
480+
target_arch = "powerpc"))]
480481
pub mod posix01 {
481482
use types::os::arch::c95::{c_short, c_long, time_t};
482483
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
@@ -522,12 +523,13 @@ pub mod types {
522523
pub __size: [u32; 9]
523524
}
524525
}
526+
525527
#[cfg(all(any(target_arch = "arm", target_arch = "x86"),
526-
target_os = "android"))]
528+
target_os = "android"))]
527529
pub mod posix01 {
528-
use types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t};
530+
use types::os::arch::c95::{c_uchar, c_uint, c_ulong, c_long, time_t};
529531
use types::os::arch::c99::{c_longlong, c_ulonglong};
530-
use types::os::arch::posix88::{uid_t, gid_t, ino_t};
532+
use types::os::arch::posix88::{uid_t, gid_t};
531533

532534
pub type nlink_t = u16;
533535
pub type blksize_t = u32;
@@ -537,15 +539,15 @@ pub mod types {
537539
#[derive(Copy, Clone)] pub struct stat {
538540
pub st_dev: c_ulonglong,
539541
pub __pad0: [c_uchar; 4],
540-
pub __st_ino: ino_t,
542+
pub __st_ino: c_long,
541543
pub st_mode: c_uint,
542544
pub st_nlink: c_uint,
543545
pub st_uid: uid_t,
544546
pub st_gid: gid_t,
545547
pub st_rdev: c_ulonglong,
546548
pub __pad3: [c_uchar; 4],
547549
pub st_size: c_longlong,
548-
pub st_blksize: blksize_t,
550+
pub st_blksize: c_ulong,
549551
pub st_blocks: c_ulonglong,
550552
pub st_atime: time_t,
551553
pub st_atime_nsec: c_ulong,
@@ -567,6 +569,7 @@ pub mod types {
567569
pub __size: [u32; 9]
568570
}
569571
}
572+
570573
#[cfg(any(target_arch = "mips",
571574
target_arch = "mipsel"))]
572575
pub mod posix01 {
@@ -993,7 +996,12 @@ pub mod types {
993996
pub mod posix88 {
994997
pub type off_t = i64;
995998
pub type dev_t = u32;
999+
1000+
#[cfg(target_os = "android")]
1001+
pub type ino_t = u64;
1002+
#[cfg(not(target_os = "android"))]
9961003
pub type ino_t = u32;
1004+
9971005
pub type pid_t = i32;
9981006
pub type uid_t = u32;
9991007
pub type gid_t = u32;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use target::Target;
12+
13+
pub fn target() -> Target {
14+
Target {
15+
llvm_target: "i686-linux-android".to_string(),
16+
target_endian: "little".to_string(),
17+
target_pointer_width: "32".to_string(),
18+
arch: "x86".to_string(),
19+
target_os: "android".to_string(),
20+
target_env: "gnu".to_string(),
21+
options: super::android_base::opts(),
22+
}
23+
}

src/librustc_back/target/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ impl Target {
373373
aarch64_unknown_linux_gnu,
374374
x86_64_unknown_linux_musl,
375375

376+
i686_linux_android,
376377
arm_linux_androideabi,
377378
aarch64_linux_android,
378379

src/libstd/os/android/raw.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#[doc(inline)]
1616
pub use self::arch::{dev_t, mode_t, blkcnt_t, blksize_t, ino_t, nlink_t, off_t, stat, time_t};
1717

18-
#[cfg(target_arch = "arm")]
18+
#[cfg(any(target_arch = "arm", target_arch = "x86"))]
1919
mod arch {
2020
use os::raw::{c_uint, c_uchar, c_ulonglong, c_longlong, c_ulong};
2121
use os::unix::raw::{uid_t, gid_t};
@@ -150,3 +150,4 @@ mod arch {
150150
pub st_ino: ino_t,
151151
}
152152
}
153+

src/rt/rust_builtin.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ rust_list_dir_val(struct dirent* entry_ptr) {
3939
return entry_ptr->d_name;
4040
}
4141

42+
// Android's struct dirent does have d_type from the very beginning
43+
// (android-3). _DIRENT_HAVE_D_TYPE is not defined all the way to android-21
44+
// though...
45+
#if defined(__ANDROID__)
46+
# define _DIRENT_HAVE_D_TYPE
47+
#endif
48+
4249
int
4350
rust_dir_get_mode(struct dirent* entry_ptr) {
4451
#if defined(_DIRENT_HAVE_D_TYPE) || defined(__APPLE__)

0 commit comments

Comments
 (0)