Skip to content

Commit 027eab2

Browse files
author
Jorge Aparicio
committed
initial support for s390x
A new target, `s390x-unknown-linux-gnu`, has been added to the compiler and can be used to build no_core/no_std Rust programs. Known limitations: - librustc_trans/cabi_s390x.rs is missing. This means no support for `extern "C" fn`. - No support for this arch in libc. This means std can be cross compiled for this target.
1 parent e07dd59 commit 027eab2

File tree

6 files changed

+40
-2
lines changed

6 files changed

+40
-2
lines changed

mk/cfg/s390x-unknown-linux-gnu.mk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target

src/bootstrap/native.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn llvm(build: &Build, target: &str) {
6565
.out_dir(&dst)
6666
.profile(if build.config.llvm_optimize {"Release"} else {"Debug"})
6767
.define("LLVM_ENABLE_ASSERTIONS", assertions)
68-
.define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC")
68+
.define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC;SystemZ")
6969
.define("LLVM_INCLUDE_EXAMPLES", "OFF")
7070
.define("LLVM_INCLUDE_TESTS", "OFF")
7171
.define("LLVM_INCLUDE_DOCS", "OFF")

src/librustc_back/target/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ supported_targets! {
132132
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
133133
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
134134
("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu),
135+
("s390x-unknown-linux-gnu", s390x_unknown_linux_gnu),
135136
("arm-unknown-linux-gnueabi", arm_unknown_linux_gnueabi),
136137
("arm-unknown-linux-gnueabihf", arm_unknown_linux_gnueabihf),
137138
("arm-unknown-linux-musleabi", arm_unknown_linux_musleabi),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let mut base = super::linux_base::opts();
15+
// NOTE(zEC12) matches C toolchain
16+
base.cpu = "zEC12".to_string();
17+
base.max_atomic_width = 64;
18+
19+
Ok(Target {
20+
llvm_target: "s390x-unknown-linux-gnu".to_string(),
21+
target_endian: "big".to_string(),
22+
target_pointer_width: "64".to_string(),
23+
data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".to_string(),
24+
arch: "s390x".to_string(),
25+
target_os: "linux".to_string(),
26+
target_env: "gnu".to_string(),
27+
target_vendor: "unknown".to_string(),
28+
options: base,
29+
})
30+
}

src/librustc_llvm/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn main() {
6666
let host = env::var("HOST").unwrap();
6767
let is_crossed = target != host;
6868

69-
let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl"];
69+
let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz"];
7070

7171
// FIXME: surely we don't need all these components, right? Stuff like mcjit
7272
// or interpreter the compiler itself never uses.

src/librustc_llvm/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ pub fn initialize_available_targets() {
428428
LLVMInitializePNaClTargetInfo,
429429
LLVMInitializePNaClTarget,
430430
LLVMInitializePNaClTargetMC);
431+
init_target!(llvm_component = "systemz",
432+
LLVMInitializeSystemZTargetInfo,
433+
LLVMInitializeSystemZTarget,
434+
LLVMInitializeSystemZTargetMC,
435+
LLVMInitializeSystemZAsmPrinter,
436+
LLVMInitializeSystemZAsmParser);
431437
}
432438

433439
pub fn last_error() -> Option<String> {

0 commit comments

Comments
 (0)