From 5da1123c5efbd91813fb5ba7cec5298d960ae3af Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Thu, 29 Aug 2019 17:49:46 -0700 Subject: [PATCH 1/9] Update zx_time_t to an i64 --- src/libstd/sys/unix/process/zircon.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs index ec715d5490f6f..9224bef7c4a5f 100644 --- a/src/libstd/sys/unix/process/zircon.rs +++ b/src/libstd/sys/unix/process/zircon.rs @@ -3,7 +3,7 @@ use crate::convert::TryInto; use crate::io; use crate::os::raw::c_char; -use crate::u64; +use crate::i64; use libc::{c_int, c_void, size_t}; @@ -14,8 +14,8 @@ pub type zx_status_t = i32; pub const ZX_HANDLE_INVALID: zx_handle_t = 0; -pub type zx_time_t = u64; -pub const ZX_TIME_INFINITE : zx_time_t = u64::MAX; +pub type zx_time_t = i64; +pub const ZX_TIME_INFINITE : zx_time_t = i64::MAX; pub type zx_signals_t = u32; From 403701f97628b85bfa3e5ec0e5ca82b81d53ba1e Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Fri, 30 Aug 2019 11:51:04 -0700 Subject: [PATCH 2/9] Don't try to use /dev/null on Fuchsia --- src/libstd/sys/unix/process/process_common.rs | 28 +++++++++++++++++-- .../sys/unix/process/process_fuchsia.rs | 15 ++++++---- src/libstd/sys/unix/process/zircon.rs | 2 +- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 6bb20bbe08794..511e67840803e 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -1,19 +1,27 @@ use crate::os::unix::prelude::*; -use crate::ffi::{OsString, OsStr, CString, CStr}; +use crate::ffi::{OsString, OsStr, CString}; use crate::fmt; use crate::io; use crate::ptr; use crate::sys::fd::FileDesc; -use crate::sys::fs::{File, OpenOptions}; +use crate::sys::fs::File; use crate::sys::pipe::{self, AnonPipe}; use crate::sys_common::process::{CommandEnv, DefaultEnvKey}; use crate::collections::BTreeMap; +#[cfg(not(target_os = "fuchsia"))] +use { + crate::ffi::CStr, + crate::sys::fs::OpenOptions, +}; + use libc::{c_int, gid_t, uid_t, c_char, EXIT_SUCCESS, EXIT_FAILURE}; cfg_if::cfg_if! { - if #[cfg(target_os = "redox")] { + if #[cfg(target_os = "fuchsia")] { + // fuchsia doesn't have /dev/null + } else if #[cfg(target_os = "redox")] { const DEV_NULL: &'static str = "null:\0"; } else { const DEV_NULL: &'static str = "/dev/null\0"; @@ -83,6 +91,11 @@ pub enum ChildStdio { Inherit, Explicit(c_int), Owned(FileDesc), + + // On Fuchsia, null stdio is the default, so we simply don't specify + // any actions at the time of spawning. + #[cfg(target_os = "fuchsia")] + Null, } pub enum Stdio { @@ -301,6 +314,7 @@ impl Stdio { Ok((ChildStdio::Owned(theirs.into_fd()), Some(ours))) } + #[cfg(not(target_os = "fuchsia"))] Stdio::Null => { let mut opts = OpenOptions::new(); opts.read(readable); @@ -311,6 +325,11 @@ impl Stdio { let fd = File::open_c(&path, &opts)?; Ok((ChildStdio::Owned(fd.into_fd()), None)) } + + #[cfg(target_os = "fuchsia")] + Stdio::Null => { + Ok((ChildStdio::Null, None)) + } } } } @@ -333,6 +352,9 @@ impl ChildStdio { ChildStdio::Inherit => None, ChildStdio::Explicit(fd) => Some(fd), ChildStdio::Owned(ref fd) => Some(fd.raw()), + + #[cfg(target_os = "fuchsia")] + ChildStdio::Null => None, } } } diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index 7c6be9b0a6047..295ec59eb32cf 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -52,7 +52,7 @@ impl Command { None => ptr::null(), }; - let transfer_or_clone = |opt_fd, target_fd| if let Some(local_fd) = opt_fd { + let make_action = |local_io: &ChildStdio, target_fd| if let Some(local_fd) = local_io.fd() { fdio_spawn_action_t { action: FDIO_SPAWN_ACTION_TRANSFER_FD, local_fd, @@ -60,6 +60,10 @@ impl Command { ..Default::default() } } else { + if let ChildStdio::Null = local_io { + // acts as no-op + return Default::default(); + } fdio_spawn_action_t { action: FDIO_SPAWN_ACTION_CLONE_FD, local_fd: target_fd, @@ -69,9 +73,9 @@ impl Command { }; // Clone stdin, stdout, and stderr - let action1 = transfer_or_clone(stdio.stdin.fd(), 0); - let action2 = transfer_or_clone(stdio.stdout.fd(), 1); - let action3 = transfer_or_clone(stdio.stderr.fd(), 2); + let action1 = make_action(&stdio.stdin, 0); + let action2 = make_action(&stdio.stdout, 1); + let action3 = make_action(&stdio.stderr, 2); let actions = [action1, action2, action3]; // We don't want FileDesc::drop to be called on any stdio. fdio_spawn_etc @@ -86,7 +90,8 @@ impl Command { zx_cvt(fdio_spawn_etc( 0, FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE, - self.get_argv()[0], self.get_argv().as_ptr(), envp, 3, actions.as_ptr(), + self.get_argv()[0], self.get_argv().as_ptr(), envp, + actions.len() as size_t, actions.as_ptr(), &mut process_handle, ptr::null_mut(), ))?; diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs index 9224bef7c4a5f..29032f5e0d200 100644 --- a/src/libstd/sys/unix/process/zircon.rs +++ b/src/libstd/sys/unix/process/zircon.rs @@ -120,7 +120,7 @@ pub struct fdio_spawn_action_t { extern { pub fn fdio_spawn_etc(job: zx_handle_t, flags: u32, path: *const c_char, argv: *const *const c_char, envp: *const *const c_char, - action_count: u64, actions: *const fdio_spawn_action_t, + action_count: size_t, actions: *const fdio_spawn_action_t, process: *mut zx_handle_t, err_msg: *mut c_char) -> zx_status_t; } From 7bfa2be4efa2d4649e8db7548f1980156d58017e Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Fri, 30 Aug 2019 18:21:57 -0700 Subject: [PATCH 3/9] fuchsia: Don't fail to spawn if no stdin exists --- .../sys/unix/process/process_fuchsia.rs | 57 ++++++++++++------- src/libstd/sys/unix/process/zircon.rs | 6 +- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index 295ec59eb32cf..2b3795292f42a 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -52,30 +52,45 @@ impl Command { None => ptr::null(), }; - let make_action = |local_io: &ChildStdio, target_fd| if let Some(local_fd) = local_io.fd() { - fdio_spawn_action_t { - action: FDIO_SPAWN_ACTION_TRANSFER_FD, - local_fd, - target_fd, - ..Default::default() - } - } else { - if let ChildStdio::Null = local_io { - // acts as no-op - return Default::default(); - } - fdio_spawn_action_t { - action: FDIO_SPAWN_ACTION_CLONE_FD, - local_fd: target_fd, - target_fd, - ..Default::default() + let make_action = |local_io: &ChildStdio, target_fd| -> io::Result { + if let Some(local_fd) = local_io.fd() { + Ok(fdio_spawn_action_t { + action: FDIO_SPAWN_ACTION_TRANSFER_FD, + local_fd, + target_fd, + ..Default::default() + }) + } else { + if let ChildStdio::Null = local_io { + // acts as no-op + return Ok(Default::default()); + } + + let mut handle = ZX_HANDLE_INVALID; + let status = fdio_fd_clone(target_fd, &mut handle); + if status == ERR_INVALID_ARGS || status == ERR_NOT_SUPPORTED { + // This descriptor is closed; skip it rather than generating an + // error. + return Ok(Default::default()); + } + zx_cvt(status)?; + + let mut cloned_fd = 0; + zx_cvt(fdio_fd_create(handle, &mut cloned_fd))?; + + Ok(fdio_spawn_action_t { + action: FDIO_SPAWN_ACTION_TRANSFER_FD, + local_fd: cloned_fd as i32, + target_fd, + ..Default::default() + }) } }; // Clone stdin, stdout, and stderr - let action1 = make_action(&stdio.stdin, 0); - let action2 = make_action(&stdio.stdout, 1); - let action3 = make_action(&stdio.stderr, 2); + let action1 = make_action(&stdio.stdin, 0)?; + let action2 = make_action(&stdio.stdout, 1)?; + let action3 = make_action(&stdio.stderr, 2)?; let actions = [action1, action2, action3]; // We don't want FileDesc::drop to be called on any stdio. fdio_spawn_etc @@ -88,7 +103,7 @@ impl Command { let mut process_handle: zx_handle_t = 0; zx_cvt(fdio_spawn_etc( - 0, + ZX_HANDLE_INVALID, FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE, self.get_argv()[0], self.get_argv().as_ptr(), envp, actions.len() as size_t, actions.as_ptr(), diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs index 29032f5e0d200..1ba48de3c0785 100644 --- a/src/libstd/sys/unix/process/zircon.rs +++ b/src/libstd/sys/unix/process/zircon.rs @@ -2,8 +2,9 @@ use crate::convert::TryInto; use crate::io; -use crate::os::raw::c_char; use crate::i64; +use crate::mem::MaybeUninit; +use crate::os::raw::c_char; use libc::{c_int, c_void, size_t}; @@ -122,6 +123,9 @@ extern { argv: *const *const c_char, envp: *const *const c_char, action_count: size_t, actions: *const fdio_spawn_action_t, process: *mut zx_handle_t, err_msg: *mut c_char) -> zx_status_t; + + pub fn fdio_fd_clone(fd: c_int, out_handle: *mut zx_handle_t) -> zx_status_t; + pub fn fdio_fd_create(handle: zx_handle_t, fd: *mut c_int) -> zx_status_t; } // fdio_spawn_etc flags From 5f91ad0e3300c36033bf409ceefb00480fecbed3 Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Fri, 30 Aug 2019 18:52:19 -0700 Subject: [PATCH 4/9] fuchsia: Fix default environment behavior when spawning --- src/libstd/sys/unix/process/process_fuchsia.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index 2b3795292f42a..fff9fc6b3bbc8 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -48,8 +48,10 @@ impl Command { use crate::sys::process::zircon::*; let envp = match maybe_envp { - Some(envp) => envp.as_ptr(), + // None means to clone the current environment, which is done in the + // flags below. None => ptr::null(), + Some(envp) => envp.as_ptr(), }; let make_action = |local_io: &ChildStdio, target_fd| -> io::Result { @@ -104,7 +106,8 @@ impl Command { let mut process_handle: zx_handle_t = 0; zx_cvt(fdio_spawn_etc( ZX_HANDLE_INVALID, - FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE, + FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE + | FDIO_SPAWN_CLONE_ENVIRON, // this is ignored when envp is non-null self.get_argv()[0], self.get_argv().as_ptr(), envp, actions.len() as size_t, actions.as_ptr(), &mut process_handle, From c86ea34639b0962858f053e900fe7c7de1008c5f Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 2 Sep 2019 14:23:41 -0400 Subject: [PATCH 5/9] Ensure all warnings are emitted even on warnings=warn --- src/bootstrap/bin/rustc.rs | 13 +++++++------ src/bootstrap/bootstrap.py | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 8cb48df14bfef..84415baa3a140 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -119,17 +119,18 @@ fn main() { cmd.arg(format!("-Cdebuginfo={}", debuginfo_level)); } - if env::var_os("RUSTC_DENY_WARNINGS").is_some() && - env::var_os("RUSTC_EXTERNAL_TOOL").is_none() { + if env::var_os("RUSTC_EXTERNAL_TOOL").is_none() { // When extending this list, add the new lints to the RUSTFLAGS of the // build_bootstrap function of src/bootstrap/bootstrap.py as well as // some code doesn't go through this `rustc` wrapper. - cmd.arg("-Dwarnings"); - cmd.arg("-Drust_2018_idioms"); - cmd.arg("-Dunused_lifetimes"); + cmd.arg("-Wrust_2018_idioms"); + cmd.arg("-Wunused_lifetimes"); if use_internal_lints(crate_name) { cmd.arg("-Zunstable-options"); - cmd.arg("-Drustc::internal"); + cmd.arg("-Wrustc::internal"); + } + if env::var_os("RUSTC_DENY_WARNINGS").is_some() { + cmd.arg("-Dwarnings"); } } diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 4162fe1df5086..03f02ea217ddf 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -631,8 +631,9 @@ def build_bootstrap(self): target_linker = self.get_toml("linker", build_section) if target_linker is not None: env["RUSTFLAGS"] += "-C linker=" + target_linker + " " + env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes " if self.get_toml("deny-warnings", "rust") != "false": - env["RUSTFLAGS"] += "-Dwarnings -Drust_2018_idioms -Dunused_lifetimes " + env["RUSTFLAGS"] += "-Dwarnings " env["PATH"] = os.path.join(self.bin_root(), "bin") + \ os.pathsep + env["PATH"] From fda251b966ec5a8d1c3c001242777861f15b95e2 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Mon, 2 Sep 2019 14:24:40 -0400 Subject: [PATCH 6/9] Rename --warnings=allow to --warnings=warn We never allowed the warnings, only made them not denied. --- src/bootstrap/flags.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 828865f10ffba..d9580b598155e 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -36,7 +36,7 @@ pub struct Flags { // This overrides the deny-warnings configuation option, // which passes -Dwarnings to the compiler invocations. // - // true => deny, false => allow + // true => deny, false => warn pub deny_warnings: Option, } @@ -556,10 +556,10 @@ fn split(s: &[String]) -> Vec { fn parse_deny_warnings(matches: &getopts::Matches) -> Option { match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) { Some("deny") => Some(true), - Some("allow") => Some(false), + Some("warn") => Some(false), Some(value) => { eprintln!( - r#"invalid value for --warnings: {:?}, expected "allow" or "deny""#, + r#"invalid value for --warnings: {:?}, expected "warn" or "deny""#, value, ); process::exit(1); From 4c4f25c82712d51e5a0b75f11073076aa153f696 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 5 Sep 2019 17:03:12 -0500 Subject: [PATCH 7/9] update rustc-guide --- src/doc/rustc-guide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-guide b/src/doc/rustc-guide index 6e25a3d0d3573..a0c08c27e60e5 160000 --- a/src/doc/rustc-guide +++ b/src/doc/rustc-guide @@ -1 +1 @@ -Subproject commit 6e25a3d0d3573eb42b2e2339f1219e969d1b3dee +Subproject commit a0c08c27e60e52b72244c5241ed494a197bebf28 From 8ddbe7660fa6297193fe81e50f5d342a16cb06b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Thu, 29 Aug 2019 13:22:21 +0200 Subject: [PATCH 8/9] Upgrade env_logger to 0.6 --- Cargo.lock | 36 +++++++++++--------------------- src/librustc_driver/Cargo.toml | 2 +- src/tools/compiletest/Cargo.toml | 2 +- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 313fef1c086a8..c9f2092eb5236 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -277,7 +277,7 @@ dependencies = [ "crypto-hash", "curl", "curl-sys", - "env_logger 0.6.0", + "env_logger", "failure", "filetime", "flate2", @@ -507,7 +507,7 @@ name = "compiletest" version = "0.0.0" dependencies = [ "diff", - "env_logger 0.5.13", + "env_logger", "getopts", "lazy_static 1.3.0", "libc", @@ -909,21 +909,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" -dependencies = [ - "atty", - "humantime", - "log", - "termcolor", -] - -[[package]] -name = "env_logger" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" +checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" dependencies = [ "atty", "humantime", @@ -1774,7 +1762,7 @@ dependencies = [ "chrono", "clap", "elasticlunr-rs", - "env_logger 0.6.0", + "env_logger", "error-chain", "handlebars", "itertools 0.8.0", @@ -1799,7 +1787,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77d1f0ba4d1e6b86fa18e8853d026d7d76a97eb7eb5eb052ed80901e43b7fc10" dependencies = [ - "env_logger 0.6.0", + "env_logger", "failure", "log", "mdbook", @@ -1992,7 +1980,7 @@ dependencies = [ "colored", "compiletest_rs", "directories", - "env_logger 0.6.0", + "env_logger", "getrandom", "hex", "log", @@ -2363,7 +2351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df8b3f4e0475def7d9c2e5de8e5a1306949849761e107b360d03e98eafaffd61" dependencies = [ "chrono", - "env_logger 0.6.0", + "env_logger", "log", ] @@ -2440,7 +2428,7 @@ dependencies = [ "bitflags", "clap", "derive_more", - "env_logger 0.6.0", + "env_logger", "humantime", "lazy_static 1.3.0", "log", @@ -2734,7 +2722,7 @@ dependencies = [ "clippy_lints", "crossbeam-channel", "difference", - "env_logger 0.6.0", + "env_logger", "failure", "futures", "heck", @@ -3203,7 +3191,7 @@ dependencies = [ name = "rustc_driver" version = "0.0.0" dependencies = [ - "env_logger 0.5.13", + "env_logger", "graphviz", "log", "rustc", @@ -3590,7 +3578,7 @@ dependencies = [ "derive-new", "diff", "dirs", - "env_logger 0.6.0", + "env_logger", "failure", "getopts", "ignore", diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index b030517e28ec2..a839ee56b2b6e 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -12,7 +12,7 @@ crate-type = ["dylib"] [dependencies] graphviz = { path = "../libgraphviz" } log = "0.4" -env_logger = { version = "0.5", default-features = false } +env_logger = { version = "0.6", default-features = false } rustc = { path = "../librustc" } rustc_target = { path = "../librustc_target" } rustc_ast_borrowck = { path = "../librustc_ast_borrowck" } diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index e759ad1f35dde..745233c151cd6 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] diff = "0.1.10" -env_logger = { version = "0.5", default-features = false } +env_logger = { version = "0.6", default-features = false } getopts = "0.2" log = "0.4" regex = "1.0" From 13413d6d39ad7f4fc73ba9ed1ef932bf97427de3 Mon Sep 17 00:00:00 2001 From: mark Date: Fri, 6 Sep 2019 16:01:46 -0500 Subject: [PATCH 9/9] update guide --- src/doc/rustc-guide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-guide b/src/doc/rustc-guide index a0c08c27e60e5..941968db2fd9c 160000 --- a/src/doc/rustc-guide +++ b/src/doc/rustc-guide @@ -1 +1 @@ -Subproject commit a0c08c27e60e52b72244c5241ed494a197bebf28 +Subproject commit 941968db2fd9c85788a4f971c8e425d46b4cb734