about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2017-12-26 15:18:58 +0800
committerGitHub <noreply@github.com>2017-12-26 15:18:58 +0800
commit720a4b53f5c79be6072166e22fd3aa81104d91f2 (patch)
treec1b8cb0144a5755fa4851afa5a4bfd1cb389aa28 /src
parent32016d5eb1e102657763c4080b0a4085db8eba6a (diff)
parent41567525fe4e0efaf3fd2483af5b7800e7befbcf (diff)
downloadrust-720a4b53f5c79be6072166e22fd3aa81104d91f2.tar.gz
rust-720a4b53f5c79be6072166e22fd3aa81104d91f2.zip
Rollup merge of #46940 - EdSchouten:cloudabi, r=alexcrichton
Add support for CloudABI targets to the rustc backend.

CloudABI is a sandboxed UNIX-like runtime environment. It is a
programming environment that uses a capability-based security model. In
practice this means that many POSIX interfaces are present, except for
ones that try to access resources out of thin air. For example, open()
is gone, but openat() is present.

Right now I'm at the point where I can compile very basic CloudABI
applications on all four supported architectures (ARM and x86, 32 and 64
bits). The next step will be to get libstd to work. Patches for that are
outside the scope of this change.

More info: https://nuxi.nl/cloudabi/ https://github.com/NuxiNL/cloudlibc/
Diffstat (limited to 'src')
-rw-r--r--src/librustc_back/target/aarch64_unknown_cloudabi.rs32
-rw-r--r--src/librustc_back/target/armv7_unknown_cloudabi_eabihf.rs34
-rw-r--r--src/librustc_back/target/cloudabi_base.rs34
-rw-r--r--src/librustc_back/target/i686_unknown_cloudabi.rs34
-rw-r--r--src/librustc_back/target/mod.rs6
-rw-r--r--src/librustc_back/target/x86_64_unknown_cloudabi.rs34
-rw-r--r--src/tools/build-manifest/src/main.rs8
7 files changed, 180 insertions, 2 deletions
diff --git a/src/librustc_back/target/aarch64_unknown_cloudabi.rs b/src/librustc_back/target/aarch64_unknown_cloudabi.rs
new file mode 100644
index 00000000000..d5e8194c3f7
--- /dev/null
+++ b/src/librustc_back/target/aarch64_unknown_cloudabi.rs
@@ -0,0 +1,32 @@
+// Copyright 2017 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 LinkerFlavor;
+use target::{Target, TargetResult};
+
+pub fn target() -> TargetResult {
+    let mut base = super::cloudabi_base::opts();
+    base.max_atomic_width = Some(128);
+    base.abi_blacklist = super::arm_base::abi_blacklist();
+
+    Ok(Target {
+        llvm_target: "aarch64-unknown-cloudabi".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "64".to_string(),
+        target_c_int_width: "32".to_string(),
+        data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
+        arch: "aarch64".to_string(),
+        target_os: "cloudabi".to_string(),
+        target_env: "".to_string(),
+        target_vendor: "unknown".to_string(),
+        linker_flavor: LinkerFlavor::Gcc,
+        options: base,
+    })
+}
diff --git a/src/librustc_back/target/armv7_unknown_cloudabi_eabihf.rs b/src/librustc_back/target/armv7_unknown_cloudabi_eabihf.rs
new file mode 100644
index 00000000000..4dad8e1713b
--- /dev/null
+++ b/src/librustc_back/target/armv7_unknown_cloudabi_eabihf.rs
@@ -0,0 +1,34 @@
+// Copyright 2017 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 LinkerFlavor;
+use target::{Target, TargetResult};
+
+pub fn target() -> TargetResult {
+    let mut base = super::cloudabi_base::opts();
+    base.cpu = "cortex-a8".to_string();
+    base.max_atomic_width = Some(64);
+    base.features = "+v7,+vfp3,+neon".to_string();
+    base.abi_blacklist = super::arm_base::abi_blacklist();
+
+    Ok(Target {
+        llvm_target: "armv7-unknown-cloudabi-eabihf".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "32".to_string(),
+        target_c_int_width: "32".to_string(),
+        data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
+        arch: "arm".to_string(),
+        target_os: "cloudabi".to_string(),
+        target_env: "".to_string(),
+        target_vendor: "unknown".to_string(),
+        linker_flavor: LinkerFlavor::Gcc,
+        options: base,
+    })
+}
diff --git a/src/librustc_back/target/cloudabi_base.rs b/src/librustc_back/target/cloudabi_base.rs
new file mode 100644
index 00000000000..c29130bdf8e
--- /dev/null
+++ b/src/librustc_back/target/cloudabi_base.rs
@@ -0,0 +1,34 @@
+// Copyright 2017 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 LinkerFlavor;
+use target::{LinkArgs, TargetOptions, RelroLevel};
+use std::default::Default;
+
+pub fn opts() -> TargetOptions {
+    let mut args = LinkArgs::new();
+    args.insert(LinkerFlavor::Gcc, vec![
+        "-Wl,-Bstatic".to_string(),
+        "-Wl,--no-dynamic-linker".to_string(),
+        "-Wl,--eh-frame-hdr".to_string(),
+        "-Wl,--gc-sections".to_string(),
+    ]);
+
+    TargetOptions {
+        executables: true,
+        target_family: Some("unix".to_string()),
+        linker_is_gnu: true,
+        pre_link_args: args,
+        position_independent_executables: true,
+        relro_level: RelroLevel::Full,
+        exe_allocation_crate: super::maybe_jemalloc(),
+        .. Default::default()
+    }
+}
diff --git a/src/librustc_back/target/i686_unknown_cloudabi.rs b/src/librustc_back/target/i686_unknown_cloudabi.rs
new file mode 100644
index 00000000000..b9aa6176d87
--- /dev/null
+++ b/src/librustc_back/target/i686_unknown_cloudabi.rs
@@ -0,0 +1,34 @@
+// Copyright 2017 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 LinkerFlavor;
+use target::{Target, TargetResult};
+
+pub fn target() -> TargetResult {
+    let mut base = super::cloudabi_base::opts();
+    base.cpu = "pentium4".to_string();
+    base.max_atomic_width = Some(64);
+    base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string());
+    base.stack_probes = true;
+
+    Ok(Target {
+        llvm_target: "i686-unknown-cloudabi".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "32".to_string(),
+        target_c_int_width: "32".to_string(),
+        data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
+        arch: "x86".to_string(),
+        target_os: "cloudabi".to_string(),
+        target_env: "".to_string(),
+        target_vendor: "unknown".to_string(),
+        linker_flavor: LinkerFlavor::Gcc,
+        options: base,
+    })
+}
diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs
index 6f9ba5dada2..5c18e82fe3a 100644
--- a/src/librustc_back/target/mod.rs
+++ b/src/librustc_back/target/mod.rs
@@ -57,6 +57,7 @@ mod apple_base;
 mod apple_ios_base;
 mod arm_base;
 mod bitrig_base;
