From d04f5208ba67c90e145438b459f99f2d634026ae Mon Sep 17 00:00:00 2001 From: Yu Ding Date: Mon, 31 Dec 2018 15:45:42 -0800 Subject: [PATCH 1/2] Bound sgx target_env with fortanix as target_vendor Signed-off-by: Yu Ding --- src/libpanic_abort/lib.rs | 3 ++- src/libstd/Cargo.toml | 2 +- src/libstd/lib.rs | 9 +++++---- src/libstd/sys/mod.rs | 10 +++++++--- src/libstd/sys_common/mod.rs | 2 +- src/libtest/lib.rs | 6 ++++-- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index 4a22b69eda80b..d8dd2e0a11337 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -12,6 +12,7 @@ #![panic_runtime] #![allow(unused_features)] +#![feature(cfg_target_vendor)] #![feature(core_intrinsics)] #![feature(libc)] #![feature(nll)] @@ -57,7 +58,7 @@ pub unsafe extern fn __rust_start_panic(_payload: usize) -> u32 { core::intrinsics::abort(); } - #[cfg(target_env="sgx")] + #[cfg(all(target_vendor="fortanix", target_env="sgx"))] unsafe fn abort() -> ! { extern "C" { pub fn panic_exit() -> !; } panic_exit(); diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 5214f365a6476..92876f7f2d804 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -37,7 +37,7 @@ rustc_lsan = { path = "../librustc_lsan" } rustc_msan = { path = "../librustc_msan" } rustc_tsan = { path = "../librustc_tsan" } -[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), target_env = "sgx"))'.dependencies] +[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies] dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] } [target.x86_64-fortanix-unknown-sgx.dependencies] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 6ded43dfed1f4..3b7e8291d3851 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -302,9 +302,10 @@ #![feature(non_exhaustive)] #![feature(alloc_layout_extra)] #![feature(maybe_uninit)] -#![cfg_attr(target_env = "sgx", feature(global_asm, range_contains, slice_index_methods, - decl_macro, coerce_unsized, sgx_platform, - min_const_unsafe_fn))] +#![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"), + feature(global_asm, range_contains, slice_index_methods, + decl_macro, coerce_unsized, sgx_platform, + min_const_unsafe_fn))] #![default_lib_allocator] @@ -347,7 +348,7 @@ extern crate backtrace_sys; // testing gives test-std access to real-std lang items and globals. See #2912 #[cfg(test)] extern crate std as realstd; -#[cfg(target_env = "sgx")] +#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] #[macro_use] #[allow(unused_imports)] // FIXME: without `#[macro_use]`, get error: “cannot // determine resolution for the macro `usercalls_asm`” diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs index de9e09bf7057e..f398a2a6225ce 100644 --- a/src/libstd/sys/mod.rs +++ b/src/libstd/sys/mod.rs @@ -38,7 +38,7 @@ cfg_if! { } else if #[cfg(target_arch = "wasm32")] { mod wasm; pub use self::wasm::*; - } else if #[cfg(target_env = "sgx")] { + } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { mod sgx; pub use self::sgx::*; } else { @@ -55,7 +55,9 @@ cfg_if! { if #[cfg(any(unix, target_os = "redox"))] { // On unix we'll document what's already available pub use self::ext as unix_ext; - } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32", target_env = "sgx"))] { + } else if #[cfg(any(target_os = "cloudabi", + target_arch = "wasm32", + all(target_vendor = "fortanix", target_env = "sgx")))] { // On CloudABI and wasm right now the module below doesn't compile // (missing things in `libc` which is empty) so just omit everything // with an empty module @@ -76,7 +78,9 @@ cfg_if! { // On windows we'll just be documenting what's already available #[allow(missing_docs)] pub use self::ext as windows_ext; - } else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32", target_env = "sgx"))] { + } else if #[cfg(any(target_os = "cloudabi", + target_arch = "wasm32", + all(target_vendor = "fortanix", target_env = "sgx")))] { // On CloudABI and wasm right now the shim below doesn't compile, so // just omit it #[unstable(issue = "0", feature = "std_internals")] diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs index ee3916b35f9c9..c18b603a6356c 100644 --- a/src/libstd/sys_common/mod.rs +++ b/src/libstd/sys_common/mod.rs @@ -51,7 +51,7 @@ cfg_if! { target_os = "l4re", target_os = "redox", all(target_arch = "wasm32", not(target_os = "emscripten")), - target_env = "sgx"))] { + all(target_vendor = "fortanix", target_env = "sgx")))] { pub use sys::net; } else { pub mod net; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 4e227745a793f..ec96ea067082f 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -23,6 +23,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] #![feature(asm)] +#![feature(cfg_target_vendor)] #![feature(fnbox)] #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))] #![feature(nll)] @@ -1015,7 +1016,7 @@ fn use_color(opts: &TestOpts) -> bool { #[cfg(any(target_os = "cloudabi", target_os = "redox", all(target_arch = "wasm32", not(target_os = "emscripten")), - target_env = "sgx"))] + all(target_vendor = "fortanix", target_env = "sgx")))] fn stdout_isatty() -> bool { // FIXME: Implement isatty on Redox and SGX false @@ -1246,7 +1247,8 @@ fn get_concurrency() -> usize { 1 } - #[cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), target_env = "sgx"))] + #[cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), + all(target_vendor = "fortanix", target_env = "sgx")))] fn num_cpus() -> usize { 1 } From a3128116d258d2d715f55062f25ab9debe79be14 Mon Sep 17 00:00:00 2001 From: Yu Ding Date: Tue, 1 Jan 2019 11:49:54 -0800 Subject: [PATCH 2/2] Remove min_const_unsafe_fn since it is stable Signed-off-by: Yu Ding --- src/libstd/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 3b7e8291d3851..d42e39f16e663 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -304,8 +304,7 @@ #![feature(maybe_uninit)] #![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"), feature(global_asm, range_contains, slice_index_methods, - decl_macro, coerce_unsized, sgx_platform, - min_const_unsafe_fn))] + decl_macro, coerce_unsized, sgx_platform))] #![default_lib_allocator]