about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorAndy Russell <arussell123@gmail.com>2017-08-10 16:31:11 -0400
committerAndy Russell <arussell123@gmail.com>2017-08-16 11:45:07 -0400
commit6f21239fa5d7f586bbed1dfaf413ca7a031ab0d4 (patch)
treef42e4c256064240df579ef2ede929fcffdcc8456 /src/tools
parent04dee085016741016c77d958323fe4e19cea3037 (diff)
downloadrust-6f21239fa5d7f586bbed1dfaf413ca7a031ab0d4.tar.gz
rust-6f21239fa5d7f586bbed1dfaf413ca7a031ab0d4.zip
remove `extra_args` argument
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/compiletest/src/runtest.rs86
1 files changed, 38 insertions, 48 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 67e5e032136..e129c39936d 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1100,10 +1100,11 @@ actual:\n\
     }
 
     fn compile_test(&self) -> ProcRes {
-        let aux_dir = self.aux_output_dir_name();
-        // FIXME (#9639): This needs to handle non-utf8 paths
-        let mut extra_args = vec!["-L".to_owned(),
-                                  aux_dir.to_str().unwrap().to_owned()];
+        let mut rustc = self.make_compile_args(
+            &self.testpaths.file, TargetLocation::ThisFile(self.make_exe_name()));
+
+        rustc.arg("-L").arg(&self.aux_output_dir_name());
+
         match self.config.mode {
             CompileFail | Ui => {
                 // compile-fail and ui tests tend to have tons of unused code as
@@ -1111,14 +1112,11 @@ actual:\n\
                 // want to actually assert warnings about all this code. Instead
                 // let's just ignore unused code warnings by defaults and tests
                 // can turn it back on if needed.
-                extra_args.push("-A".to_owned());
-                extra_args.push("unused".to_owned());
+                rustc.args(&["-A", "unused"]);
             }
             _ => {}
         }
 
-        let rustc = self.make_compile_args(
-            extra_args, &self.testpaths.file, TargetLocation::ThisFile(self.make_exe_name()));
         self.compose_and_run_compiler(rustc, None)
     }
 
@@ -1241,17 +1239,27 @@ actual:\n\
         }
 
         let aux_dir = self.aux_output_dir_name();
-        // FIXME (#9639): This needs to handle non-utf8 paths
-        let extra_link_args = vec!["-L".to_owned(),
-                                   aux_dir.to_str().unwrap().to_owned()];
 
         for rel_ab in &self.props.aux_builds {
             let aux_testpaths = self.compute_aux_test_paths(rel_ab);
             let aux_props = self.props.from_aux_file(&aux_testpaths.file,
                                                      self.revision,
                                                      self.config);
-            let mut crate_type = if aux_props.no_prefer_dynamic {
-                Vec::new()
+            let aux_output = {
+                let f = self.make_lib_name(&self.testpaths.file);
+                let parent = f.parent().unwrap();
+                TargetLocation::ThisDirectory(parent.to_path_buf())
+            };
+            let aux_cx = TestCx {
+                config: self.config,
+                props: &aux_props,
+                testpaths: &aux_testpaths,
+                revision: self.revision
+            };
+            let mut aux_rustc = aux_cx.make_compile_args(&aux_testpaths.file, aux_output);
+
+            let crate_type = if aux_props.no_prefer_dynamic {
+                None
             } else if (self.config.target.contains("musl") && !aux_props.force_host) ||
                       self.config.target.contains("emscripten") {
                 // We primarily compile all auxiliary libraries as dynamic libraries
@@ -1263,24 +1271,17 @@ actual:\n\
                 // dynamic libraries so we just go back to building a normal library. Note,
                 // however, that for MUSL if the library is built with `force_host` then
                 // it's ok to be a dylib as the host should always support dylibs.
-                vec!["--crate-type=lib".to_owned()]
+                Some("lib")
             } else {
-                vec!["--crate-type=dylib".to_owned()]
-            };
-            crate_type.extend(extra_link_args.clone());
-            let aux_output = {
-                let f = self.make_lib_name(&self.testpaths.file);
-                let parent = f.parent().unwrap();
-                TargetLocation::ThisDirectory(parent.to_path_buf())
-            };
-            let aux_cx = TestCx {
-                config: self.config,
-                props: &aux_props,
-                testpaths: &aux_testpaths,
-                revision: self.revision
+                Some("dylib")
             };
-            let aux_rustc =
-                aux_cx.make_compile_args(crate_type, &aux_testpaths.file, aux_output);
+
+            if let Some(crate_type) = crate_type {
+                aux_rustc.args(&["--crate-type", crate_type]);
+            }
+
+            aux_rustc.arg("-L").arg(&aux_dir);
+
             let auxres = aux_cx.compose_and_run(aux_rustc,
                                                 aux_cx.config.compile_lib_path.to_str().unwrap(),
                                                 Some(aux_dir.to_str().unwrap()),
@@ -1337,12 +1338,7 @@ actual:\n\
         result
     }
 
-    fn make_compile_args(&self,
-                         extra_args: Vec<String>,
-                         input_file: &Path,
-                         output_file: TargetLocation)
-                         -> Command
-    {
+    fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> Command {
         let mut rustc = Command::new(&self.config.rustc_path);
         rustc.arg(input_file)
             .arg("-L").arg(&self.config.build_base);
@@ -1410,8 +1406,6 @@ actual:\n\
             }
         }
 
-        rustc.args(&extra_args);
-
         if !self.props.no_prefer_dynamic {
             rustc.args(&["-C", "prefer-dynamic"]);
         }
@@ -1635,17 +1629,13 @@ actual:\n\
 
     fn compile_test_and_save_ir(&self) -> ProcRes {
         let aux_dir = self.aux_output_dir_name();
-        // FIXME (#9639): This needs to handle non-utf8 paths
-        let mut link_args = vec!["-L".to_owned(),
-                                 aux_dir.to_str().unwrap().to_owned()];
-        let llvm_args = vec!["--emit=llvm-ir".to_owned(),];
-        link_args.extend(llvm_args);
-        let rustc = self.make_compile_args(link_args,
-                                           &self.testpaths.file,
-                                           TargetLocation::ThisDirectory(
-                                               self.output_base_name().parent()
-                                                                      .unwrap()
-                                                                      .to_path_buf()));
+
+        let output_file = TargetLocation::ThisDirectory(
+            self.output_base_name().parent().unwrap().to_path_buf());
+        let mut rustc = self.make_compile_args(&self.testpaths.file, output_file);
+        rustc.arg("-L").arg(aux_dir)
+            .arg("--emit=llvm-ir");
+
         self.compose_and_run_compiler(rustc, None)
     }