Skip to content

Commit 4a35056

Browse files
author
Jethro Beekman
committed
Add x86_64-fortanix-unknown-sgx target to libstd and dependencies
The files src/libstd/sys/sgx/*.rs are mostly copied/adapted from the wasm target. This also updates the dlmalloc submodule to the very latest version.
1 parent c559216 commit 4a35056

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2873
-15
lines changed

.gitmodules

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@
6161
path = src/tools/clang
6262
url = https://github.com/rust-lang-nursery/clang.git
6363
branch = rust-release-80-v2
64-
6564
[submodule "src/doc/rustc-guide"]
6665
path = src/doc/rustc-guide
6766
url = https://github.com/rust-lang/rustc-guide.git
6867
[submodule "src/doc/edition-guide"]
6968
path = src/doc/edition-guide
7069
url = https://github.com/rust-lang-nursery/edition-guide
70+
[submodule "src/rust-sgx"]
71+
path = src/rust-sgx
72+
url = https://github.com/fortanix/rust-sgx

Cargo.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,14 @@ name = "foreign-types-shared"
797797
version = "0.1.1"
798798
source = "registry+https://github.com/rust-lang/crates.io-index"
799799

800+
[[package]]
801+
name = "fortanix-sgx-abi"
802+
version = "0.0.0"
803+
dependencies = [
804+
"compiler_builtins 0.0.0",
805+
"core 0.0.0",
806+
]
807+
800808
[[package]]
801809
name = "fs2"
802810
version = "0.4.3"
@@ -2773,6 +2781,7 @@ dependencies = [
27732781
"compiler_builtins 0.0.0",
27742782
"core 0.0.0",
27752783
"dlmalloc 0.0.0",
2784+
"fortanix-sgx-abi 0.0.0",
27762785
"libc 0.0.0",
27772786
"panic_abort 0.0.0",
27782787
"panic_unwind 0.0.0",

src/bootstrap/dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ impl Step for Src {
874874
"src/rustc/compiler_builtins_shim",
875875
"src/rustc/libc_shim",
876876
"src/rustc/dlmalloc_shim",
877+
"src/rustc/fortanix-sgx-abi_shim",
877878
"src/libtest",
878879
"src/libterm",
879880
"src/libprofiler_builtins",

src/liblibc

Submodule liblibc updated 65 files

src/libpanic_abort/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ pub unsafe extern fn __rust_start_panic(_payload: usize) -> u32 {
6666
unsafe fn abort() -> ! {
6767
core::intrinsics::abort();
6868
}
69+
70+
#[cfg(target_env="sgx")]
71+
unsafe fn abort() -> ! {
72+
extern "C" { pub fn panic_exit() -> !; }
73+
panic_exit();
74+
}
6975
}
7076

7177
// This... is a bit of an oddity. The tl;dr; is that this is required to link

src/libpanic_unwind/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ cfg_if! {
6262
if #[cfg(target_os = "emscripten")] {
6363
#[path = "emcc.rs"]
6464
mod imp;
65-
} else if #[cfg(target_arch = "wasm32")] {
65+
} else if #[cfg(any(target_arch = "wasm32", target_env = "sgx"))] {
6666
#[path = "dummy.rs"]
6767
mod imp;
6868
} else if #[cfg(all(target_env = "msvc", target_arch = "aarch64"))] {

src/libstd/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ rustc_lsan = { path = "../librustc_lsan" }
3535
rustc_msan = { path = "../librustc_msan" }
3636
rustc_tsan = { path = "../librustc_tsan" }
3737

38-
[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies]
38+
[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), target_env = "sgx"))'.dependencies]
3939
dlmalloc = { path = '../rustc/dlmalloc_shim' }
4040

41+
[target.x86_64-fortanix-unknown-sgx.dependencies]
42+
fortanix-sgx-abi = { path = "../rustc/fortanix-sgx-abi_shim" }
43+
4144
[build-dependencies]
4245
cc = "1.0"
4346
build_helper = { path = "../build_helper" }

src/libstd/io/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub enum ErrorKind {
184184
}
185185

186186
impl ErrorKind {
187-
fn as_str(&self) -> &'static str {
187+
pub(crate) fn as_str(&self) -> &'static str {
188188
match *self {
189189
ErrorKind::NotFound => "entity not found",
190190
ErrorKind::PermissionDenied => "permission denied",

src/libstd/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@
312312
#![feature(non_exhaustive)]
313313
#![feature(alloc_layout_extra)]
314314
#![feature(maybe_uninit)]
315+
#![cfg_attr(target_env = "sgx", feature(global_asm, range_contains))]
315316

316317
#![default_lib_allocator]
317318

@@ -354,6 +355,12 @@ extern crate unwind;
354355
// testing gives test-std access to real-std lang items and globals. See #2912
355356
#[cfg(test)] extern crate std as realstd;
356357

358+
#[cfg(target_env = "sgx")]
359+
#[macro_use]
360+
#[allow(unused_imports)] // FIXME: without `#[macro_use]`, get error: “cannot
361+
// determine resolution for the macro `usercalls_asm`”
362+
extern crate fortanix_sgx_abi;
363+
357364
// The standard macros that are not built-in to the compiler.
358365
#[macro_use]
359366
mod macros;

src/libstd/sys/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ cfg_if! {
4848
} else if #[cfg(target_arch = "wasm32")] {
4949
mod wasm;
5050
pub use self::wasm::*;
51+
} else if #[cfg(target_env = "sgx")] {
52+
mod sgx;
53+
pub use self::sgx::*;
5154
} else {
5255
compile_error!("libstd doesn't compile for this platform yet");
5356
}

0 commit comments

Comments
 (0)