Skip to content

Commit b43ee6c

Browse files
committed
auto merge of #9277 : crabtw/rust/mips, r=brson
This patch fixes some errors of MIPS target, however, MIPS C ABI is still broken. I will send another PR to fix the problem. Because MIPS target has no "generic" CPU name, I add --target-cpu and --target-feature to RUST_FLAGS. In order to workaround the "compact frame descriptions incompatible with DWARF2 .eh_frame" problem, the linker I used is CXX but not CC.
2 parents e02313a + d11f746 commit b43ee6c

File tree

3 files changed

+143
-29
lines changed

3 files changed

+143
-29
lines changed

mk/platform.mk

+3-2
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ CFG_PATH_MUNGE_mips-unknown-linux-gnu := true
343343
CFG_LDPATH_mips-unknown-linux-gnu :=
344344
CFG_RUN_mips-unknown-linux-gnu=
345345
CFG_RUN_TARG_mips-unknown-linux-gnu=
346+
RUSTC_FLAGS_mips-unknown-linux-gnu := --linker=$(CXX_mips-unknown-linux-gnu) --target-cpu mips32r2 --target-feature +mips32r2,+o32
346347

347348
# i686-pc-mingw32 configuration
348349
CC_i686-pc-mingw32=$(CC)
@@ -480,7 +481,7 @@ define CFG_MAKE_TOOLCHAIN
480481
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
481482
$$(call CFG_INSTALL_NAME_$(1),$$(4))
482483

483-
ifneq ($(HOST_$(1)),arm)
484+
ifeq ($$(findstring $(HOST_$(1)),arm mips),)
484485

485486
# We're using llvm-mc as our assembler because it supports
486487
# .cfi pseudo-ops on mac
@@ -492,7 +493,7 @@ define CFG_MAKE_TOOLCHAIN
492493
-o=$$(1)
493494
else
494495

495-
# For the ARM crosses, use the toolchain assembler
496+
# For the ARM and MIPS crosses, use the toolchain assembler
496497
# XXX: We should be able to use the LLVM assembler
497498
CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
498499

src/libstd/libc.rs

