Skip to content

Commit

Permalink
Auto merge of #57243 - dingelish:master, r=sfackler
Browse files Browse the repository at this point in the history
Bound sgx target_env with fortanix as target_vendor

This PR adds `target_vendor` check, as discussed in issue [57231](#57231)

Signed-off-by: Yu Ding <dingelish@gmail.com>
  • Loading branch information
bors committed Jan 2, 2019
2 parents a36b960 + 20e0395 commit ec19464
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/libpanic_abort/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#![panic_runtime]
#![allow(unused_features)]

#![feature(cfg_target_vendor)]
#![feature(core_intrinsics)]
#![feature(libc)]
#![feature(nll)]
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@
#![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))]

#![default_lib_allocator]

Expand Down Expand Up @@ -347,7 +347,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`”
Expand Down
10 changes: 7 additions & 3 deletions src/libstd/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit ec19464

Please sign in to comment.