diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 01f4cacd771ff..0346f652ae272 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1386,7 +1386,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the } let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] }; flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests)); - flags.push(builder.config.cmd.rustc_args().join(" ")); + flags.extend(builder.config.cmd.rustc_args().iter().map(|s| s.to_string())); if let Some(linker) = builder.linker(target) { cmd.arg("--linker").arg(linker); @@ -1395,12 +1395,16 @@ note: if you're sure you want to do this, please open an issue as to why. In the let mut hostflags = flags.clone(); hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display())); hostflags.extend(builder.lld_flags(compiler.host)); - cmd.arg("--host-rustcflags").arg(hostflags.join(" ")); + for flag in hostflags { + cmd.arg("--host-rustcflags").arg(flag); + } let mut targetflags = flags; targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display())); targetflags.extend(builder.lld_flags(target)); - cmd.arg("--target-rustcflags").arg(targetflags.join(" ")); + for flag in targetflags { + cmd.arg("--target-rustcflags").arg(flag); + } cmd.arg("--python").arg(builder.python()); diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index b9ac6c9f36418..0260f68483864 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -269,10 +269,10 @@ pub struct Config { pub runtool: Option, /// Flags to pass to the compiler when building for the host - pub host_rustcflags: Option, + pub host_rustcflags: Vec, /// Flags to pass to the compiler when building for the target - pub target_rustcflags: Option, + pub target_rustcflags: Vec, /// Whether tests should be optimized by default. Individual test-suites and test files may /// override this setting. @@ -457,12 +457,12 @@ pub enum Endian { } impl TargetCfg { - fn new(rustc_path: &Path, target: &str, target_rustcflags: &Option) -> TargetCfg { + fn new(rustc_path: &Path, target: &str, target_rustcflags: &Vec) -> TargetCfg { let output = match Command::new(rustc_path) .arg("--print=cfg") .arg("--target") .arg(target) - .args(target_rustcflags.into_iter().map(|s| s.split_whitespace()).flatten()) + .args(target_rustcflags) .output() { Ok(output) => output, diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index dccfd4e0d9807..f2d80d7f5325a 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -252,8 +252,8 @@ pub fn parse_config(args: Vec) -> Config { }), logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)), runtool: matches.opt_str("runtool"), - host_rustcflags: Some(matches.opt_strs("host-rustcflags").join(" ")), - target_rustcflags: Some(matches.opt_strs("target-rustcflags").join(" ")), + host_rustcflags: matches.opt_strs("host-rustcflags"), + target_rustcflags: matches.opt_strs("target-rustcflags"), optimize_tests: matches.opt_present("optimize-tests"), target, host: opt_str2(matches.opt_str("host")), @@ -320,8 +320,8 @@ pub fn log_config(config: &Config) { format!("force_pass_mode: {}", opt_str(&config.force_pass_mode.map(|m| format!("{}", m))),), ); logv(c, format!("runtool: {}", opt_str(&config.runtool))); - logv(c, format!("host-rustcflags: {}", opt_str(&config.host_rustcflags))); - logv(c, format!("target-rustcflags: {}", opt_str(&config.target_rustcflags))); + logv(c, format!("host-rustcflags: {:?}", config.host_rustcflags)); + logv(c, format!("target-rustcflags: {:?}", config.target_rustcflags)); logv(c, format!("target: {}", config.target)); logv(c, format!("host: {}", config.host)); logv(c, format!("android-cross-path: {:?}", config.android_cross_path.display())); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 8f289876f7307..8af5f1da694b9 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -558,10 +558,7 @@ impl<'test> TestCx<'test> { .arg(&aux_dir) .args(&self.props.compile_flags) .envs(self.props.rustc_env.clone()); - self.maybe_add_external_args( - &mut rustc, - self.split_maybe_args(&self.config.target_rustcflags), - ); + self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags); let src = match read_from { ReadFrom::Stdin(src) => Some(src), @@ -629,10 +626,7 @@ impl<'test> TestCx<'test> { .arg("-L") .arg(aux_dir); self.set_revision_flags(&mut rustc); - self.maybe_add_external_args( - &mut rustc, - self.split_maybe_args(&self.config.target_rustcflags), - ); + self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags); rustc.args(&self.props.compile_flags); self.compose_and_run_compiler(rustc, Some(src)) @@ -1186,23 +1180,14 @@ impl<'test> TestCx<'test> { ProcRes { status, stdout: out, stderr: err, cmdline: format!("{:?}", cmd) } } - fn cleanup_debug_info_options(&self, options: &Option) -> Option { - if options.is_none() { - return None; - } - + fn cleanup_debug_info_options(&self, options: &Vec) -> Vec { // Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS. let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()]; - let new_options = self - .split_maybe_args(options) - .into_iter() - .filter(|x| !options_to_remove.contains(x)) - .collect::>(); - Some(new_options.join(" ")) + options.iter().filter(|x| !options_to_remove.contains(x)).map(|x| x.clone()).collect() } - fn maybe_add_external_args(&self, cmd: &mut Command, args: Vec) { + fn maybe_add_external_args(&self, cmd: &mut Command, args: &Vec) { // Filter out the arguments that should not be added by runtest here. // // Notable use-cases are: do not add our optimisation flag if @@ -2035,15 +2020,9 @@ impl<'test> TestCx<'test> { } if self.props.force_host { - self.maybe_add_external_args( - &mut rustc, - self.split_maybe_args(&self.config.host_rustcflags), - ); + self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags); } else { - self.maybe_add_external_args( - &mut rustc, - self.split_maybe_args(&self.config.target_rustcflags), - ); + self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags); if !is_rustdoc { if let Some(ref linker) = self.config.linker { rustc.arg(format!("-Clinker={}", linker));