]> git.lizzy.rs Git - rust.git/commitdiff
initial support for s390x
authorJorge Aparicio <japaricious@gmail.com>
Sat, 27 Aug 2016 02:05:16 +0000 (21:05 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Sat, 27 Aug 2016 02:05:50 +0000 (21:05 -0500)
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.

mk/cfg/s390x-unknown-linux-gnu.mk [new file with mode: 0644]
src/bootstrap/native.rs
src/librustc_back/target/mod.rs
src/librustc_back/target/s390x_unknown_linux_gnu.rs [new file with mode: 0644]
src/librustc_llvm/build.rs
src/librustc_llvm/lib.rs

diff --git a/mk/cfg/s390x-unknown-linux-gnu.mk b/mk/cfg/s390x-unknown-linux-gnu.mk
new file mode 100644 (file)
index 0000000..34aee77
--- /dev/null
@@ -0,0 +1 @@
+# rustbuild-only target
index a78cef4f409b43e1001b209459eb4604e0ff3a5c..a4518d6ed7619159c204480905c49175f0460ffc 100644 (file)
@@ -65,7 +65,7 @@ pub fn llvm(build: &Build, target: &str) {
        .out_dir(&dst)
        .profile(if build.config.llvm_optimize {"Release"} else {"Debug"})
        .define("LLVM_ENABLE_ASSERTIONS", assertions)
-       .define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC")
+       .define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC;SystemZ")
        .define("LLVM_INCLUDE_EXAMPLES", "OFF")
        .define("LLVM_INCLUDE_TESTS", "OFF")
        .define("LLVM_INCLUDE_DOCS", "OFF")
index 86cd86d282cf5d121842cdb4d3581f9c1f5b7597..86325cfe5449fa2753130c491b6823799876652d 100644 (file)
@@ -132,6 +132,7 @@ fn $module() {
     ("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
     ("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
     ("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu),
+    ("s390x-unknown-linux-gnu", s390x_unknown_linux_gnu),
     ("arm-unknown-linux-gnueabi", arm_unknown_linux_gnueabi),
     ("arm-unknown-linux-gnueabihf", arm_unknown_linux_gnueabihf),
     ("arm-unknown-linux-musleabi", arm_unknown_linux_musleabi),
diff --git a/src/librustc_back/target/s390x_unknown_linux_gnu.rs b/src/librustc_back/target/s390x_unknown_linux_gnu.rs
new file mode 100644 (file)
index 0000000..895d33d
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use target::{Target, TargetResult};
+
+pub fn target() -> TargetResult {
+    let mut base = super::linux_base::opts();
+    // NOTE(zEC12) matches C toolchain
+    base.cpu = "zEC12".to_string();
+    base.max_atomic_width = 64;
+
+    Ok(Target {
+        llvm_target: "s390x-unknown-linux-gnu".to_string(),
+        target_endian: "big".to_string(),
+        target_pointer_width: "64".to_string(),
+        data_layout: "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64".to_string(),
+        arch: "s390x".to_string(),
+        target_os: "linux".to_string(),
+        target_env: "gnu".to_string(),
+        target_vendor: "unknown".to_string(),
+        options: base,
+    })
+}
index 5f7a0f788ca1289e8da69b9e001289622041af8b..ac83d860b6e90a52cc6cd0bd662c37359aa8c0af 100644 (file)
@@ -66,7 +66,7 @@ fn main() {
     let host = env::var("HOST").unwrap();
     let is_crossed = target != host;
 
-    let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl"];
+    let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl", "systemz"];
 
     // FIXME: surely we don't need all these components, right? Stuff like mcjit
     //        or interpreter the compiler itself never uses.
index 6c4e1a54ea7281b4ff3d0ae55f9c3ac7c9337e76..eb45d3d25c5c05f5ff71a713d57c039626cac426 100644 (file)
@@ -428,6 +428,12 @@ fn init() { }
                  LLVMInitializePNaClTargetInfo,
                  LLVMInitializePNaClTarget,
                  LLVMInitializePNaClTargetMC);
+    init_target!(llvm_component = "systemz",
+                 LLVMInitializeSystemZTargetInfo,
+                 LLVMInitializeSystemZTarget,
+                 LLVMInitializeSystemZTargetMC,
+                 LLVMInitializeSystemZAsmPrinter,
+                 LLVMInitializeSystemZAsmParser);
 }
 
 pub fn last_error() -> Option<String> {