Skip to content

Commit a270127

Browse files
committed
---
yaml --- r: 152535 b: refs/heads/try2 c: a49b765 h: refs/heads/master i: 152533: b422fd9 152531: e6a7ce2 152527: 8079a1b v: v3
1 parent e0d4082 commit a270127

38 files changed

+462
-66
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 0c10c686824bf37084af87af84f338bcd2a7551a
8+
refs/heads/try2: a49b765f9a5b5926e338da30fcaae59ff1ae5c02
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/liblibc/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,13 @@ pub use consts::os::extra::{MAP_STACK};
278278
pub use consts::os::bsd44::{TCP_KEEPIDLE};
279279

280280
#[cfg(target_os = "macos")]
281+
#[cfg(target_os = "ios")]
281282
pub use consts::os::bsd44::{TCP_KEEPALIVE};
282283
#[cfg(target_os = "macos")]
284+
#[cfg(target_os = "ios")]
283285
pub use consts::os::extra::{F_FULLFSYNC};
284286
#[cfg(target_os = "macos")]
287+
#[cfg(target_os = "ios")]
285288
pub use types::os::arch::extra::{mach_timebase_info};
286289

287290

@@ -1286,6 +1289,7 @@ pub mod types {
12861289
}
12871290

12881291
#[cfg(target_os = "macos")]
1292+
#[cfg(target_os = "ios")]
12891293
pub mod os {
12901294
pub mod common {
12911295
pub mod posix01 {
@@ -3106,6 +3110,7 @@ pub mod consts {
31063110
}
31073111

31083112
#[cfg(target_os = "macos")]
3113+
#[cfg(target_os = "ios")]
31093114
pub mod os {
31103115
pub mod c95 {
31113116
use types::os::arch::c95::{c_int, c_uint};
@@ -3769,6 +3774,7 @@ pub mod funcs {
37693774
#[cfg(target_os = "linux")]
37703775
#[cfg(target_os = "android")]
37713776
#[cfg(target_os = "macos")]
3777+
#[cfg(target_os = "ios")]
37723778
#[cfg(target_os = "freebsd")]
37733779
pub mod posix88 {
37743780
pub mod stat_ {
@@ -3783,6 +3789,7 @@ pub mod funcs {
37833789
#[cfg(target_os = "linux")]
37843790
#[cfg(target_os = "freebsd")]
37853791
#[cfg(target_os = "android")]
3792+
#[cfg(target_os = "ios")]
37863793
pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
37873794

37883795
#[cfg(target_os = "macos")]
@@ -3795,6 +3802,7 @@ pub mod funcs {
37953802
#[cfg(target_os = "linux")]
37963803
#[cfg(target_os = "freebsd")]
37973804
#[cfg(target_os = "android")]
3805+
#[cfg(target_os = "ios")]
37983806
pub fn stat(path: *c_char, buf: *mut stat) -> c_int;
37993807

38003808
#[cfg(target_os = "macos")]
@@ -3967,6 +3975,7 @@ pub mod funcs {
39673975
#[cfg(target_os = "linux")]
39683976
#[cfg(target_os = "android")]
39693977
#[cfg(target_os = "macos")]
3978+
#[cfg(target_os = "ios")]
39703979
#[cfg(target_os = "freebsd")]
39713980
pub mod posix01 {
39723981
pub mod stat_ {
@@ -3977,6 +3986,7 @@ pub mod funcs {
39773986
#[cfg(target_os = "linux")]
39783987
#[cfg(target_os = "freebsd")]
39793988
#[cfg(target_os = "android")]
3989+
#[cfg(target_os = "ios")]
39803990
pub fn lstat(path: *c_char, buf: *mut stat) -> c_int;
39813991

39823992
#[cfg(target_os = "macos")]
@@ -4076,6 +4086,7 @@ pub mod funcs {
40764086
#[cfg(target_os = "linux")]
40774087
#[cfg(target_os = "android")]
40784088
#[cfg(target_os = "macos")]
4089+
#[cfg(target_os = "ios")]
40794090
#[cfg(target_os = "freebsd")]
40804091
pub mod posix08 {
40814092
pub mod unistd {
@@ -4156,6 +4167,7 @@ pub mod funcs {
41564167
}
41574168

41584169
#[cfg(target_os = "macos")]
4170+
#[cfg(target_os = "ios")]
41594171
#[cfg(target_os = "freebsd")]
41604172
pub mod bsd44 {
41614173
use types::common::c95::{c_void};
@@ -4209,6 +4221,7 @@ pub mod funcs {
42094221
}
42104222

42114223
#[cfg(target_os = "macos")]
4224+
#[cfg(target_os = "ios")]
42124225
pub mod extra {
42134226
use types::os::arch::c95::{c_char, c_int};
42144227

branches/try2/src/libnative/io/c_unix.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub use self::signal::{SA_NODEFER, SA_NOCLDWAIT, SA_SIGINFO, SIGCHLD};
2020
use libc;
2121

2222
#[cfg(target_os = "macos")]
23+
#[cfg(target_os = "ios")]
2324
#[cfg(target_os = "freebsd")]
2425
pub static FIONBIO: libc::c_ulong = 0x8004667e;
2526
#[cfg(target_os = "linux", not(target_arch = "mips"))]
@@ -29,6 +30,7 @@ pub static FIONBIO: libc::c_ulong = 0x5421;
2930
pub static FIONBIO: libc::c_ulong = 0x667e;
3031

3132
#[cfg(target_os = "macos")]
33+
#[cfg(target_os = "ios")]
3234
#[cfg(target_os = "freebsd")]
3335
pub static FIOCLEX: libc::c_ulong = 0x20006601;
3436
#[cfg(target_os = "linux", not(target_arch = "mips"))]
@@ -38,6 +40,7 @@ pub static FIOCLEX: libc::c_ulong = 0x5451;
3840
pub static FIOCLEX: libc::c_ulong = 0x6601;
3941

4042
#[cfg(target_os = "macos")]
43+
#[cfg(target_os = "ios")]
4144
#[cfg(target_os = "freebsd")]
4245
pub static MSG_DONTWAIT: libc::c_int = 0x80;
4346
#[cfg(target_os = "linux")]
@@ -75,6 +78,7 @@ extern {
7578
}
7679

7780
#[cfg(target_os = "macos")]
81+
#[cfg(target_os = "ios")]
7882
mod select {
7983
pub static FD_SETSIZE: uint = 1024;
8084

@@ -187,6 +191,7 @@ mod signal {
187191
}
188192

189193
#[cfg(target_os = "macos")]
194+
#[cfg(target_os = "ios")]
190195
#[cfg(target_os = "freebsd")]
191196
mod signal {
192197
use libc;
@@ -201,6 +206,7 @@ mod signal {
201206
pub static SIGCHLD: libc::c_int = 20;
202207

203208
#[cfg(target_os = "macos")]
209+
#[cfg(target_os = "ios")]
204210
pub type sigset_t = u32;
205211
#[cfg(target_os = "freebsd")]
206212
pub struct sigset_t {
@@ -219,6 +225,7 @@ mod signal {
219225
}
220226

221227
#[cfg(target_os = "macos")]
228+
#[cfg(target_os = "ios")]
222229
pub struct sigaction {
223230
pub sa_handler: extern fn(libc::c_int),
224231
sa_tramp: *mut libc::c_void,

branches/try2/src/libnative/io/file_unix.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,15 @@ impl rtio::RtioFileStream for FileDesc {
133133
return super::mkerr_libc(os_datasync(self.fd()));
134134

135135
#[cfg(target_os = "macos")]
136+
#[cfg(target_os = "ios")]
136137
fn os_datasync(fd: c_int) -> c_int {
137138
unsafe { libc::fcntl(fd, libc::F_FULLFSYNC) }
138139
}
139140
#[cfg(target_os = "linux")]
140141
fn os_datasync(fd: c_int) -> c_int {
141142
retry(|| unsafe { libc::fdatasync(fd) })
142143
}
143-
#[cfg(not(target_os = "macos"), not(target_os = "linux"))]
144+
#[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "linux"))]
144145
fn os_datasync(fd: c_int) -> c_int {
145146
retry(|| unsafe { libc::fsync(fd) })
146147
}

branches/try2/src/libnative/io/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub mod file;
5050
pub mod file;
5151

5252
#[cfg(target_os = "macos")]
53+
#[cfg(target_os = "ios")]
5354
#[cfg(target_os = "freebsd")]
5455
#[cfg(target_os = "android")]
5556
#[cfg(target_os = "linux")]

branches/try2/src/libnative/io/net.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ impl TcpStream {
320320
}
321321

322322
#[cfg(target_os = "macos")]
323+
#[cfg(target_os = "ios")]
323324
fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> {
324325
setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
325326
seconds as libc::c_int)
@@ -329,7 +330,7 @@ impl TcpStream {
329330
setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
330331
seconds as libc::c_int)
331332
}
332-
#[cfg(not(target_os = "macos"), not(target_os = "freebsd"))]
333+
#[cfg(not(target_os = "macos"), not(target_os = "ios"), not(target_os = "freebsd"))]
333334
fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> {
334335
Ok(())
335336
}

branches/try2/src/libnative/io/process.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ fn translate_status(status: c_int) -> rtio::ProcessExit {
769769
}
770770

771771
#[cfg(target_os = "macos")]
772+
#[cfg(target_os = "ios")]
772773
#[cfg(target_os = "freebsd")]
773774
mod imp {
774775
pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }

branches/try2/src/libnative/io/timer_unix.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,20 @@ pub fn now() -> u64 {
9393
}
9494
}
9595

96-
fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
96+
97+
// Note: although the last parameter isn't used there is no way now to
98+
// convert it to unit type, because LLVM dies in SjLj preparation
99+
// step (unfortunately iOS uses SjLJ exceptions)
100+
//
101+
// It's definitely a temporary workaround just to get it working.
102+
// So far it looks like an LLVM issue and it was reported:
103+
// http://llvm.org/bugs/show_bug.cgi?id=19855
104+
// Actually this issue is pretty common while compiling for armv7 iOS
105+
// and in most cases it is simply solved by using --opt-level=2 (or -O)
106+
//
107+
// For this specific case unfortunately turning optimizations wasn't
108+
// enough.
109+
fn helper(input: libc::c_int, messages: Receiver<Req>, _: int) {
97110
let mut set: c::fd_set = unsafe { mem::zeroed() };
98111

99112
let mut fd = FileDesc::new(input, true);
@@ -202,7 +215,9 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) {
202215

203216
impl Timer {
204217
pub fn new() -> IoResult<Timer> {
205-
unsafe { HELPER.boot(|| {}, helper); }
218+
// See notes above regarding using int return value
219+
// instead of ()
220+
unsafe { HELPER.boot(|| {0}, helper); }
206221

207222
static mut ID: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT;
208223
let id = unsafe { ID.fetch_add(1, atomics::Relaxed) };

branches/try2/src/librustc/back/arm.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
3434
-a0:0:64-n32".to_string()
3535
}
3636

37+
abi::OsiOS => {
38+
"e-p:32:32:32\
39+
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
40+
-f32:32:32-f64:64:64\
41+
-v64:64:64-v128:64:128\
42+
-a0:0:64-n32".to_string()
43+
}
44+
3745
abi::OsWin32 => {
3846
"e-p:32:32:32\
3947
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\

branches/try2/src/librustc/back/link.rs

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ pub mod write {
114114
// which are *far* more efficient. This is obviously undesirable in some
115115
// cases, so if any sort of target feature is specified we don't append v7
116116
// to the feature list.
117+
//
118+
// On iOS only armv7 and newer are supported. So it is useful to
119+
// get all hardware potential via VFP3 (hardware floating point)
120+
// and NEON (SIMD) instructions supported by LLVM.
121+
// Note that without those flags various linking errors might
122+
// arise as some of intrinsicts are converted into function calls
123+
// and nobody provides implementations those functions
117124
fn target_feature<'a>(sess: &'a Session) -> &'a str {
118125
match sess.targ_cfg.os {
119126
abi::OsAndroid => {
@@ -122,7 +129,10 @@ pub mod write {
122129
} else {
123130
sess.opts.cg.target_feature.as_slice()
124131
}
125-
}
132+
},
133+
abi::OsiOS if sess.targ_cfg.arch == abi::Arm => {
134+
"+v7,+thumb2,+vfp3,+neon"
135+
},
126136
_ => sess.opts.cg.target_feature.as_slice()
127137
}
128138
}
@@ -827,15 +837,23 @@ pub fn filename_for_input(sess: &Session, crate_type: config::CrateType,
827837
out_filename.with_filename(format!("lib{}.rlib", libname))
828838
}
829839
config::CrateTypeDylib => {
830-
let (prefix, suffix) = match sess.targ_cfg.os {
831-
abi::OsWin32 => (loader::WIN32_DLL_PREFIX, loader::WIN32_DLL_SUFFIX),
832-
abi::OsMacos => (loader::MACOS_DLL_PREFIX, loader::MACOS_DLL_SUFFIX),
833-
abi::OsLinux => (loader::LINUX_DLL_PREFIX, loader::LINUX_DLL_SUFFIX),
834-
abi::OsAndroid => (loader::ANDROID_DLL_PREFIX, loader::ANDROID_DLL_SUFFIX),
835-
abi::OsFreebsd => (loader::FREEBSD_DLL_PREFIX, loader::FREEBSD_DLL_SUFFIX),
836-
};
837-
out_filename.with_filename(format!("{}{}{}", prefix, libname,
838-
suffix))
840+
// There is no support of DyLibs on iOS
841+
if sess.targ_cfg.os == abi::OsiOS {
842+
out_filename.with_filename(format!("lib{}.a", libname))
843+
} else {
844+
let (prefix, suffix) = match sess.targ_cfg.os {
845+
abi::OsWin32 => (loader::WIN32_DLL_PREFIX, loader::WIN32_DLL_SUFFIX),
846+
abi::OsMacos => (loader::MACOS_DLL_PREFIX, loader::MACOS_DLL_SUFFIX),
847+
abi::OsLinux => (loader::LINUX_DLL_PREFIX, loader::LINUX_DLL_SUFFIX),
848+
abi::OsAndroid => (loader::ANDROID_DLL_PREFIX, loader::ANDROID_DLL_SUFFIX),
849+
abi::OsFreebsd => (loader::FREEBSD_DLL_PREFIX, loader::FREEBSD_DLL_SUFFIX),
850+
abi::OsiOS => unreachable!(),
851+
};
852+
out_filename.with_filename(format!("{}{}{}",
853+
prefix,
854+
libname,
855+
suffix))
856+
}
839857
}
840858
config::CrateTypeStaticlib => {
841859
out_filename.with_filename(format!("lib{}.a", libname))
@@ -886,7 +904,14 @@ fn link_binary_output(sess: &Session,
886904
link_natively(sess, trans, false, &obj_filename, &out_filename);
887905
}
888906
config::CrateTypeDylib => {
889-
link_natively(sess, trans, true, &obj_filename, &out_filename);
907+
if sess.targ_cfg.os == abi::OsiOS {
908+
sess.warn(format!("No dylib for iOS -> saving static library {} to {}",
909+
obj_filename.display(), out_filename.display()).as_slice());
910+
link_staticlib(sess, &obj_filename, &out_filename);
911+
}
912+
else {
913+
link_natively(sess, trans, true, &obj_filename, &out_filename);
914+
}
890915
}
891916
}
892917

@@ -991,7 +1016,7 @@ fn link_rlib<'a>(sess: &'a Session,
9911016
// symbol table of the archive. This currently dies on OSX (see
9921017
// #11162), and isn't necessary there anyway
9931018
match sess.targ_cfg.os {
994-
abi::OsMacos => {}
1019+
abi::OsMacos | abi::OsiOS => {}
9951020
_ => { a.update_symbols(); }
9961021
}
9971022
}
@@ -1104,15 +1129,16 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
11041129

11051130
// On OSX, debuggers need this utility to get run to do some munging of
11061131
// the symbols
1107-
if sess.targ_cfg.os == abi::OsMacos && (sess.opts.debuginfo != NoDebugInfo) {
1108-
match Command::new("dsymutil").arg(out_filename).status() {
1109-
Ok(..) => {}
1110-
Err(e) => {
1111-
sess.err(format!("failed to run dsymutil: {}", e).as_slice());
1112-
sess.abort_if_errors();
1132+
if (sess.targ_cfg.os == abi::OsMacos || sess.targ_cfg.os == abi::OsiOS)
1133+
&& (sess.opts.debuginfo != NoDebugInfo) {
1134+
match Command::new("dsymutil").arg(out_filename).status() {
1135+
Ok(..) => {}
1136+
Err(e) => {
1137+
sess.err(format!("failed to run dsymutil: {}", e).as_slice());
1138+
sess.abort_if_errors();
1139+
}
11131140
}
11141141
}
1115-
}
11161142
}
11171143

11181144
fn link_args(cmd: &mut Command,
@@ -1169,7 +1195,7 @@ fn link_args(cmd: &mut Command,
11691195
// already done the best it can do, and we also don't want to eliminate the
11701196
// metadata. If we're building an executable, however, --gc-sections drops
11711197
// the size of hello world from 1.8MB to 597K, a 67% reduction.
1172-
if !dylib && sess.targ_cfg.os != abi::OsMacos {
1198+
if !dylib && sess.targ_cfg.os != abi::OsMacos && sess.targ_cfg.os != abi::OsiOS {
11731199
cmd.arg("-Wl,--gc-sections");
11741200
}
11751201

@@ -1185,7 +1211,7 @@ fn link_args(cmd: &mut Command,
11851211
sess.opts.optimize == config::Aggressive {
11861212
cmd.arg("-Wl,-O1");
11871213
}
1188-
} else if sess.targ_cfg.os == abi::OsMacos {
1214+
} else if sess.targ_cfg.os == abi::OsMacos || sess.targ_cfg.os == abi::OsiOS {
11891215
// The dead_strip option to the linker specifies that functions and data
11901216
// unreachable by the entry point will be removed. This is quite useful
11911217
// with Rust's compilation model of compiling libraries at a time into
@@ -1348,7 +1374,7 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
13481374
// For those that support this, we ensure we pass the option if the library
13491375
// was flagged "static" (most defaults are dynamic) to ensure that if
13501376
// libfoo.a and libfoo.so both exist that the right one is chosen.
1351-
let takes_hints = sess.targ_cfg.os != abi::OsMacos;
1377+
let takes_hints = sess.targ_cfg.os != abi::OsMacos && sess.targ_cfg.os != abi::OsiOS;
13521378

13531379
for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
13541380
match kind {

0 commit comments

Comments
 (0)