diff --git a/.gitmodules b/.gitmodules index 697b17a14bd3cbf3fac5edd31172ffc064b5cd83..4b874d7a8c256745582d00e0930f9668fad3d4bc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "src/llvm"] path = src/llvm - url = https://github.com/rust-lang/llvm.git - branch = master + url = https://gitlab.redox-os.org/redox-os/llvm.git + branch = aarch64 [submodule "src/rust-installer"] path = src/tools/rust-installer url = https://github.com/rust-lang/rust-installer.git diff --git a/src/librustc_target/spec/aarch64_unknown_redox.rs b/src/librustc_target/spec/aarch64_unknown_redox.rs new file mode 100644 index 0000000000000000000000000000000000000000..e85f90d8825fbe8796f500e9c249038ed8f919fb --- /dev/null +++ b/src/librustc_target/spec/aarch64_unknown_redox.rs @@ -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 spec::{LinkerFlavor, Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::redox_base::opts(); + base.max_atomic_width = Some(128); + + Ok(Target { + llvm_target: "aarch64-unknown-redox".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: "redox".to_string(), + target_env: "".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index c8af81c02ea4a48b5a8a72cd7e1307272532fd63..2b16104dde175d857796ef78d245d74b34b6dce8 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -363,6 +363,7 @@ fn $module() { ("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc), + ("aarch64-unknown-redox", aarch64_unknown_redox), ("x86_64-unknown-redox", x86_64_unknown_redox), ("i386-apple-ios", i386_apple_ios), diff --git a/src/librustc_target/spec/redox_base.rs b/src/librustc_target/spec/redox_base.rs index c28746a9363594e45e4891a3fe1a35a3c5884057..7d46db95927e310bcbe2c25ac6e36224251cc712 100644 --- a/src/librustc_target/spec/redox_base.rs +++ b/src/librustc_target/spec/redox_base.rs @@ -33,7 +33,7 @@ pub fn opts() -> TargetOptions { relocation_model: "static".to_string(), disable_redzone: true, eliminate_frame_pointer: false, - target_family: None, + target_family: Some("redox".to_string()), linker_is_gnu: true, has_elf_tls: true, .. Default::default() diff --git a/src/libstd/sys/redox/syscall/arch/aarch64.rs b/src/libstd/sys/redox/syscall/arch/aarch64.rs new file mode 100644 index 0000000000000000000000000000000000000000..662f428d04cff535d246e83a858f2c04fd0c25aa --- /dev/null +++ b/src/libstd/sys/redox/syscall/arch/aarch64.rs @@ -0,0 +1,77 @@ +use super::error::{Error, Result}; + +pub unsafe fn syscall0(mut a: usize) -> Result<usize> { + asm!("svc 0" + : "={x0}"(a) + : "{x8}"(a) + : "x0", "x8" + : "volatile"); + + Error::demux(a) +} + +pub unsafe fn syscall1(mut a: usize, b: usize) -> Result<usize> { + asm!("svc 0" + : "={x0}"(a) + : "{x8}"(a), "{x0}"(b) + : "x0", "x8" + : "volatile"); + + Error::demux(a) +} + +// Clobbers all registers - special for clone +pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result<usize> { + asm!("svc 0" + : "={x0}"(a) + : "{x8}"(a), "{x0}"(b) + : "memory", + "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", + "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", + "x16", "x17","x18", "x19", "x20", "x21", "x22", "x23", + "x24", "x25", "x26", "x27", "x28", "x29", "x30" + : "volatile"); + + Error::demux(a) +} + +pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result<usize> { + asm!("svc 0" + : "={x0}"(a) + : "{x8}"(a), "{x0}"(b), "{x1}"(c) + : "x0", "x1", "x8" + : "volatile"); + + Error::demux(a) +} + +pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result<usize> { + asm!("svc 0" + : "={x0}"(a) + : "{x8}"(a), "{x0}"(b), "{x1}"(c), "{x2}"(d) + : "x0", "x1", "x2", "x8" + : "volatile"); + + Error::demux(a) +} + +pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result<usize> { + asm!("svc 0" + : "={x0}"(a) + : "{x8}"(a), "{x0}"(b), "{x1}"(c), "{x2}"(d), "{x3}"(e) + : "x0", "x1", "x2", "x3", "x8" + : "volatile"); + + Error::demux(a) +} + +pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) + -> Result<usize> { + asm!("svc 0" + : "={x0}"(a) + : "{x8}"(a), "{x0}"(b), "{x1}"(c), "{x2}"(d), "{x3}"(e), "{x4}"(f) + : "x0", "x1", "x2", "x3", "x4", "x8" + : "volatile"); + + Error::demux(a) +} diff --git a/src/libstd/sys/redox/syscall/mod.rs b/src/libstd/sys/redox/syscall/mod.rs index ce789c269a7e0ab3bc5d0f88967101afc7c033bc..e292d46ca3335ff12fed20bfb27589ed48453538 100644 --- a/src/libstd/sys/redox/syscall/mod.rs +++ b/src/libstd/sys/redox/syscall/mod.rs @@ -19,6 +19,10 @@ #[path="arch/arm.rs"] mod arch; +#[cfg(target_arch = "aarch64")] +#[path="arch/aarch64.rs"] +mod arch; + #[cfg(target_arch = "x86")] #[path="arch/x86.rs"] mod arch; diff --git a/src/llvm b/src/llvm index 7051ead40a5f825878b59bf08d4e768be9e99a4a..f8d5116afe1ec40aa25fe485ffbfb36f47b8c7c3 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 7051ead40a5f825878b59bf08d4e768be9e99a4a +Subproject commit f8d5116afe1ec40aa25fe485ffbfb36f47b8c7c3 diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index f81964ccbc23c6405d4533fe5bd06865004bcd34..30b6babe9292cd7eaa607cf1e8ada49f04b2ea7e 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -51,6 +51,7 @@ "aarch64-unknown-cloudabi", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", + "aarch64-unknown-redox", "arm-linux-androideabi", "arm-unknown-linux-gnueabi", "arm-unknown-linux-gnueabihf",