+139-26
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ pub mod types {
294294
pub type ssize_t = i32;
295295
}
296296
#[cfg(target_arch = "x86")]
297-
#[cfg(target_arch = "mips")]
298297
pub mod posix01 {
299298
use libc::types::os::arch::c95::{c_short, c_long, time_t};
300299
use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
@@ -305,7 +304,6 @@ pub mod types {
305304
pub type blksize_t = i32;
306305
pub type blkcnt_t = i32;
307306

308-
#[cfg(target_arch = "x86")]
309307
pub struct stat {
310308
st_dev: dev_t,
311309
__pad1: c_short,
@@ -328,30 +326,6 @@ pub mod types {
328326
__unused4: c_long,
329327
__unused5: c_long,
330328
}
331-
332-
#[cfg(target_arch = "mips")]
333-
pub struct stat {
334-
st_dev: c_ulong,
335-
st_pad1: [c_long, ..3],
336-
st_ino: ino_t,
337-
st_mode: mode_t,
338-
st_nlink: nlink_t,
339-
st_uid: uid_t,
340-
st_gid: gid_t,
341-
st_rdev: c_ulong,
342-
st_pad2: [c_long, ..2],
343-
st_size: off_t,
344-
st_pad3: c_long,
345-
st_atime: time_t,
346-
st_atime_nsec: c_long,
347-
st_mtime: time_t,
348-
st_mtime_nsec: c_long,
349-
st_ctime: time_t,
350-
st_ctime_nsec: c_long,
351-
st_blksize: blksize_t,
352-
st_blocks: blkcnt_t,
353-
st_pad5: [c_long, ..14],
354-
}
355329
}
356330
#[cfg(target_arch = "arm")]
357331
pub mod posix01 {
@@ -385,6 +359,40 @@ pub mod types {
385359
st_ino: c_ulonglong
386360
}
387361
}
362+
#[cfg(target_arch = "mips")]
363+
pub mod posix01 {
364+
use libc::types::os::arch::c95::{c_long, c_ulong, time_t};
365+
use libc::types::os::arch::posix88::{gid_t, ino_t};
366+
use libc::types::os::arch::posix88::{mode_t, off_t};
367+
use libc::types::os::arch::posix88::{uid_t};
368+
369+
pub type nlink_t = u32;
370+
pub type blksize_t = i32;
371+
pub type blkcnt_t = i32;
372+
373+
pub struct stat {
374+
st_dev: c_ulong,
375+
st_pad1: [c_long, ..3],
376+
st_ino: ino_t,
377+
st_mode: mode_t,
378+
st_nlink: nlink_t,
379+
st_uid: uid_t,
380+
st_gid: gid_t,
381+
st_rdev: c_ulong,
382+
st_pad2: [c_long, ..2],
383+
st_size: off_t,
384+
st_pad3: c_long,
385+
st_atime: time_t,
386+
st_atime_nsec: c_long,
387+
st_mtime: time_t,
388+
st_mtime_nsec: c_long,
389+
st_ctime: time_t,
390+
st_ctime_nsec: c_long,
391+
st_blksize: blksize_t,
392+
st_blocks: blkcnt_t,
393+
st_pad5: [c_long, ..14],
394+
}
395+
}
388396
pub mod posix08 {}
389397
pub mod bsd44 {}
390398
pub mod extra {}
@@ -1633,6 +1641,111 @@ pub mod consts {
16331641
pub static EPIPE : c_int = 32;
16341642
pub static EDOM : c_int = 33;
16351643
pub static ERANGE : c_int = 34;
1644+
1645+
pub static ENOMSG: c_int = 35;
1646+
pub static EIDRM: c_int = 36;
1647+
pub static ECHRNG: c_int = 37;
1648+
pub static EL2NSYNC: c_int = 38;
1649+
pub static EL3HLT: c_int = 39;
1650+
pub static EL3RST: c_int = 40;
1651+
pub static ELNRNG: c_int = 41;
1652+
pub static EUNATCH: c_int = 42;
1653+
pub static ENOCSI: c_int = 43;
1654+
pub static EL2HLT: c_int = 44;
1655+
pub static EDEADLK: c_int = 45;
1656+
pub static ENOLCK: c_int = 46;
1657+
pub static EBADE: c_int = 50;
1658+
pub static EBADR: c_int = 51;
1659+
pub static EXFULL: c_int = 52;
1660+
pub static ENOANO: c_int = 53;
1661+
pub static EBADRQC: c_int = 54;
1662+
pub static EBADSLT: c_int = 55;
1663+
pub static EDEADLOCK: c_int = 56;
1664+
pub static EBFONT: c_int = 59;
1665+
pub static ENOSTR: c_int = 60;
1666+
pub static ENODATA: c_int = 61;
1667+
pub static ETIME: c_int = 62;
1668+
pub static ENOSR: c_int = 63;
1669+
pub static ENONET: c_int = 64;
1670+
pub static ENOPKG: c_int = 65;
1671+
pub static EREMOTE: c_int = 66;
1672+
pub static ENOLINK: c_int = 67;
1673+
pub static EADV: c_int = 68;
1674+
pub static ESRMNT: c_int = 69;
1675+
pub static ECOMM: c_int = 70;
1676+
pub static EPROTO: c_int = 71;
1677+
pub static EDOTDOT: c_int = 73;
1678+
pub static EMULTIHOP: c_int = 74;
1679+
pub static EBADMSG: c_int = 77;
1680+
pub static ENAMETOOLONG: c_int = 78;
1681+
pub static EOVERFLOW: c_int = 79;
1682+
pub static ENOTUNIQ: c_int = 80;
1683+
pub static EBADFD: c_int = 81;
1684+
pub static EREMCHG: c_int = 82;
1685+
pub static ELIBACC: c_int = 83;
1686+
pub static ELIBBAD: c_int = 84;
1687+
pub static ELIBSCN: c_int = 95;
1688+
pub static ELIBMAX: c_int = 86;
1689+
pub static ELIBEXEC: c_int = 87;
1690+
pub static EILSEQ: c_int = 88;
1691+
pub static ENOSYS: c_int = 89;
1692+
pub static ELOOP: c_int = 90;
1693+
pub static ERESTART: c_int = 91;
1694+
pub static ESTRPIPE: c_int = 92;
1695+
pub static ENOTEMPTY: c_int = 93;
1696+
pub static EUSERS: c_int = 94;
1697+
pub static ENOTSOCK: c_int = 95;
1698+
pub static EDESTADDRREQ: c_int = 96;
1699+
pub static EMSGSIZE: c_int = 97;
1700+
pub static EPROTOTYPE: c_int = 98;
1701+
pub static ENOPROTOOPT: c_int = 99;
1702+
pub static EPROTONOSUPPORT: c_int = 120;
1703+
pub static ESOCKTNOSUPPORT: c_int = 121;
1704+
pub static EOPNOTSUPP: c_int = 122;
1705+
pub static EPFNOSUPPORT: c_int = 123;
1706+
pub static EAFNOSUPPORT: c_int = 124;
1707+
pub static EADDRINUSE: c_int = 125;
1708+
pub static EADDRNOTAVAIL: c_int = 126;
1709+
pub static ENETDOWN: c_int = 127;
1710+
pub static ENETUNREACH: c_int = 128;
1711+
pub static ENETRESET: c_int = 129;
1712+
pub static ECONNABORTED: c_int = 130;
1713+
pub static ECONNRESET: c_int = 131;
1714+
pub static ENOBUFS: c_int = 132;
1715+
pub static EISCONN: c_int = 133;
1716+
pub static ENOTCONN: c_int = 134;
1717+
pub static EUCLEAN: c_int = 135;
1718+
pub static ENOTNAM: c_int = 137;
1719+
pub static ENAVAIL: c_int = 138;
1720+
pub static EISNAM: c_int = 139;
1721+
pub static EREMOTEIO: c_int = 140;
1722+
pub static ESHUTDOWN: c_int = 143;
1723+
pub static ETOOMANYREFS: c_int = 144;
1724+
pub static ETIMEDOUT: c_int = 145;
1725+
pub static ECONNREFUSED: c_int = 146;
1726+
pub static EHOSTDOWN: c_int = 147;
1727+
pub static EHOSTUNREACH: c_int = 148;
1728+
pub static EWOULDBLOCK: c_int = EAGAIN;
1729+
pub static EALREADY: c_int = 149;
1730+
pub static EINPROGRESS: c_int = 150;
1731+
pub static ESTALE: c_int = 151;
1732+
pub static ECANCELED: c_int = 158;
1733+
1734+
pub static ENOMEDIUM: c_int = 159;
1735+
pub static EMEDIUMTYPE: c_int = 160;
1736+
pub static ENOKEY: c_int = 161;
1737+
pub static EKEYEXPIRED: c_int = 162;
1738+
pub static EKEYREVOKED: c_int = 163;
1739+
pub static EKEYREJECTED: c_int = 164;
1740+
1741+
pub static EOWNERDEAD: c_int = 165;
1742+
pub static ENOTRECOVERABLE: c_int = 166;
1743+
1744+
pub static ERFKILL: c_int = 167;
1745+
1746+
pub static EHWPOISON: c_int = 168;
1747+
1748+
pub static EDQUOT: c_int = 1133;
16361749
}
16371750
pub mod posix01 {
16381751
use libc::types::os::arch::c95::c_int;

src/libstd/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ pub mod consts {
16591659
pub use os::consts::arm::*;
16601660
16611661
#[cfg(target_arch = "mips")]
1662-
use os::consts::mips::*;
1662+
pub use os::consts::mips::*;
16631663
16641664
pub mod unix {
16651665
pub static FAMILY: &'static str = "unix";

0 commit comments

Comments
 (0)