about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-01-15 04:06:25 +0000
committerbors <bors@rust-lang.org>2019-01-15 04:06:25 +0000
commit33e6df4b62237af312bf6e3f40a97f5bdc94949a (patch)
treea8cd44217ba1afaaa007bbc38b9e77e9632202b5 /src/libstd/sys
parentaea9f0aa976db2f5de28be3b6b287c6889cd926b (diff)
parent99fbd1bf110c1e62c0c22a0e2232bec4bf9fdd89 (diff)
downloadrust-33e6df4b62237af312bf6e3f40a97f5bdc94949a.tar.gz
rust-33e6df4b62237af312bf6e3f40a97f5bdc94949a.zip
Auto merge of #57130 - VardhanThigle:Vardhan/x86_64-fortanix-unknown-sgx-tier2_support, r=alexcrichton
Upgrade x86_64-fortanix-unknown-sgx platform support to tier 2

## Overview
1. This PR upgrades x86_64-fortanix-unknown-sgx platform support to tier 2 (std only) by setting up build automation for this target.
1. For supporting unwinding, this target needs to link to a port of LLVM's libunwind (more details could be found in #56979), which will be distributed along with the Rust binaries (similar to the extra musl objects)

### Building and copying libunwind:
We have added a new build script  (`build-x86_64-fortanix-unknown-sgx-toolchain.sh`) that will run while the container is built. This will build `libunwind.a` from git source.
While the container is built, the persistent volumes where obj/ gets created aren't yet mapped. As a workaround, we copy the built `libunwind.a` to  `obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-fortanix-unknown-sgx/lib/` after x.py runs.
 If any reviewer knows of a better solution, please do tell.

r? @Mark-Simulacrum
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/sgx/abi/entry.S10
-rw-r--r--src/libstd/sys/sgx/time.rs8
-rw-r--r--src/libstd/sys/sgx/waitqueue.rs1
3 files changed, 19 insertions, 0 deletions
diff --git a/src/libstd/sys/sgx/abi/entry.S b/src/libstd/sys/sgx/abi/entry.S
index 8dad6ee976f..ac7f95d4eae 100644
--- a/src/libstd/sys/sgx/abi/entry.S
+++ b/src/libstd/sys/sgx/abi/entry.S
@@ -4,6 +4,16 @@
 .global IMAGE_BASE
 IMAGE_BASE:
 
+.section ".note.x86_64-fortanix-unknown-sgx", "", @note
+    .align 4
+    .long 1f - 0f              /* name length (not including padding) */
+    .long 3f - 2f              /* desc length (not including padding) */
+    .long 1                    /* type = NT_VERSION */
+0:  .asciz "toolchain-version" /* name */
+1:  .align 4
+2:  .long 0                    /* desc - toolchain version number, 32-bit LE */
+3:  .align 4
+
 .section .rodata
 /*  The XSAVE area needs to be a large chunk of readable memory, but since we are */
 /*  going to restore everything to its initial state (XSTATE_BV=0), only certain */
diff --git a/src/libstd/sys/sgx/time.rs b/src/libstd/sys/sgx/time.rs
index 10fe72d5f68..407fe72b0e6 100644
--- a/src/libstd/sys/sgx/time.rs
+++ b/src/libstd/sys/sgx/time.rs
@@ -25,6 +25,14 @@ impl Instant {
     pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
         Some(Instant(self.0.checked_sub(*other)?))
     }
+
+    pub fn actually_monotonic() -> bool {
+        false
+    }
+
+    pub const fn zero() -> Instant {
+        Instant(Duration::from_secs(0))
+    }
 }
 
 impl SystemTime {
diff --git a/src/libstd/sys/sgx/waitqueue.rs b/src/libstd/sys/sgx/waitqueue.rs
index a4738208778..51c00a1433e 100644
--- a/src/libstd/sys/sgx/waitqueue.rs
+++ b/src/libstd/sys/sgx/waitqueue.rs
@@ -456,6 +456,7 @@ mod spin_mutex {
         }
     }
 
+    /// Lock the Mutex or return false.
     pub macro try_lock_or_false {
         ($e:expr) => {
             if let Some(v) = $e.try_lock() {