+mod cloudabi_base;
 mod dragonfly_base;
 mod emscripten_base;
 mod freebsd_base;
@@ -227,6 +228,11 @@ supported_targets! {
     ("thumbv7em-none-eabihf", thumbv7em_none_eabihf),
 
     ("msp430-none-elf", msp430_none_elf),
+
+    ("aarch64-unknown-cloudabi", aarch64_unknown_cloudabi),
+    ("armv7-unknown-cloudabi-eabihf", armv7_unknown_cloudabi_eabihf),
+    ("i686-unknown-cloudabi", i686_unknown_cloudabi),
+    ("x86_64-unknown-cloudabi", x86_64_unknown_cloudabi),
 }
 
 /// Everything `rustc` knows about how to compile for a specific target.
diff --git a/src/librustc_back/target/x86_64_unknown_cloudabi.rs b/src/librustc_back/target/x86_64_unknown_cloudabi.rs
new file mode 100644
index 00000000000..f9a563174d4
--- /dev/null
+++ b/src/librustc_back/target/x86_64_unknown_cloudabi.rs
@@ -0,0 +1,34 @@
+// Copyright 2017 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 LinkerFlavor;
+use target::{Target, TargetResult};
+
+pub fn target() -> TargetResult {
+    let mut base = super::cloudabi_base::opts();
+    base.cpu = "x86-64".to_string();
+    base.max_atomic_width = Some(64);
+    base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
+    base.stack_probes = true;
+
+    Ok(Target {
+        llvm_target: "x86_64-unknown-cloudabi".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "64".to_string(),
+        target_c_int_width: "32".to_string(),
+        data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
+        arch: "x86_64".to_string(),
+        target_os: "cloudabi".to_string(),
+        target_env: "".to_string(),
+        target_vendor: "unknown".to_string(),
+        linker_flavor: LinkerFlavor::Gcc,
+        options: base,
+    })
+}
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs
index 371bbd16a5e..fc2759df447 100644
--- a/src/tools/build-manifest/src/main.rs
+++ b/src/tools/build-manifest/src/main.rs
@@ -46,8 +46,9 @@ static HOSTS: &'static [&'static str] = &[
 
 static TARGETS: &'static [&'static str] = &[
     "aarch64-apple-ios",
-    "aarch64-unknown-fuchsia",
     "aarch64-linux-android",
+    "aarch64-unknown-cloudabi",
+    "aarch64-unknown-fuchsia",
     "aarch64-unknown-linux-gnu",
     "aarch64-unknown-linux-musl",
     "arm-linux-androideabi",
@@ -58,6 +59,7 @@ static TARGETS: &'static [&'static str] = &[
     "armv5te-unknown-linux-gnueabi",
     "armv7-apple-ios",
     "armv7-linux-androideabi",
+    "armv7-unknown-cloudabi-eabihf",
     "armv7-unknown-linux-gnueabihf",
     "armv7-unknown-linux-musleabihf",
     "armv7s-apple-ios",
@@ -69,6 +71,7 @@ static TARGETS: &'static [&'static str] = &[
     "i686-linux-android",
     "i686-pc-windows-gnu",
     "i686-pc-windows-msvc",
+    "i686-unknown-cloudabi",
     "i686-unknown-freebsd",
     "i686-unknown-linux-gnu",
     "i686-unknown-linux-musl",
@@ -86,13 +89,14 @@ static TARGETS: &'static [&'static str] = &[
     "sparcv9-sun-solaris",
     "wasm32-unknown-emscripten",
     "wasm32-unknown-unknown",
-    "x86_64-linux-android",
     "x86_64-apple-darwin",
     "x86_64-apple-ios",
+    "x86_64-linux-android",
     "x86_64-pc-windows-gnu",
     "x86_64-pc-windows-msvc",
     "x86_64-rumprun-netbsd",
     "x86_64-sun-solaris",
+    "x86_64-unknown-cloudabi",
     "x86_64-unknown-freebsd",
     "x86_64-unknown-fuchsia",
     "x86_64-unknown-linux-gnu",