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