Skip to content

Commit 689c6c4

Browse files
authored
Auto merge of #36024 - japaric:mips64, r=alexcrichton
add mips64-gnu and mips64el-gnu targets With this commit one can build no_core (and probably no_std as well) Rust programs for these targets. It's not yet possible to cross compile std for these targets because rust-lang/libc doesn't know about the mips64 architecture. These targets have been tested by cross compiling the "smallest hello" program (see code below) and then running it under QEMU. ``` rust extern { fn puts(_: *const u8); } fn start(_: isize, _: *const *const u8) -> isize { unsafe { let msg = b"Hello, world!\0"; puts(msg as *const _ as *const u8); } 0 } trait Copy {} trait Sized {} ``` cc #36015 r? @alexcrichton cc @brson The cabi stuff is likely wrong. I just copied cabi_mips source and changed some `4`s to `8`s and `32`s to `64`s. It was enough to get libc's `puts` to work but I'd like someone familiar with this module to check it.
2 parents 022cb6d + bbf2c3c commit 689c6c4

File tree

16 files changed

+259
-14
lines changed

16 files changed

+259
-14
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target

src/liballoc_jemalloc/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ const MIN_ALIGN: usize = 8;
7777
#[cfg(all(any(target_arch = "x86",
7878
target_arch = "x86_64",
7979
target_arch = "aarch64",
80-
target_arch = "powerpc64")))]
80+
target_arch = "powerpc64",
81+
target_arch = "mips64")))]
8182
const MIN_ALIGN: usize = 16;
8283

8384
// MALLOCX_ALIGN(a) macro

src/liballoc_system/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
target_arch = "asmjs")))]
3333
const MIN_ALIGN: usize = 8;
3434
#[cfg(all(any(target_arch = "x86_64",
35-
target_arch = "aarch64")))]
35+
target_arch = "aarch64",
36+
target_arch = "mips64")))]
3637
const MIN_ALIGN: usize = 16;
3738

3839
#[no_mangle]

src/liblibc

Submodule liblibc updated 48 files

src/libpanic_unwind/gcc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const UNWIND_DATA_REG: (i32, i32) = (0, 1); // RAX, RDX
124124
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
125125
const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1 / X0, X1
126126

127-
#[cfg(any(target_arch = "mips", target_arch = "mipsel"))]
127+
#[cfg(any(target_arch = "mips", target_arch = "mipsel", target_arch = "mips64"))]
128128
const UNWIND_DATA_REG: (i32, i32) = (4, 5); // A0, A1
129129

130130
#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2016 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, TargetOptions, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
Ok(Target {
15+
llvm_target: "mips64-unknown-linux-gnuabi64".to_string(),
16+
target_endian: "big".to_string(),
17+
target_pointer_width: "64".to_string(),
18+
data_layout: "E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(),
19+
arch: "mips64".to_string(),
20+
target_os: "linux".to_string(),
21+
target_env: "gnu".to_string(),
22+
target_vendor: "unknown".to_string(),
23+
options: TargetOptions {
24+
// NOTE(mips64r2) matches C toolchain
25+
cpu: "mips64r2".to_string(),
26+
features: "+mips64r2".to_string(),
27+
max_atomic_width: 64,
28+
..super::linux_base::opts()
29+
},
30+
})
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2016 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, TargetOptions, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
Ok(Target {
15+
llvm_target: "mips64el-unknown-linux-gnuabi64".to_string(),
16+
target_endian: "little".to_string(),
17+
target_pointer_width: "64".to_string(),
18+
data_layout: "e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128".to_string(),
19+
arch: "mips64".to_string(),
20+
target_os: "linux".to_string(),
21+
target_env: "gnu".to_string(),
22+
target_vendor: "unknown".to_string(),
23+
options: TargetOptions {
24+
// NOTE(mips64r2) matches C toolchain
25+
cpu: "mips64r2".to_string(),
26+
features: "+mips64r2".to_string(),
27+
max_atomic_width: 64,
28+
..super::linux_base::opts()
29+
},
30+
})
31+
}

src/librustc_back/target/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ supported_targets! {
128128
("i686-unknown-linux-gnu", i686_unknown_linux_gnu),
129129
("i586-unknown-linux-gnu", i586_unknown_linux_gnu),
130130
("mips-unknown-linux-gnu", mips_unknown_linux_gnu),
131+
("mips64-unknown-linux-gnuabi64", mips64_unknown_linux_gnuabi64),
132+
("mips64el-unknown-linux-gnuabi64", mips64el_unknown_linux_gnuabi64),
131133
("mipsel-unknown-linux-gnu", mipsel_unknown_linux_gnu),
132134
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
133135
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),

src/librustc_trans/abi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use cabi_aarch64;
2121
use cabi_powerpc;
2222
use cabi_powerpc64;
2323
use cabi_mips;
24+
use cabi_mips64;
2425
use cabi_asmjs;
2526
use machine::{llalign_of_min, llsize_of, llsize_of_real, llsize_of_store};
2627
use type_::Type;
@@ -501,6 +502,7 @@ impl FnType {
501502
cabi_arm::compute_abi_info(ccx, self, flavor);
502503
},
503504
"mips" => cabi_mips::compute_abi_info(ccx, self),
505+
"mips64" => cabi_mips64::compute_abi_info(ccx, self),
504506
"powerpc" => cabi_powerpc::compute_abi_info(ccx, self),
505507
"powerpc64" => cabi_powerpc64::compute_abi_info(ccx, self),
506508
"asmjs" => cabi_asmjs::compute_abi_info(ccx, self),

0 commit comments

Comments
 (0)