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