|
106 | 106 | use std::cell::{Cell, RefCell};
|
107 | 107 | use std::collections::{HashMap, HashSet};
|
108 | 108 | use std::env;
|
| 109 | +use std::env::consts::EXE_SUFFIX; |
109 | 110 | use std::fs::{self, File};
|
110 | 111 | use std::path::{Path, PathBuf};
|
111 | 112 | use std::process::{self, Command};
|
@@ -450,15 +451,10 @@ impl Build {
|
450 | 451 | let bootstrap_out = if std::env::var("BOOTSTRAP_PYTHON").is_ok() {
|
451 | 452 | out.join("bootstrap").join("debug")
|
452 | 453 | } else {
|
453 |
| - let workspace_target_dir = std::env::var("CARGO_TARGET_DIR") |
| 454 | + std::env::var("CARGO_TARGET_DIR") |
454 | 455 | .map(PathBuf::from)
|
455 |
| - .unwrap_or_else(|_| src.join("target")); |
456 |
| - let bootstrap_out = workspace_target_dir.join("debug"); |
457 |
| - if !bootstrap_out.join("rustc").exists() && !cfg!(test) { |
458 |
| - // this restriction can be lifted whenever https://github.com/rust-lang/rfcs/pull/3028 is implemented |
459 |
| - panic!("run `cargo build --bins` before `cargo run`") |
460 |
| - } |
461 |
| - bootstrap_out |
| 456 | + .unwrap_or_else(|_| src.join("target")) |
| 457 | + .join("debug") |
462 | 458 | };
|
463 | 459 |
|
464 | 460 | let mut build = Build {
|
@@ -502,6 +498,20 @@ impl Build {
|
502 | 498 | tool_artifacts: Default::default(),
|
503 | 499 | };
|
504 | 500 |
|
| 501 | + let bootstrap_out = &build.bootstrap_out; |
| 502 | + let dispatcher = bootstrap_out.join(format!("rustbuild-binary-dispatch-shim{EXE_SUFFIX}")); |
| 503 | + if dispatcher.exists() && !cfg!(test) { |
| 504 | + build.copy(&dispatcher, &bootstrap_out.join(format!("bootstrap{EXE_SUFFIX}"))); |
| 505 | + build.copy(&dispatcher, &bootstrap_out.join(format!("rustc{EXE_SUFFIX}"))); |
| 506 | + build.copy(&dispatcher, &bootstrap_out.join(format!("rustdoc{EXE_SUFFIX}"))); |
| 507 | + build.copy(&dispatcher, &bootstrap_out.join(format!("sccache-plus-cl{EXE_SUFFIX}"))); |
| 508 | + build |
| 509 | + .copy(&dispatcher, &bootstrap_out.join(format!("llvm-config-wrapper{EXE_SUFFIX}"))); |
| 510 | + } else if !cfg!(test) { |
| 511 | + // tests do not need these files to be copied. |
| 512 | + panic!("bootstrap binary shim ({}) does not exist", dispatcher.display()); |
| 513 | + } |
| 514 | + |
505 | 515 | build.verbose("finding compilers");
|
506 | 516 | cc_detect::find(&mut build);
|
507 | 517 | // When running `setup`, the profile is about to change, so any requirements we have now may
|
|
0 commit comments