Skip to content

Commit 6d7e86d

Browse files
committed
fix MIPS target
I ignored AtomicU64 methods on MIPS target because libgcc doesn't implement MIPS32 64-bit atomic operations. Otherwise it would cause link failure.
1 parent b4d3243 commit 6d7e86d

File tree

7 files changed

+38
-43
lines changed

7 files changed

+38
-43
lines changed

src/libgreen/context.rs

+2
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
283283
unsafe { *sp = 0; }
284284

285285
regs[4] = arg as uint;
286+
regs[5] = procedure.code as uint;
287+
regs[6] = procedure.env as uint;
286288
regs[29] = sp as uint;
287289
regs[25] = fptr as uint;
288290
regs[31] = fptr as uint;

src/librustc/back/mips.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,39 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
2222

2323
data_layout: match target_os {
2424
abi::OsMacos => {
25-
~"e-p:32:32:32" +
25+
~"E-p:32:32:32" +
2626
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
2727
"-f32:32:32-f64:64:64" +
2828
"-v64:64:64-v128:64:128" +
2929
"-a0:0:64-n32"
3030
}
3131

3232
abi::OsWin32 => {
33-
~"e-p:32:32:32" +
33+
~"E-p:32:32:32" +
3434
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
3535
"-f32:32:32-f64:64:64" +
3636
"-v64:64:64-v128:64:128" +
3737
"-a0:0:64-n32"
3838
}
3939

4040
abi::OsLinux => {
41-
~"e-p:32:32:32" +
41+
~"E-p:32:32:32" +
4242
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
4343
"-f32:32:32-f64:64:64" +
4444
"-v64:64:64-v128:64:128" +
4545
"-a0:0:64-n32"
4646
}
4747

4848
abi::OsAndroid => {
49-
~"e-p:32:32:32" +
49+
~"E-p:32:32:32" +
5050
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
5151
"-f32:32:32-f64:64:64" +
5252
"-v64:64:64-v128:64:128" +
5353
"-a0:0:64-n32"
5454
}
5555

5656
abi::OsFreebsd => {
57-
~"e-p:32:32:32" +
57+
~"E-p:32:32:32" +
5858
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
5959
"-f32:32:32-f64:64:64" +
6060
"-v64:64:64-v128:64:128" +

src/libstd/libc.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ pub mod consts {
21332133
pub static MAP_SHARED : c_int = 0x0001;
21342134
pub static MAP_PRIVATE : c_int = 0x0002;
21352135
pub static MAP_FIXED : c_int = 0x0010;
2136-
pub static MAP_ANON : c_int = 0x0020;
2136+
pub static MAP_ANON : c_int = 0x0800;
21372137

21382138
pub static MAP_FAILED : *c_void = -1 as *c_void;
21392139

@@ -2425,20 +2425,19 @@ pub mod consts {
24252425
pub static O_DSYNC : c_int = 16;
24262426
pub static O_SYNC : c_int = 16400;
24272427

2428-
pub static PROT_GROWSDOWN : c_int = 0x010000000;
2429-
pub static PROT_GROWSUP : c_int = 0x020000000;
2428+
pub static PROT_GROWSDOWN : c_int = 0x01000000;
2429+
pub static PROT_GROWSUP : c_int = 0x02000000;
24302430

24312431
pub static MAP_TYPE : c_int = 0x000f;
2432-
pub static MAP_ANONONYMOUS : c_int = 0x0020;
2433-
pub static MAP_32BIT : c_int = 0x0040;
2434-
pub static MAP_GROWSDOWN : c_int = 0x0100;
2435-
pub static MAP_DENYWRITE : c_int = 0x0800;
2436-
pub static MAP_EXECUTABLE : c_int = 0x01000;
2437-
pub static MAP_LOCKED : c_int = 0x02000;
2438-
pub static MAP_NONRESERVE : c_int = 0x04000;
2439-
pub static MAP_POPULATE : c_int = 0x08000;
2440-
pub static MAP_NONBLOCK : c_int = 0x010000;
2441-
pub static MAP_STACK : c_int = 0x020000;
2432+
pub static MAP_ANONONYMOUS : c_int = 0x0800;
2433+
pub static MAP_GROWSDOWN : c_int = 0x01000;
2434+
pub static MAP_DENYWRITE : c_int = 0x02000;
2435+
pub static MAP_EXECUTABLE : c_int = 0x04000;
2436+
pub static MAP_LOCKED : c_int = 0x08000;
2437+
pub static MAP_NONRESERVE : c_int = 0x0400;
2438+
pub static MAP_POPULATE : c_int = 0x010000;
2439+
pub static MAP_NONBLOCK : c_int = 0x020000;
2440+
pub static MAP_STACK : c_int = 0x040000;
24422441
}
24432442
#[cfg(target_os = "linux")]
24442443
pub mod sysconf {

src/libstd/rt/libunwind.rs

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ pub static unwinder_private_data_size: int = 2;
6565
#[cfg(target_arch = "arm")]
6666
pub static unwinder_private_data_size: int = 20;
6767

68+
#[cfg(target_arch = "mips")]
69+
pub static unwinder_private_data_size: int = 2;
70+
6871
pub struct _Unwind_Exception {
6972
exception_class: _Unwind_Exception_Class,
7073
exception_cleanup: _Unwind_Exception_Cleanup_Fn,

src/libstd/sync/atomics.rs

+4
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ impl AtomicInt {
225225
}
226226
}
227227

228+
// temporary workaround
229+
// it causes link failure on MIPS target
230+
// libgcc doesn't implement 64-bit atomic operations for MIPS32
231+
#[cfg(not(target_arch = "mips"))]
228232
impl AtomicU64 {
229233
pub fn new(v: u64) -> AtomicU64 {
230234
AtomicU64 { v:v, nopod: marker::NoPod }

src/libstd/unstable/mutex.rs

+4
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,16 @@ mod imp {
324324
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
325325
#[cfg(target_arch = "arm")]
326326
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
327+
#[cfg(target_arch = "mips")]
328+
static __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8;
327329
#[cfg(target_arch = "x86_64")]
328330
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
329331
#[cfg(target_arch = "x86")]
330332
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
331333
#[cfg(target_arch = "arm")]
332334
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
335+
#[cfg(target_arch = "mips")]
336+
static __SIZEOF_PTHREAD_COND_T: uint = 48 - 8;
333337

334338
pub struct pthread_mutex_t {
335339
__align: libc::c_longlong,

src/rt/arch/mips/morestack.S

+8-25
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,21 @@ __morestack:
1919
.set noreorder
2020
.set nomacro
2121

22-
// n.b. most of this is probably unnecessary. I know very little mips
23-
// assembly, and I didn't have anything to test on, so I wasn't
24-
// brave enough to try to trim this down.
22+
addiu $29, $29, -4
23+
sw $30, 0($29)
2524

26-
addiu $29, $29, -12
27-
sw $31, 8($29)
28-
sw $30, 4($29)
29-
sw $23, 0($29)
30-
31-
// 24 = 12 (current) + 12 (previous)
32-
.cfi_def_cfa_offset 24
25+
// 16 = 4 (current) + 12 (previous)
26+
.cfi_def_cfa_offset 16
3327
.cfi_offset 31, -4
34-
.cfi_offset 30, -20
35-
.cfi_offset 23, -24
28+
.cfi_offset 30, -16
3629

37-
move $23, $28
3830
move $30, $29
3931
.cfi_def_cfa_register 30
4032

41-
// Save argument registers of the original function
42-
addiu $29, $29, -32
43-
sw $4, 16($29)
44-
sw $5, 20($29)
45-
sw $6, 24($29)
46-
sw $7, 28($29)
47-
48-
move $4, $14 // Size of stack arguments
49-
addu $5, $30, 24 // Address of stack arguments
50-
move $6, $15 // The amount of stack needed
33+
// O32 ABI always reserves 16 bytes for arguments
34+
addiu $29, $29, -16
5135

52-
move $28, $23
53-
lw $25, %call16(rust_stack_exhausted)($23)
36+
lw $25, %call16(rust_stack_exhausted)($28)
5437
jalr $25
5538
nop
5639

0 commit comments

Comments
 (0)