|
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, Context, Job, Unit, Work};
|
35 |
| -use crate::core::compiler::artifact; |
| 35 | +use crate::core::compiler::{artifact, CompileKind}; |
36 | 36 | use crate::core::compiler::context::Metadata;
|
37 | 37 | use crate::core::compiler::job_queue::JobState;
|
38 | 38 | use crate::core::{profiles::ProfileRoot, PackageId, Target};
|
@@ -316,6 +316,15 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
|
316 | 316 | cmd.env("CARGO_TRIM_PATHS", trim_paths.to_string());
|
317 | 317 | }
|
318 | 318 |
|
| 319 | + // Pass along sysroots used by the host/target. |
| 320 | + let host_sysroot = &bcx.target_data.info(CompileKind::Host).sysroot; |
| 321 | + let target_sysroot = match unit.kind { |
| 322 | + CompileKind::Host => host_sysroot, |
| 323 | + CompileKind::Target(_) => &bcx.target_data.info(unit.kind).sysroot |
| 324 | + }; |
| 325 | + cmd.env("RUSTC_HOST_SYSROOT", host_sysroot); |
| 326 | + cmd.env("RUSTC_TARGET_SYSROOT", target_sysroot); |
| 327 | + |
319 | 328 | // Be sure to pass along all enabled features for this package, this is the
|
320 | 329 | // last piece of statically known information that we have.
|
321 | 330 | for feat in &unit.features {
|
|
0 commit comments