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