use std::mem;
use std::process::{self, Output};
+use rustc_span::symbol::Symbol;
use rustc_target::spec::LldFlavor;
-use syntax::symbol::Symbol;
#[derive(Clone)]
pub struct Command {
enum Program {
Normal(OsString),
CmdBatScript(OsString),
- Lld(OsString, LldFlavor)
+ Lld(OsString, LldFlavor),
}
impl Command {
}
fn _new(program: Program) -> Command {
- Command {
- program,
- args: Vec::new(),
- env: Vec::new(),
- env_remove: Vec::new(),
- }
+ Command { program, args: Vec::new(), env: Vec::new(), env_remove: Vec::new() }
}
pub fn arg<P: AsRef<OsStr>>(&mut self, arg: P) -> &mut Command {
}
pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Command
- where K: AsRef<OsStr>,
- V: AsRef<OsStr>
+ where
+ K: AsRef<OsStr>,
+ V: AsRef<OsStr>,
{
self._env(key.as_ref(), value.as_ref());
self
}
pub fn env_remove<K>(&mut self, key: K) -> &mut Command
- where K: AsRef<OsStr>,
+ where
+ K: AsRef<OsStr>,
{
self._env_remove(key.as_ref());
self
for k in &self.env_remove {
ret.env_remove(k);
}
- return ret
+ return ret;
}
// extensions
// We mostly only care about Windows in this method, on Unix the limits
// can be gargantuan anyway so we're pretty unlikely to hit them
if cfg!(unix) {
- return false
+ return false;
}
// Right now LLD doesn't support the `@` syntax of passing an argument
// through files, so regardless of the platform we try to go to the OS
// on this one.
if let Program::Lld(..) = self.program {
- return false
+ return false;
}
// Ok so on Windows to spawn a process is 32,768 characters in its
// error code if we fail to spawn and automatically re-spawning the
// linker with smaller arguments.
//
- // [1]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
- // [2]: https://blogs.msdn.microsoft.com/oldnewthing/20031210-00/?p=41553
+ // [1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa
+ // [2]: https://devblogs.microsoft.com/oldnewthing/?p=41553
- let estimated_command_line_len =
- self.args.iter().map(|a| a.len()).sum::<usize>();
+ let estimated_command_line_len = self.args.iter().map(|a| a.len()).sum::<usize>();
estimated_command_line_len > 1024 * 6
}
}