|
32 | 32 | //! [instructions]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script
|
33 | 33 |
|
34 | 34 | use super::{fingerprint, BuildRunner, Job, Unit, Work};
|
35 |
| -use crate::core::compiler::artifact; |
36 | 35 | use crate::core::compiler::build_runner::Metadata;
|
37 | 36 | use crate::core::compiler::fingerprint::DirtyReason;
|
38 | 37 | use crate::core::compiler::job_queue::JobState;
|
| 38 | +use crate::core::compiler::{artifact, CompileKind}; |
39 | 39 | use crate::core::{profiles::ProfileRoot, PackageId, Target};
|
40 | 40 | use crate::util::errors::CargoResult;
|
41 | 41 | use crate::util::machine_message::{self, Message};
|
@@ -317,6 +317,15 @@ fn build_work(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResul
|
317 | 317 | cmd.env("CARGO_TRIM_PATHS", trim_paths.to_string());
|
318 | 318 | }
|
319 | 319 |
|
| 320 | + // Pass along sysroots used by the host/target. |
| 321 | + let host_sysroot = &bcx.target_data.info(CompileKind::Host).sysroot; |
| 322 | + let target_sysroot = match unit.kind { |
| 323 | + CompileKind::Host => host_sysroot, |
| 324 | + CompileKind::Target(_) => &bcx.target_data.info(unit.kind).sysroot, |
| 325 | + }; |
| 326 | + cmd.env("RUSTC_HOST_SYSROOT", host_sysroot); |
| 327 | + cmd.env("RUSTC_TARGET_SYSROOT", target_sysroot); |
| 328 | + |
320 | 329 | // Be sure to pass along all enabled features for this package, this is the
|
321 | 330 | // last piece of statically known information that we have.
|
322 | 331 | for feat in &unit.features {
|
|
0 commit comments