From f1971456d19349f3143a1e57d384f878caf61717 Mon Sep 17 00:00:00 2001 From: Nicole L Date: Tue, 31 Jan 2023 11:38:40 -0800 Subject: [PATCH] Revert libstd support for Trusty --- Cargo.toml | 2 - library/core/src/ffi/mod.rs | 4 - library/std/build.rs | 1 - library/std/src/sys/mod.rs | 3 - library/std/src/sys/trusty/mod.rs | 42 ---------- library/std/src/sys/trusty/stdio.rs | 81 ------------------- .../std/src/sys/trusty/thread_local_key.rs | 31 ------- library/std/src/sys_common/mod.rs | 1 - src/bootstrap/lib.rs | 3 +- 9 files changed, 1 insertion(+), 167 deletions(-) delete mode 100644 library/std/src/sys/trusty/mod.rs delete mode 100644 library/std/src/sys/trusty/stdio.rs delete mode 100644 library/std/src/sys/trusty/thread_local_key.rs diff --git a/Cargo.toml b/Cargo.toml index 0d42210f0f67e..15cbb2659c9b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,7 +115,5 @@ rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' } rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' } rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' } -libc = { git = "https://github.com/randomPoison/libc.git", rev = "7ccd2753aa1e26301c73bdb6f9e2df8085ac39e6" } - [patch."https://github.com/rust-lang/rust-clippy"] clippy_lints = { path = "src/tools/clippy/clippy_lints" } diff --git a/library/core/src/ffi/mod.rs b/library/core/src/ffi/mod.rs index c83d45520ab2d..76daceecd7bef 100644 --- a/library/core/src/ffi/mod.rs +++ b/library/core/src/ffi/mod.rs @@ -144,10 +144,6 @@ mod c_char_definition { ) ), all(target_os = "fuchsia", target_arch = "aarch64"), - all( - target_os = "trusty", - any(target_arch = "aarch64", target_arch = "arm") - ), target_os = "horizon" ))] { pub type c_char = u8; diff --git a/library/std/build.rs b/library/std/build.rs index c0594b9b176e3..8b1a06ee750fb 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -21,7 +21,6 @@ fn main() { || target.contains("fuchsia") || (target.contains("sgx") && target.contains("fortanix")) || target.contains("hermit") - || target.contains("trusty") || target.contains("l4re") || target.contains("redox") || target.contains("haiku") diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index acd483f243f84..c080c176a2ace 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -37,9 +37,6 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "hermit")] { mod hermit; pub use self::hermit::*; - } else if #[cfg(target_os = "trusty")] { - mod trusty; - pub use self::trusty::*; } else if #[cfg(target_os = "wasi")] { mod wasi; pub use self::wasi::*; diff --git a/library/std/src/sys/trusty/mod.rs b/library/std/src/sys/trusty/mod.rs deleted file mode 100644 index 9e97c315e450c..0000000000000 --- a/library/std/src/sys/trusty/mod.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! System bindings for the Trusty OS. - -#[path = "../unix/alloc.rs"] -pub mod alloc; -#[path = "../unsupported/args.rs"] -pub mod args; -#[path = "../unix/cmath.rs"] -pub mod cmath; -#[path = "../unsupported/common.rs"] -#[deny(unsafe_op_in_unsafe_fn)] -mod common; -#[path = "../unsupported/env.rs"] -pub mod env; -#[path = "../unsupported/fs.rs"] -pub mod fs; -#[path = "../unsupported/io.rs"] -pub mod io; -#[path = "../unsupported/locks/mod.rs"] -pub mod locks; -#[path = "../unsupported/net.rs"] -pub mod net; -#[path = "../unsupported/os.rs"] -pub mod os; -#[path = "../unix/os_str.rs"] -pub mod os_str; -#[path = "../unix/path.rs"] -pub mod path; -#[path = "../unsupported/pipe.rs"] -pub mod pipe; -#[path = "../unsupported/process.rs"] -pub mod process; -pub mod stdio; -#[path = "../unsupported/thread.rs"] -pub mod thread; -#[cfg(target_thread_local)] -#[path = "../unsupported/thread_local_dtor.rs"] -pub mod thread_local_dtor; -pub mod thread_local_key; -#[path = "../unsupported/time.rs"] -pub mod time; - -pub use common::*; diff --git a/library/std/src/sys/trusty/stdio.rs b/library/std/src/sys/trusty/stdio.rs deleted file mode 100644 index d393e95394d1a..0000000000000 --- a/library/std/src/sys/trusty/stdio.rs +++ /dev/null @@ -1,81 +0,0 @@ -use crate::io; - -pub struct Stdin; -pub struct Stdout; -pub struct Stderr; - -impl Stdin { - pub const fn new() -> Stdin { - Stdin - } -} - -impl io::Read for Stdin { - fn read(&mut self, _buf: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Stdout { - pub const fn new() -> Stdout { - Stdout - } -} - -impl io::Write for Stdout { - fn write(&mut self, buf: &[u8]) -> io::Result { - _write(libc::STDOUT_FILENO, buf) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl Stderr { - pub const fn new() -> Stderr { - Stderr - } -} - -impl io::Write for Stderr { - fn write(&mut self, buf: &[u8]) -> io::Result { - _write(libc::STDERR_FILENO, buf) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -pub const STDIN_BUF_SIZE: usize = 0; - -pub fn is_ebadf(_err: &io::Error) -> bool { - true -} - -pub fn panic_output() -> Option { - Some(Stderr) -} - -fn _write(fd: i32, message: &[u8]) -> io::Result { - let mut iov = libc::iovec { iov_base: message.as_ptr() as *mut _, iov_len: message.len() }; - loop { - // SAFETY: syscall, safe arguments. - let ret = unsafe { libc::writev(fd, &iov, 1) }; - if ret < 0 { - return Err(io::Error::last_os_error()); - } - let ret = ret as usize; - if ret > iov.iov_len { - return Err(io::Error::last_os_error()); - } - if ret == iov.iov_len { - return Ok(message.len()); - } - // SAFETY: ret has been checked to be less than the length of - // the buffer - iov.iov_base = unsafe { iov.iov_base.add(ret) }; - iov.iov_len -= ret; - } -} diff --git a/library/std/src/sys/trusty/thread_local_key.rs b/library/std/src/sys/trusty/thread_local_key.rs deleted file mode 100644 index 56e14f71367ac..0000000000000 --- a/library/std/src/sys/trusty/thread_local_key.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::ptr; - -pub type Key = usize; -type Dtor = unsafe extern "C" fn(*mut u8); - -static mut STORAGE: crate::vec::Vec<(*mut u8, Option)> = Vec::new(); - -#[inline] -pub unsafe fn create(dtor: Option) -> Key { - let key = STORAGE.len(); - STORAGE.push((ptr::null_mut(), dtor)); - key -} - -#[inline] -pub unsafe fn set(key: Key, value: *mut u8) { - STORAGE[key].0 = value; -} - -#[inline] -pub unsafe fn get(key: Key) -> *mut u8 { - STORAGE[key].0 -} - -#[inline] -pub unsafe fn destroy(_key: Key) {} - -#[inline] -pub fn requires_synchronized_create() -> bool { - false -} diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs index 753979c529cef..6b24b0e9aa8be 100644 --- a/library/std/src/sys_common/mod.rs +++ b/library/std/src/sys_common/mod.rs @@ -45,7 +45,6 @@ cfg_if::cfg_if! { cfg_if::cfg_if! { if #[cfg(any(target_os = "l4re", target_os = "hermit", - target_os = "trusty", feature = "restricted-std", all(target_family = "wasm", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))] { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 9b14164d8ee99..267aa3278d8ff 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -213,8 +213,7 @@ const EXTRA_CHECK_CFGS: &[(Option, &'static str, Option<&[&'static str]>)] (Some(Mode::Std), "backtrace_in_libstd", None), /* Extra values not defined in the built-in targets yet, but used in std */ (Some(Mode::Std), "target_env", Some(&["libnx"])), - // #[cfg(bootstrap)] trusty - (Some(Mode::Std), "target_os", Some(&["trusty"])), + // (Some(Mode::Std), "target_os", Some(&[])), (Some(Mode::Std), "target_arch", Some(&["asmjs", "spirv", "nvptx", "xtensa"])), /* Extra names used by dependencies */ // FIXME: Used by serde_json, but we should not be triggering on external dependencies.