Skip to content

Commit 7de7eb9

Browse files
authored
Unrolled build for rust-lang#120434
Rollup merge of rust-lang#120434 - fmease:revert-speeder, r=petrochenkov Revert outdated version of "Add the wasm32-wasi-preview2 target" An outdated version of rust-lang#119616 was merged in rollup rust-lang#120309. This reverts those changes to enable rust-lang#119616 to “retain the intended diff” after a rebase. ```@rylev``` has agreed that this would be the cleanest approach with respect to the history. Unblocks rust-lang#119616. r? ```@petrochenkov``` or compiler or libs
2 parents 5ad7454 + 9199742 commit 7de7eb9

File tree

18 files changed

+130
-334
lines changed

18 files changed

+130
-334
lines changed

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,6 @@ symbols! {
17891789
warn,
17901790
wasm_abi,
17911791
wasm_import_module,
1792-
wasm_preview2,
17931792
wasm_target_feature,
17941793
while_let,
17951794
windows,

compiler/rustc_target/src/spec/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,6 @@ supported_targets! {
15741574
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
15751575
("wasm32-unknown-unknown", wasm32_unknown_unknown),
15761576
("wasm32-wasi", wasm32_wasi),
1577-
("wasm32-wasi-preview2", wasm32_wasi_preview2),
15781577
("wasm32-wasi-preview1-threads", wasm32_wasi_preview1_threads),
15791578
("wasm64-unknown-unknown", wasm64_unknown_unknown),
15801579

compiler/rustc_target/src/spec/targets/wasm32_wasi_preview1_threads.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@
7272
//! best we can with this target. Don't start relying on too much here unless
7373
//! you know what you're getting in to!
7474
75-
use crate::spec::{base, crt_objects, cvs, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
75+
use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
7676

7777
pub fn target() -> Target {
7878
let mut options = base::wasm::options();
7979

80-
options.families = cvs!["wasm", "wasi"];
8180
options.os = "wasi".into();
8281

8382
options.add_pre_link_args(

compiler/rustc_target/src/spec/targets/wasm32_wasi_preview2.rs

-64
This file was deleted.

library/std/src/os/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ pub mod linux;
8585
#[cfg(any(target_os = "wasi", doc))]
8686
pub mod wasi;
8787

88-
#[cfg(any(all(target_os = "wasi", target_env = "preview2"), doc))]
89-
pub mod wasi_preview2;
90-
9188
// windows
9289
#[cfg(not(all(
9390
doc,

library/std/src/os/wasi/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
//! [`OsStr`]: crate::ffi::OsStr
2929
//! [`OsString`]: crate::ffi::OsString
3030
31-
#![cfg_attr(not(target_env = "preview2"), stable(feature = "rust1", since = "1.0.0"))]
32-
#![cfg_attr(target_env = "preview2", unstable(feature = "wasm_preview2", issue = "none"))]
31+
#![stable(feature = "rust1", since = "1.0.0")]
3332
#![deny(unsafe_op_in_unsafe_fn)]
3433
#![doc(cfg(target_os = "wasi"))]
3534

library/std/src/os/wasi_preview2/mod.rs

-5
This file was deleted.

library/std/src/sys/pal/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ cfg_if::cfg_if! {
4040
} else if #[cfg(target_os = "wasi")] {
4141
mod wasi;
4242
pub use self::wasi::*;
43-
} else if #[cfg(all(target_os = "wasi", target_env = "preview2"))] {
44-
mod wasi_preview2;
45-
pub use self::wasi_preview2::*;
4643
} else if #[cfg(target_family = "wasm")] {
4744
mod wasm;
4845
pub use self::wasm::*;

library/std/src/sys/pal/wasi/helpers.rs

-123
This file was deleted.

library/std/src/sys/pal/wasi/mod.rs

+123-9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
//! compiling for wasm. That way it's a compile time error for something that's
1515
//! guaranteed to be a runtime error!
1616
17+
use crate::io as std_io;
18+
use crate::mem;
19+
1720
#[path = "../unix/alloc.rs"]
1821
pub mod alloc;
1922
pub mod args;
@@ -69,12 +72,123 @@ cfg_if::cfg_if! {
6972
mod common;
7073
pub use common::*;
7174

72-
mod helpers;
73-
// These exports are listed individually to work around Rust's glob import
74-
// conflict rules. If we glob export `helpers` and `common` together, then
75-
// the compiler complains about conflicts.
76-
pub use helpers::abort_internal;
77-
pub use helpers::decode_error_kind;
78-
use helpers::err2io;
79-
pub use helpers::hashmap_random_keys;
80-
pub use helpers::is_interrupted;
75+
#[inline]
76+
pub fn is_interrupted(errno: i32) -> bool {
77+
errno == wasi::ERRNO_INTR.raw().into()
78+
}
79+
80+
pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
81+
use std_io::ErrorKind;
82+
83+
let Ok(errno) = u16::try_from(errno) else {
84+
return ErrorKind::Uncategorized;
85+
};
86+
87+
macro_rules! match_errno {
88+
($($($errno:ident)|+ => $errkind:ident),*, _ => $wildcard:ident $(,)?) => {
89+
match errno {
90+
$(e if $(e == ::wasi::$errno.raw())||+ => ErrorKind::$errkind),*,
91+
_ => ErrorKind::$wildcard,
92+
}
93+
};
94+
}
95+
96+
match_errno! {
97+
ERRNO_2BIG => ArgumentListTooLong,
98+
ERRNO_ACCES => PermissionDenied,
99+
ERRNO_ADDRINUSE => AddrInUse,
100+
ERRNO_ADDRNOTAVAIL => AddrNotAvailable,
101+
ERRNO_AFNOSUPPORT => Unsupported,
102+
ERRNO_AGAIN => WouldBlock,
103+
// ALREADY => "connection already in progress",
104+
// BADF => "bad file descriptor",
105+
// BADMSG => "bad message",
106+
ERRNO_BUSY => ResourceBusy,
107+
// CANCELED => "operation canceled",
108+
// CHILD => "no child processes",
109+
ERRNO_CONNABORTED => ConnectionAborted,
110+
ERRNO_CONNREFUSED => ConnectionRefused,
111+
ERRNO_CONNRESET => ConnectionReset,
112+
ERRNO_DEADLK => Deadlock,
113+
// DESTADDRREQ => "destination address required",
114+
ERRNO_DOM => InvalidInput,
115+
// DQUOT => /* reserved */,
116+
ERRNO_EXIST => AlreadyExists,
117+
// FAULT => "bad address",
118+
ERRNO_FBIG => FileTooLarge,
119+
ERRNO_HOSTUNREACH => HostUnreachable,
120+
// IDRM => "identifier removed",
121+
// ILSEQ => "illegal byte sequence",
122+
// INPROGRESS => "operation in progress",
123+
ERRNO_INTR => Interrupted,
124+
ERRNO_INVAL => InvalidInput,
125+
ERRNO_IO => Uncategorized,
126+
// ISCONN => "socket is connected",
127+
ERRNO_ISDIR => IsADirectory,
128+
ERRNO_LOOP => FilesystemLoop,
129+
// MFILE => "file descriptor value too large",
130+
ERRNO_MLINK => TooManyLinks,
131+
// MSGSIZE => "message too large",
132+
// MULTIHOP => /* reserved */,
133+
ERRNO_NAMETOOLONG => InvalidFilename,
134+
ERRNO_NETDOWN => NetworkDown,
135+
// NETRESET => "connection aborted by network",
136+
ERRNO_NETUNREACH => NetworkUnreachable,
137+
// NFILE => "too many files open in system",
138+
// NOBUFS => "no buffer space available",
139+
ERRNO_NODEV => NotFound,
140+
ERRNO_NOENT => NotFound,
141+
// NOEXEC => "executable file format error",
142+
// NOLCK => "no locks available",
143+
// NOLINK => /* reserved */,
144+
ERRNO_NOMEM => OutOfMemory,
145+
// NOMSG => "no message of the desired type",
146+
// NOPROTOOPT => "protocol not available",
147+
ERRNO_NOSPC => StorageFull,
148+
ERRNO_NOSYS => Unsupported,
149+
ERRNO_NOTCONN => NotConnected,
150+
ERRNO_NOTDIR => NotADirectory,
151+
ERRNO_NOTEMPTY => DirectoryNotEmpty,
152+
// NOTRECOVERABLE => "state not recoverable",
153+
// NOTSOCK => "not a socket",
154+
ERRNO_NOTSUP => Unsupported,
155+
// NOTTY => "inappropriate I/O control operation",
156+
ERRNO_NXIO => NotFound,
157+
// OVERFLOW => "value too large to be stored in data type",
158+
// OWNERDEAD => "previous owner died",
159+
ERRNO_PERM => PermissionDenied,
160+
ERRNO_PIPE => BrokenPipe,
161+
// PROTO => "protocol error",
162+
ERRNO_PROTONOSUPPORT => Unsupported,
163+
// PROTOTYPE => "protocol wrong type for socket",
164+
// RANGE => "result too large",
165+
ERRNO_ROFS => ReadOnlyFilesystem,
166+
ERRNO_SPIPE => NotSeekable,
167+
ERRNO_SRCH => NotFound,
168+
// STALE => /* reserved */,
169+
ERRNO_TIMEDOUT => TimedOut,
170+
ERRNO_TXTBSY => ResourceBusy,
171+
ERRNO_XDEV => CrossesDevices,
172+
ERRNO_NOTCAPABLE => PermissionDenied,
173+
_ => Uncategorized,
174+
}
175+
}
176+
177+
pub fn abort_internal() -> ! {
178+
unsafe { libc::abort() }
179+
}
180+
181+
pub fn hashmap_random_keys() -> (u64, u64) {
182+
let mut ret = (0u64, 0u64);
183+
unsafe {
184+
let base = &mut ret as *mut (u64, u64) as *mut u8;
185+
let len = mem::size_of_val(&ret);
186+
wasi::random_get(base, len).expect("random_get failure");
187+
}
188+
return ret;
189+
}
190+
191+
#[inline]
192+
fn err2io(err: wasi::Errno) -> std_io::Error {
193+
std_io::Error::from_raw_os_error(err.raw().into())
194+
}

0 commit comments

Comments
 (0)