diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7e1269bd1..601b37911 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -232,7 +232,6 @@ jobs: - name: Prepare repository for redox compilation run: bash scripts/redox/uncomment-cargo.sh - name: Check compilation for Redox - if: false # FIXME: redoxer toolchain is from ~july 2021, edition2021 isn't stabilized uses: coolreader18/redoxer-action@v1 with: command: check diff --git a/Cargo.lock b/Cargo.lock index 43a5d9d7b..e30c9d165 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1123,9 +1123,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libffi" @@ -1337,18 +1337,6 @@ dependencies = [ "memoffset 0.6.5", ] -[[package]] -name = "nix" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" -dependencies = [ - "autocfg", - "bitflags", - "cfg-if", - "libc", -] - [[package]] name = "nix" version = "0.26.2" @@ -2281,9 +2269,9 @@ checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" [[package]] name = "rustyline" -version = "10.1.1" +version = "11.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e83c32c3f3c33b08496e0d1df9ea8c64d39adb8eb36a1ebb1440c690697aef" +checksum = "5dfc8644681285d1fb67a467fb3021bfea306b99b4146b166a1fe3ada965eece" dependencies = [ "bitflags", "cfg-if", @@ -2293,7 +2281,7 @@ dependencies = [ "libc", "log", "memchr", - "nix 0.25.1", + "nix 0.26.2", "radix_trie", "scopeguard", "unicode-segmentation", diff --git a/Cargo.toml b/Cargo.toml index 57adb7053..1cdcce0db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,3 @@ -# REDOX START -# cargo-features = ["edition2021"] -# REDOX END [package] name = "rustpython" version = "0.2.0" @@ -49,7 +46,7 @@ once_cell = "1.13" parking_lot = "0.12" paste = "1.0.7" rand = "0.8.5" -rustyline = "10.0.0" +rustyline = "11" serde = "1.0" schannel = "0.1.19" static_assertions = "1.1" @@ -131,4 +128,7 @@ lto = "thin" [patch.crates-io] # REDOX START, Uncomment when you want to compile/check with redoxer +# nix = { git = "https://github.com/coolreader18/nix", branch = "0.26.2-redox" } +# errno = { git = "https://github.com/coolreader18/rust-errno", branch = "0.2.8-redox" } +# libc = { git = "https://github.com/rust-lang/libc" } # REDOX END diff --git a/stdlib/Cargo.toml b/stdlib/Cargo.toml index a78ab448f..3c421c62f 100644 --- a/stdlib/Cargo.toml +++ b/stdlib/Cargo.toml @@ -77,7 +77,7 @@ flate2 = "1.0.23" bzip2 = { version = "0.4", optional = true } # uuid -[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32")))'.dependencies] +[target.'cfg(not(any(target_os = "ios", target_os = "android", target_os = "windows", target_arch = "wasm32", target_os = "redox")))'.dependencies] mac_address = "1.1.3" uuid = { version = "1.1.2", features = ["v1", "fast-rng", "macro-diagnostics"] } diff --git a/stdlib/src/lib.rs b/stdlib/src/lib.rs index 33ba6d875..c78f74449 100644 --- a/stdlib/src/lib.rs +++ b/stdlib/src/lib.rs @@ -30,7 +30,7 @@ mod statistics; mod bz2; #[cfg(not(target_arch = "wasm32"))] pub mod socket; -#[cfg(unix)] +#[cfg(all(unix, not(target_os = "redox")))] mod syslog; mod unicodedata; mod zlib; @@ -62,7 +62,8 @@ mod termios; target_os = "android", target_os = "ios", target_os = "windows", - target_arch = "wasm32" + target_arch = "wasm32", + target_os = "redox", )))] mod uuid; @@ -138,11 +139,11 @@ pub fn get_module_inits() -> impl Iterator, StdlibInit #[cfg(unix)] { "_posixsubprocess" => posixsubprocess::make_module, - "syslog" => syslog::make_module, "mmap" => mmap::make_module, } #[cfg(all(unix, not(target_os = "redox")))] { + "syslog" => syslog::make_module, "resource" => resource::make_module, } #[cfg(all(unix, not(any(target_os = "ios", target_os = "redox"))))] @@ -157,7 +158,7 @@ pub fn get_module_inits() -> impl Iterator, StdlibInit { "_scproxy" => scproxy::make_module, } - #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "windows", target_arch = "wasm32")))] + #[cfg(not(any(target_os = "android", target_os = "ios", target_os = "windows", target_arch = "wasm32", target_os = "redox")))] { "_uuid" => uuid::make_module, } diff --git a/stdlib/src/locale.rs b/stdlib/src/locale.rs index f0c88d688..bbe1008e5 100644 --- a/stdlib/src/locale.rs +++ b/stdlib/src/locale.rs @@ -50,7 +50,10 @@ mod _locale { ptr, }; - #[cfg(all(unix, not(any(target_os = "ios", target_os = "android"))))] + #[cfg(all( + unix, + not(any(target_os = "ios", target_os = "android", target_os = "redox")) + ))] #[pyattr] use libc::{ ABDAY_1, ABDAY_2, ABDAY_3, ABDAY_4, ABDAY_5, ABDAY_6, ABDAY_7, ABMON_1, ABMON_10, ABMON_11, diff --git a/stdlib/src/mmap.rs b/stdlib/src/mmap.rs index b0a72562e..ecd1e8a18 100644 --- a/stdlib/src/mmap.rs +++ b/stdlib/src/mmap.rs @@ -27,7 +27,7 @@ mod mmap { use std::fs::File; use std::io::Write; use std::ops::{Deref, DerefMut}; - #[cfg(all(unix, not(target_os = "redox")))] + #[cfg(unix)] use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd}; fn advice_try_from_i32(vm: &VirtualMachine, i: i32) -> PyResult { @@ -224,6 +224,7 @@ mod mmap { end: Option, } + #[cfg(not(target_os = "redox"))] #[derive(FromArgs)] pub struct AdviseOptions { #[pyarg(positional)] @@ -234,6 +235,7 @@ mod mmap { length: Option, } + #[cfg(not(target_os = "redox"))] impl AdviseOptions { fn values(self, len: usize, vm: &VirtualMachine) -> PyResult<(libc::c_int, usize, usize)> { let start = self @@ -273,7 +275,7 @@ mod mmap { type Args = MmapNewArgs; // TODO: Windows is not supported right now. - #[cfg(all(unix, not(target_os = "redox")))] + #[cfg(unix)] fn py_new( cls: PyTypeRef, MmapNewArgs { @@ -671,6 +673,7 @@ mod mmap { Ok(()) } + #[cfg(not(target_os = "redox"))] #[allow(unused_assignments)] #[pymethod] fn madvise(&self, options: AdviseOptions, vm: &VirtualMachine) -> PyResult<()> { diff --git a/stdlib/src/socket.rs b/stdlib/src/socket.rs index 662ca7aa7..715f8476e 100644 --- a/stdlib/src/socket.rs +++ b/stdlib/src/socket.rs @@ -53,15 +53,20 @@ mod _socket { #[pyattr] // put IPPROTO_MAX later use c::{ - AF_DECnet, AF_APPLETALK, AF_INET, AF_INET6, AF_IPX, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK, - INADDR_NONE, IPPROTO_AH, IPPROTO_DSTOPTS, IPPROTO_EGP, IPPROTO_ESP, IPPROTO_FRAGMENT, - IPPROTO_HOPOPTS, IPPROTO_ICMP, IPPROTO_ICMPV6, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IP, - IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_NONE, IPPROTO_PIM, IPPROTO_PUP, - IPPROTO_RAW, IPPROTO_ROUTING, IPPROTO_TCP, IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC, - MSG_DONTROUTE, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST, - NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST, NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR, - SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE, - SO_REUSEADDR, SO_TYPE, TCP_NODELAY, + AF_INET, AF_INET6, AF_UNSPEC, INADDR_ANY, INADDR_LOOPBACK, INADDR_NONE, IPPROTO_ICMP, + IPPROTO_ICMPV6, IPPROTO_IP, IPPROTO_IP as IPPROTO_IPIP, IPPROTO_IPV6, IPPROTO_TCP, + IPPROTO_TCP as SOL_TCP, IPPROTO_UDP, MSG_CTRUNC, MSG_DONTROUTE, MSG_OOB, MSG_PEEK, + MSG_TRUNC, MSG_WAITALL, NI_DGRAM, NI_MAXHOST, NI_NAMEREQD, NI_NOFQDN, NI_NUMERICHOST, + NI_NUMERICSERV, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM, SOCK_STREAM, SOL_SOCKET, + SO_BROADCAST, SO_ERROR, SO_LINGER, SO_OOBINLINE, SO_REUSEADDR, SO_TYPE, TCP_NODELAY, + }; + + #[cfg(not(target_os = "redox"))] + #[pyattr] + use c::{ + AF_DECnet, AF_APPLETALK, AF_IPX, IPPROTO_AH, IPPROTO_DSTOPTS, IPPROTO_EGP, IPPROTO_ESP, + IPPROTO_FRAGMENT, IPPROTO_HOPOPTS, IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_NONE, IPPROTO_PIM, + IPPROTO_PUP, IPPROTO_RAW, IPPROTO_ROUTING, }; #[cfg(unix)] diff --git a/vm/src/readline.rs b/vm/src/readline.rs index 0b380e315..53647270e 100644 --- a/vm/src/readline.rs +++ b/vm/src/readline.rs @@ -66,7 +66,7 @@ mod rustyline_readline { /// Readline: the REPL pub struct Readline { - repl: rustyline::Editor, + repl: rustyline::Editor, } impl Readline { @@ -100,7 +100,7 @@ mod rustyline_readline { } pub fn add_history_entry(&mut self, entry: &str) -> OtherResult<()> { - self.repl.add_history_entry(entry); + self.repl.add_history_entry(entry)?; Ok(()) } diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 6069fd606..b2efb660b 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -1685,7 +1685,7 @@ pub(super) mod _os { } cfg_if::cfg_if! { - if #[cfg(target_os = "android")] { + if #[cfg(any(target_os = "android", target_os = "redox"))] { Ok(Some("UTF-8".to_owned())) } else if #[cfg(windows)] { let cp = match fd { diff --git a/vm/src/stdlib/posix.rs b/vm/src/stdlib/posix.rs index cd8f45ad1..81e77332d 100644 --- a/vm/src/stdlib/posix.rs +++ b/vm/src/stdlib/posix.rs @@ -429,6 +429,10 @@ pub mod module { ) } + #[cfg(not(target_os = "redox"))] + const MKNOD_DIR_FD: bool = cfg!(not(target_vendor = "apple")); + + #[cfg(not(target_os = "redox"))] #[derive(FromArgs)] struct MknodArgs { #[pyarg(any)] @@ -437,11 +441,11 @@ pub mod module { mode: libc::mode_t, #[pyarg(any)] device: libc::dev_t, - #[allow(unused)] #[pyarg(flatten)] - dir_fd: DirFd<1>, + dir_fd: DirFd<{ MKNOD_DIR_FD as usize }>, } + #[cfg(not(target_os = "redox"))] impl MknodArgs { fn _mknod(self, vm: &VirtualMachine) -> PyResult { Ok(unsafe { @@ -473,6 +477,7 @@ pub mod module { } #[cfg(target_vendor = "apple")] fn mknod(self, vm: &VirtualMachine) -> PyResult<()> { + let [] = self.dir_fd.0; let ret = self._mknod(vm)?; if ret != 0 { Err(errno_err(vm)) @@ -482,6 +487,7 @@ pub mod module { } } + #[cfg(not(target_os = "redox"))] #[pyfunction] fn mknod(args: MknodArgs, vm: &VirtualMachine) -> PyResult<()> { args.mknod(vm) @@ -1568,10 +1574,8 @@ pub mod module { SupportFunc::new("lchown", None, None, None), #[cfg(not(target_os = "redox"))] SupportFunc::new("fchown", Some(true), None, Some(true)), - #[cfg(not(target_os = "macos"))] - SupportFunc::new("mknod", Some(true), Some(true), Some(false)), - #[cfg(target_os = "macos")] - SupportFunc::new("mknod", Some(true), Some(false), Some(false)), + #[cfg(not(target_os = "redox"))] + SupportFunc::new("mknod", Some(true), Some(MKNOD_DIR_FD), Some(false)), SupportFunc::new("umask", Some(false), Some(false), Some(false)), SupportFunc::new("execv", None, None, None), SupportFunc::new("pathconf", Some(true), None, None), diff --git a/vm/src/stdlib/time.rs b/vm/src/stdlib/time.rs index 793a03c6d..151b97acf 100644 --- a/vm/src/stdlib/time.rs +++ b/vm/src/stdlib/time.rs @@ -552,7 +552,7 @@ mod unix { target_os = "linux", )))] #[pyfunction] - fn get_clock_info(_name: PyStrRef, vm: &VirtualMachine) -> PyResult { + fn get_clock_info(_name: PyStrRef, vm: &VirtualMachine) -> PyResult> { Err(vm.new_not_implemented_error("get_clock_info unsupported on this system".to_owned())) }