Skip to content

Commit ec19464

Browse files
committed
Auto merge of #57243 - dingelish:master, r=sfackler
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 <[email protected]>
2 parents a36b960 + 20e0395 commit ec19464

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

Diff for: src/libpanic_abort/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![panic_runtime]
1313
#![allow(unused_features)]
1414

15+
#![feature(cfg_target_vendor)]
1516
#![feature(core_intrinsics)]
1617
#![feature(libc)]
1718
#![feature(nll)]
@@ -57,7 +58,7 @@ pub unsafe extern fn __rust_start_panic(_payload: usize) -> u32 {
5758
core::intrinsics::abort();
5859
}
5960

60-
#[cfg(target_env="sgx")]
61+
#[cfg(all(target_vendor="fortanix", target_env="sgx"))]
6162
unsafe fn abort() -> ! {
6263
extern "C" { pub fn panic_exit() -> !; }
6364
panic_exit();

Diff for: src/libstd/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ rustc_lsan = { path = "../librustc_lsan" }
3737
rustc_msan = { path = "../librustc_msan" }
3838
rustc_tsan = { path = "../librustc_tsan" }
3939

40-
[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), target_env = "sgx"))'.dependencies]
40+
[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
4141
dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
4242

4343
[target.x86_64-fortanix-unknown-sgx.dependencies]

Diff for: src/libstd/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@
302302
#![feature(non_exhaustive)]
303303
#![feature(alloc_layout_extra)]
304304
#![feature(maybe_uninit)]
305-
#![cfg_attr(target_env = "sgx", feature(global_asm, range_contains, slice_index_methods,
306-
decl_macro, coerce_unsized, sgx_platform,
307-
min_const_unsafe_fn))]
305+
#![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"),
306+
feature(global_asm, range_contains, slice_index_methods,
307+
decl_macro, coerce_unsized, sgx_platform))]
308308

309309
#![default_lib_allocator]
310310

@@ -347,7 +347,7 @@ extern crate backtrace_sys;
347347
// testing gives test-std access to real-std lang items and globals. See #2912
348348
#[cfg(test)] extern crate std as realstd;
349349

350-
#[cfg(target_env = "sgx")]
350+
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
351351
#[macro_use]
352352
#[allow(unused_imports)] // FIXME: without `#[macro_use]`, get error: “cannot
353353
// determine resolution for the macro `usercalls_asm`”

Diff for: src/libstd/sys/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cfg_if! {
3838
} else if #[cfg(target_arch = "wasm32")] {
3939
mod wasm;
4040
pub use self::wasm::*;
41-
} else if #[cfg(target_env = "sgx")] {
41+
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
4242
mod sgx;
4343
pub use self::sgx::*;
4444
} else {
@@ -55,7 +55,9 @@ cfg_if! {
5555
if #[cfg(any(unix, target_os = "redox"))] {
5656
// On unix we'll document what's already available
5757
pub use self::ext as unix_ext;
58-
} else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32", target_env = "sgx"))] {
58+
} else if #[cfg(any(target_os = "cloudabi",
59+
target_arch = "wasm32",
60+
all(target_vendor = "fortanix", target_env = "sgx")))] {
5961
// On CloudABI and wasm right now the module below doesn't compile
6062
// (missing things in `libc` which is empty) so just omit everything
6163
// with an empty module
@@ -76,7 +78,9 @@ cfg_if! {
7678
// On windows we'll just be documenting what's already available
7779
#[allow(missing_docs)]
7880
pub use self::ext as windows_ext;
79-
} else if #[cfg(any(target_os = "cloudabi", target_arch = "wasm32", target_env = "sgx"))] {
81+
} else if #[cfg(any(target_os = "cloudabi",
82+
target_arch = "wasm32",
83+
all(target_vendor = "fortanix", target_env = "sgx")))] {
8084
// On CloudABI and wasm right now the shim below doesn't compile, so
8185
// just omit it
8286
#[unstable(issue = "0", feature = "std_internals")]

Diff for: src/libstd/sys_common/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ cfg_if! {
5151
target_os = "l4re",
5252
target_os = "redox",
5353
all(target_arch = "wasm32", not(target_os = "emscripten")),
54-
target_env = "sgx"))] {
54+
all(target_vendor = "fortanix", target_env = "sgx")))] {
5555
pub use sys::net;
5656
} else {
5757
pub mod net;

Diff for: src/libtest/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2424
html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
2525
#![feature(asm)]
26+
#![feature(cfg_target_vendor)]
2627
#![feature(fnbox)]
2728
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
2829
#![feature(nll)]
@@ -1015,7 +1016,7 @@ fn use_color(opts: &TestOpts) -> bool {
10151016
#[cfg(any(target_os = "cloudabi",
10161017
target_os = "redox",
10171018
all(target_arch = "wasm32", not(target_os = "emscripten")),
1018-
target_env = "sgx"))]
1019+
all(target_vendor = "fortanix", target_env = "sgx")))]
10191020
fn stdout_isatty() -> bool {
10201021
// FIXME: Implement isatty on Redox and SGX
10211022
false
@@ -1246,7 +1247,8 @@ fn get_concurrency() -> usize {
12461247
1
12471248
}
12481249

1249-
#[cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), target_env = "sgx"))]
1250+
#[cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")),
1251+
all(target_vendor = "fortanix", target_env = "sgx")))]
12501252
fn num_cpus() -> usize {
12511253
1
12521254
}

0 commit comments

Comments
 (0)