]> git.lizzy.rs Git - rust.git/blob - src/bootstrap/tool.rs
Rollup merge of #64702 - sinkuu:deps, r=jonas-schievink
[rust.git] / src / bootstrap / tool.rs
1 use std::fs;
2 use std::env;
3 use std::path::PathBuf;
4 use std::process::{Command, exit};
5 use std::collections::HashSet;
6
7 use build_helper::t;
8
9 use crate::Mode;
10 use crate::Compiler;
11 use crate::builder::{Step, RunConfig, ShouldRun, Builder, Cargo as CargoCommand};
12 use crate::util::{exe, add_lib_path, CiEnv};
13 use crate::compile;
14 use crate::channel::GitInfo;
15 use crate::channel;
16 use crate::cache::Interned;
17 use crate::toolstate::ToolState;
18
19 #[derive(Debug, Clone, Hash, PartialEq, Eq)]
20 pub enum SourceType {
21     InTree,
22     Submodule,
23 }
24
25 #[derive(Debug, Clone, Hash, PartialEq, Eq)]
26 struct ToolBuild {
27     compiler: Compiler,
28     target: Interned<String>,
29     tool: &'static str,
30     path: &'static str,
31     mode: Mode,
32     is_optional_tool: bool,
33     source_type: SourceType,
34     extra_features: Vec<String>,
35 }
36
37 impl Step for ToolBuild {
38     type Output = Option<PathBuf>;
39
40     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
41         run.never()
42     }
43
44     /// Builds a tool in `src/tools`
45     ///
46     /// This will build the specified tool with the specified `host` compiler in
47     /// `stage` into the normal cargo output directory.
48     fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
49         let compiler = self.compiler;
50         let target = self.target;
51         let tool = self.tool;
52         let path = self.path;
53         let is_optional_tool = self.is_optional_tool;
54
55         match self.mode {
56             Mode::ToolRustc => {
57                 builder.ensure(compile::Rustc { compiler, target })
58             }
59             Mode::ToolStd => {
60                 builder.ensure(compile::Std { compiler, target })
61             }
62             Mode::ToolBootstrap => {} // uses downloaded stage0 compiler libs
63             _ => panic!("unexpected Mode for tool build")
64         }
65
66         let cargo = prepare_tool_cargo(
67             builder,
68             compiler,
69             self.mode,
70             target,
71             "build",
72             path,
73             self.source_type,
74             &self.extra_features,
75         );
76
77         builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target));
78         let mut duplicates = Vec::new();
79         let is_expected = compile::stream_cargo(builder, cargo, vec![], &mut |msg| {
80             // Only care about big things like the RLS/Cargo for now
81             match tool {
82                 | "rls"
83                 | "cargo"
84                 | "clippy-driver"
85                 | "miri"
86                 | "rustfmt"
87                 => {}
88
89                 _ => return,
90             }
91             let (id, features, filenames) = match msg {
92                 compile::CargoMessage::CompilerArtifact {
93                     package_id,
94                     features,
95                     filenames,
96                     target: _,
97                 } => {
98                     (package_id, features, filenames)
99                 }
100                 _ => return,
101             };
102             let features = features.iter().map(|s| s.to_string()).collect::<Vec<_>>();
103
104             for path in filenames {
105                 let val = (tool, PathBuf::from(&*path), features.clone());
106                 // we're only interested in deduplicating rlibs for now
107                 if val.1.extension().and_then(|s| s.to_str()) != Some("rlib") {
108                     continue
109                 }
110
111                 // Don't worry about compiles that turn out to be host
112                 // dependencies or build scripts. To skip these we look for
113                 // anything that goes in `.../release/deps` but *doesn't* go in
114                 // `$target/release/deps`. This ensure that outputs in
115                 // `$target/release` are still considered candidates for
116                 // deduplication.
117                 if let Some(parent) = val.1.parent() {
118                     if parent.ends_with("release/deps") {
119                         let maybe_target = parent
120                             .parent()
121                             .and_then(|p| p.parent())
122                             .and_then(|p| p.file_name())
123                             .and_then(|p| p.to_str())
124                             .unwrap();
125                         if maybe_target != &*target {
126                             continue;
127                         }
128                     }
129                 }
130
131                 // Record that we've built an artifact for `id`, and if one was
132                 // already listed then we need to see if we reused the same
133                 // artifact or produced a duplicate.
134                 let mut artifacts = builder.tool_artifacts.borrow_mut();
135                 let prev_artifacts = artifacts
136                     .entry(target)
137                     .or_default();
138                 let prev = match prev_artifacts.get(&*id) {
139                     Some(prev) => prev,
140                     None => {
141                         prev_artifacts.insert(id.to_string(), val);
142                         continue;
143                     }
144                 };
145                 if prev.1 == val.1 {
146                     return; // same path, same artifact
147                 }
148
149                 // If the paths are different and one of them *isn't* inside of
150                 // `release/deps`, then it means it's probably in
151                 // `$target/release`, or it's some final artifact like
152                 // `libcargo.rlib`. In these situations Cargo probably just
153                 // copied it up from `$target/release/deps/libcargo-xxxx.rlib`,
154                 // so if the features are equal we can just skip it.
155                 let prev_no_hash = prev.1.parent().unwrap().ends_with("release/deps");
156                 let val_no_hash = val.1.parent().unwrap().ends_with("release/deps");
157                 if prev.2 == val.2 || !prev_no_hash || !val_no_hash {
158                     return;
159                 }
160
161                 // ... and otherwise this looks like we duplicated some sort of
162                 // compilation, so record it to generate an error later.
163                 duplicates.push((
164                     id.to_string(),
165                     val,
166                     prev.clone(),
167                 ));
168             }
169         });
170
171         if is_expected && !duplicates.is_empty() {
172             println!("duplicate artifacts found when compiling a tool, this \
173                       typically means that something was recompiled because \
174                       a transitive dependency has different features activated \
175                       than in a previous build:\n");
176             println!("the following dependencies are duplicated although they \
177                       have the same features enabled:");
178             for (id, cur, prev) in duplicates.drain_filter(|(_, cur, prev)| cur.2 == prev.2) {
179                 println!("  {}", id);
180                 // same features
181                 println!("    `{}` ({:?})\n    `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
182             }
183             println!("the following dependencies have different features:");
184             for (id, cur, prev) in duplicates {
185                 println!("  {}", id);
186                 let cur_features: HashSet<_> = cur.2.into_iter().collect();
187                 let prev_features: HashSet<_> = prev.2.into_iter().collect();
188                 println!("    `{}` additionally enabled features {:?} at {:?}",
189                          cur.0, &cur_features - &prev_features, cur.1);
190                 println!("    `{}` additionally enabled features {:?} at {:?}",
191                          prev.0, &prev_features - &cur_features, prev.1);
192             }
193             println!();
194             println!("to fix this you will probably want to edit the local \
195                       src/tools/rustc-workspace-hack/Cargo.toml crate, as \
196                       that will update the dependency graph to ensure that \
197                       these crates all share the same feature set");
198             panic!("tools should not compile multiple copies of the same crate");
199         }
200
201         builder.save_toolstate(tool, if is_expected {
202             ToolState::TestFail
203         } else {
204             ToolState::BuildFail
205         });
206
207         if !is_expected {
208             if !is_optional_tool {
209                 exit(1);
210             } else {
211                 None
212             }
213         } else {
214             let cargo_out = builder.cargo_out(compiler, self.mode, target)
215                 .join(exe(tool, &compiler.host));
216             let bin = builder.tools_dir(compiler).join(exe(tool, &compiler.host));
217             builder.copy(&cargo_out, &bin);
218             Some(bin)
219         }
220     }
221 }
222
223 pub fn prepare_tool_cargo(
224     builder: &Builder<'_>,
225     compiler: Compiler,
226     mode: Mode,
227     target: Interned<String>,
228     command: &'static str,
229     path: &'static str,
230     source_type: SourceType,
231     extra_features: &[String],
232 ) -> CargoCommand {
233     let mut cargo = builder.cargo(compiler, mode, target, command);
234     let dir = builder.src.join(path);
235     cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
236
237     if source_type == SourceType::Submodule {
238         cargo.env("RUSTC_EXTERNAL_TOOL", "1");
239     }
240
241     let mut features = extra_features.iter().cloned().collect::<Vec<_>>();
242     if builder.build.config.cargo_native_static {
243         if path.ends_with("cargo") ||
244             path.ends_with("rls") ||
245             path.ends_with("clippy") ||
246             path.ends_with("miri") ||
247             path.ends_with("rustfmt")
248         {
249             cargo.env("LIBZ_SYS_STATIC", "1");
250             features.push("rustc-workspace-hack/all-static".to_string());
251         }
252     }
253
254     // if tools are using lzma we want to force the build script to build its
255     // own copy
256     cargo.env("LZMA_API_STATIC", "1");
257
258     cargo.env("CFG_RELEASE_CHANNEL", &builder.config.channel);
259     cargo.env("CFG_VERSION", builder.rust_version());
260     cargo.env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM);
261
262     let info = GitInfo::new(builder.config.ignore_git, &dir);
263     if let Some(sha) = info.sha() {
264         cargo.env("CFG_COMMIT_HASH", sha);
265     }
266     if let Some(sha_short) = info.sha_short() {
267         cargo.env("CFG_SHORT_COMMIT_HASH", sha_short);
268     }
269     if let Some(date) = info.commit_date() {
270         cargo.env("CFG_COMMIT_DATE", date);
271     }
272     if !features.is_empty() {
273         cargo.arg("--features").arg(&features.join(", "));
274     }
275     cargo
276 }
277
278 fn rustbook_features() -> Vec<String> {
279     let mut features = Vec::new();
280
281     // Due to CI budged and risk of spurious failures we want to limit jobs running this check.
282     // At same time local builds should run it regardless of the platform.
283     // `CiEnv::None` means it's local build and `CHECK_LINKS` is defined in x86_64-gnu-tools to
284     // explicitly enable it on single job
285     if CiEnv::current() == CiEnv::None || env::var("CHECK_LINKS").is_ok() {
286         features.push("linkcheck".to_string());
287     }
288
289     features
290 }
291
292 macro_rules! bootstrap_tool {
293     ($(
294         $name:ident, $path:expr, $tool_name:expr
295         $(,llvm_tools = $llvm:expr)*
296         $(,is_external_tool = $external:expr)*
297         $(,features = $features:expr)*
298         ;
299     )+) => {
300         #[derive(Copy, PartialEq, Eq, Clone)]
301         pub enum Tool {
302             $(
303                 $name,
304             )+
305         }
306
307         impl Tool {
308             /// Whether this tool requires LLVM to run
309             pub fn uses_llvm_tools(&self) -> bool {
310                 match self {
311                     $(Tool::$name => false $(|| $llvm)*,)+
312                 }
313             }
314         }
315
316         impl<'a> Builder<'a> {
317             pub fn tool_exe(&self, tool: Tool) -> PathBuf {
318                 match tool {
319                     $(Tool::$name =>
320                         self.ensure($name {
321                             compiler: self.compiler(0, self.config.build),
322                             target: self.config.build,
323                         }),
324                     )+
325                 }
326             }
327         }
328
329         $(
330             #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
331         pub struct $name {
332             pub compiler: Compiler,
333             pub target: Interned<String>,
334         }
335
336         impl Step for $name {
337             type Output = PathBuf;
338
339             fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
340                 run.path($path)
341             }
342
343             fn make_run(run: RunConfig<'_>) {
344                 run.builder.ensure($name {
345                     // snapshot compiler
346                     compiler: run.builder.compiler(0, run.builder.config.build),
347                     target: run.target,
348                 });
349             }
350
351             fn run(self, builder: &Builder<'_>) -> PathBuf {
352                 builder.ensure(ToolBuild {
353                     compiler: self.compiler,
354                     target: self.target,
355                     tool: $tool_name,
356                     mode: Mode::ToolBootstrap,
357                     path: $path,
358                     is_optional_tool: false,
359                     source_type: if false $(|| $external)* {
360                         SourceType::Submodule
361                     } else {
362                         SourceType::InTree
363                     },
364                     extra_features: {
365                         // FIXME(#60643): avoid this lint by using `_`
366                         let mut _tmp = Vec::new();
367                         $(_tmp.extend($features);)*
368                         _tmp
369                     },
370                 }).expect("expected to build -- essential tool")
371             }
372         }
373         )+
374     }
375 }
376
377 bootstrap_tool!(
378     Rustbook, "src/tools/rustbook", "rustbook", features = rustbook_features();
379     UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen";
380     Tidy, "src/tools/tidy", "tidy";
381     Linkchecker, "src/tools/linkchecker", "linkchecker";
382     CargoTest, "src/tools/cargotest", "cargotest";
383     Compiletest, "src/tools/compiletest", "compiletest", llvm_tools = true;
384     BuildManifest, "src/tools/build-manifest", "build-manifest";
385     RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
386     RustInstaller, "src/tools/rust-installer", "fabricate", is_external_tool = true;
387     RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
388 );
389
390 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
391 pub struct ErrorIndex {
392     pub compiler: Compiler,
393 }
394
395 impl ErrorIndex {
396     pub fn command(builder: &Builder<'_>, compiler: Compiler) -> Command {
397         let mut cmd = Command::new(builder.ensure(ErrorIndex {
398             compiler
399         }));
400         add_lib_path(
401             vec![PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host))],
402             &mut cmd,
403         );
404         cmd
405     }
406 }
407
408 impl Step for ErrorIndex {
409     type Output = PathBuf;
410
411     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
412         run.path("src/tools/error_index_generator")
413     }
414
415     fn make_run(run: RunConfig<'_>) {
416         // Compile the error-index in the same stage as rustdoc to avoid
417         // recompiling rustdoc twice if we can.
418         let stage = if run.builder.top_stage >= 2 { run.builder.top_stage } else { 0 };
419         run.builder.ensure(ErrorIndex {
420             compiler: run.builder.compiler(stage, run.builder.config.build),
421         });
422     }
423
424     fn run(self, builder: &Builder<'_>) -> PathBuf {
425         builder.ensure(ToolBuild {
426             compiler: self.compiler,
427             target: self.compiler.host,
428             tool: "error_index_generator",
429             mode: Mode::ToolRustc,
430             path: "src/tools/error_index_generator",
431             is_optional_tool: false,
432             source_type: SourceType::InTree,
433             extra_features: Vec::new(),
434         }).expect("expected to build -- essential tool")
435     }
436 }
437
438 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
439 pub struct RemoteTestServer {
440     pub compiler: Compiler,
441     pub target: Interned<String>,
442 }
443
444 impl Step for RemoteTestServer {
445     type Output = PathBuf;
446
447     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
448         run.path("src/tools/remote-test-server")
449     }
450
451     fn make_run(run: RunConfig<'_>) {
452         run.builder.ensure(RemoteTestServer {
453             compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
454             target: run.target,
455         });
456     }
457
458     fn run(self, builder: &Builder<'_>) -> PathBuf {
459         builder.ensure(ToolBuild {
460             compiler: self.compiler,
461             target: self.target,
462             tool: "remote-test-server",
463             mode: Mode::ToolStd,
464             path: "src/tools/remote-test-server",
465             is_optional_tool: false,
466             source_type: SourceType::InTree,
467             extra_features: Vec::new(),
468         }).expect("expected to build -- essential tool")
469     }
470 }
471
472 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
473 pub struct Rustdoc {
474     /// This should only ever be 0 or 2.
475     /// We sometimes want to reference the "bootstrap" rustdoc, which is why this option is here.
476     pub compiler: Compiler,
477 }
478
479 impl Step for Rustdoc {
480     type Output = PathBuf;
481     const DEFAULT: bool = true;
482     const ONLY_HOSTS: bool = true;
483
484     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
485         run.path("src/tools/rustdoc")
486     }
487
488     fn make_run(run: RunConfig<'_>) {
489         run.builder.ensure(Rustdoc {
490             compiler: run.builder.compiler(run.builder.top_stage, run.host),
491         });
492     }
493
494     fn run(self, builder: &Builder<'_>) -> PathBuf {
495         let target_compiler = self.compiler;
496         if target_compiler.stage == 0 {
497             if !target_compiler.is_snapshot(builder) {
498                 panic!("rustdoc in stage 0 must be snapshot rustdoc");
499             }
500             return builder.initial_rustc.with_file_name(exe("rustdoc", &target_compiler.host));
501         }
502         let target = target_compiler.host;
503         // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
504         // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
505         // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
506         // rustc compiler it's paired with, so it must be built with the previous stage compiler.
507         let build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build);
508
509         // The presence of `target_compiler` ensures that the necessary libraries (codegen backends,
510         // compiler libraries, ...) are built. Rustdoc does not require the presence of any
511         // libraries within sysroot_libdir (i.e., rustlib), though doctests may want it (since
512         // they'll be linked to those libraries). As such, don't explicitly `ensure` any additional
513         // libraries here. The intuition here is that If we've built a compiler, we should be able
514         // to build rustdoc.
515
516         let cargo = prepare_tool_cargo(
517             builder,
518             build_compiler,
519             Mode::ToolRustc,
520             target,
521             "build",
522             "src/tools/rustdoc",
523             SourceType::InTree,
524             &[],
525         );
526
527         builder.info(&format!("Building rustdoc for stage{} ({})",
528             target_compiler.stage, target_compiler.host));
529         builder.run(&mut cargo.into());
530
531         // Cargo adds a number of paths to the dylib search path on windows, which results in
532         // the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
533         // rustdoc a different name.
534         let tool_rustdoc = builder.cargo_out(build_compiler, Mode::ToolRustc, target)
535             .join(exe("rustdoc_tool_binary", &target_compiler.host));
536
537         // don't create a stage0-sysroot/bin directory.
538         if target_compiler.stage > 0 {
539             let sysroot = builder.sysroot(target_compiler);
540             let bindir = sysroot.join("bin");
541             t!(fs::create_dir_all(&bindir));
542             let bin_rustdoc = bindir.join(exe("rustdoc", &*target_compiler.host));
543             let _ = fs::remove_file(&bin_rustdoc);
544             builder.copy(&tool_rustdoc, &bin_rustdoc);
545             bin_rustdoc
546         } else {
547             tool_rustdoc
548         }
549     }
550 }
551
552 #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
553 pub struct Cargo {
554     pub compiler: Compiler,
555     pub target: Interned<String>,
556 }
557
558 impl Step for Cargo {
559     type Output = PathBuf;
560     const DEFAULT: bool = true;
561     const ONLY_HOSTS: bool = true;
562
563     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
564         let builder = run.builder;
565         run.path("src/tools/cargo").default_condition(builder.config.extended)
566     }
567
568     fn make_run(run: RunConfig<'_>) {
569         run.builder.ensure(Cargo {
570             compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
571             target: run.target,
572         });
573     }
574
575     fn run(self, builder: &Builder<'_>) -> PathBuf {
576         builder.ensure(ToolBuild {
577             compiler: self.compiler,
578             target: self.target,
579             tool: "cargo",
580             mode: Mode::ToolRustc,
581             path: "src/tools/cargo",
582             is_optional_tool: false,
583             source_type: SourceType::Submodule,
584             extra_features: Vec::new(),
585         }).expect("expected to build -- essential tool")
586     }
587 }
588
589 macro_rules! tool_extended {
590     (($sel:ident, $builder:ident),
591        $($name:ident,
592        $toolstate:ident,
593        $path:expr,
594        $tool_name:expr,
595        $extra_deps:block;)+) => {
596         $(
597             #[derive(Debug, Clone, Hash, PartialEq, Eq)]
598         pub struct $name {
599             pub compiler: Compiler,
600             pub target: Interned<String>,
601             pub extra_features: Vec<String>,
602         }
603
604         impl Step for $name {
605             type Output = Option<PathBuf>;
606             const DEFAULT: bool = true;
607             const ONLY_HOSTS: bool = true;
608
609             fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
610                 let builder = run.builder;
611                 run.path($path).default_condition(builder.config.extended)
612             }
613
614             fn make_run(run: RunConfig<'_>) {
615                 run.builder.ensure($name {
616                     compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
617                     target: run.target,
618                     extra_features: Vec::new(),
619                 });
620             }
621
622             #[allow(unused_mut)]
623             fn run(mut $sel, $builder: &Builder<'_>) -> Option<PathBuf> {
624                 $extra_deps
625                 $builder.ensure(ToolBuild {
626                     compiler: $sel.compiler,
627                     target: $sel.target,
628                     tool: $tool_name,
629                     mode: Mode::ToolRustc,
630                     path: $path,
631                     extra_features: $sel.extra_features,
632                     is_optional_tool: true,
633                     source_type: SourceType::Submodule,
634                 })
635             }
636         }
637         )+
638     }
639 }
640
641 tool_extended!((self, builder),
642     Cargofmt, rustfmt, "src/tools/rustfmt", "cargo-fmt", {};
643     CargoClippy, clippy, "src/tools/clippy", "cargo-clippy", {};
644     Clippy, clippy, "src/tools/clippy", "clippy-driver", {};
645     Miri, miri, "src/tools/miri", "miri", {};
646     CargoMiri, miri, "src/tools/miri", "cargo-miri", {};
647     Rls, rls, "src/tools/rls", "rls", {
648         let clippy = builder.ensure(Clippy {
649             compiler: self.compiler,
650             target: self.target,
651             extra_features: Vec::new(),
652         });
653         if clippy.is_some() {
654             self.extra_features.push("clippy".to_owned());
655         }
656     };
657     Rustfmt, rustfmt, "src/tools/rustfmt", "rustfmt", {};
658 );
659
660 impl<'a> Builder<'a> {
661     /// Gets a `Command` which is ready to run `tool` in `stage` built for
662     /// `host`.
663     pub fn tool_cmd(&self, tool: Tool) -> Command {
664         let mut cmd = Command::new(self.tool_exe(tool));
665         let compiler = self.compiler(0, self.config.build);
666         let host = &compiler.host;
667         // Prepares the `cmd` provided to be able to run the `compiler` provided.
668         //
669         // Notably this munges the dynamic library lookup path to point to the
670         // right location to run `compiler`.
671         let mut lib_paths: Vec<PathBuf> = vec![
672             self.build.rustc_snapshot_libdir(),
673             self.cargo_out(compiler, Mode::ToolBootstrap, *host).join("deps"),
674         ];
675
676         // On MSVC a tool may invoke a C compiler (e.g., compiletest in run-make
677         // mode) and that C compiler may need some extra PATH modification. Do
678         // so here.
679         if compiler.host.contains("msvc") {
680             let curpaths = env::var_os("PATH").unwrap_or_default();
681             let curpaths = env::split_paths(&curpaths).collect::<Vec<_>>();
682             for &(ref k, ref v) in self.cc[&compiler.host].env() {
683                 if k != "PATH" {
684                     continue
685                 }
686                 for path in env::split_paths(v) {
687                     if !curpaths.contains(&path) {
688                         lib_paths.push(path);
689                     }
690                 }
691             }
692         }
693
694         add_lib_path(lib_paths, &mut cmd);
695         cmd
696     }
697 }