Skip to content
Myr

Do not rebuild on RUSTC_BOOTSTRAP changes on nightly compiler

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 2d32366 · Browse files · 1 file+45 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+45 added−4 removed

  • other:+45 added−4 removed

1 file+45 added−4 removed

modified:build.rs+45 added-4 removed
11 unmodified lines
12fn main() {13 let mut error_generic_member_access = false;14 if cfg!(feature = "std") {15 println!("cargo:rerun-if-changed=build/probe.rs");16 println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP");1617 let consider_rustc_bootstrap;18 if compile_probe(false) {19 // This is a nightly or dev compiler, so it supports unstable20 // features regardless of RUSTC_BOOTSTRAP. No need to rerun build21 // script if RUSTC_BOOTSTRAP is changed.22 error_generic_member_access = true;23 consider_rustc_bootstrap = false;24 } else if let Some(rustc_bootstrap) = env::var_os("RUSTC_BOOTSTRAP") {18 if compile_probe() {25 if compile_probe(true) {26 // This is a stable or beta compiler for which the user has set27 // RUSTC_BOOTSTRAP to turn on unstable features. Rerun build28 // script if they change it.29 error_generic_member_access = true;30 consider_rustc_bootstrap = true;31 } else if rustc_bootstrap == "1" {32 // This compiler does not support the generic member access API33 // in the form that anyhow expects. No need to pay attention to34 // RUSTC_BOOTSTRAP.35 error_generic_member_access = false;36 consider_rustc_bootstrap = false;37 } else {38 // This is a stable or beta compiler for which RUSTC_BOOTSTRAP39 // is set to restrict the use of unstable features by this40 // crate.41 error_generic_member_access = false;42 consider_rustc_bootstrap = true;43 }44 } else {45 // Without RUSTC_BOOTSTRAP, this compiler does not support the46 // generic member access API in the form that anyhow expects, but47 // try again if the user turns on unstable features.48 error_generic_member_access = false;49 consider_rustc_bootstrap = true;50 }5152 if error_generic_member_access {53 println!("cargo:rustc-cfg=std_backtrace");54 println!("cargo:rustc-cfg=error_generic_member_access");21 error_generic_member_access = true;55 }5657 if consider_rustc_bootstrap {58 println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP");59 }60 }6162 let rustc = match rustc_minor_version() {63 Some(rustc) => rustc,
22 unmodified lines
86 println!("cargo:rustc-cfg=std_backtrace");87 }88}8953fn compile_probe() -> bool {90fn compile_probe(rustc_bootstrap: bool) -> bool {91 if env::var_os("RUSTC_STAGE").is_some() {92 // We are running inside rustc bootstrap. This is a highly non-standard93 // environment with issues such as:94 //
17 unmodified lines
112 } else {113 Command::new(rustc)114 };115116 if !rustc_bootstrap {117 cmd.env_remove("RUSTC_BOOTSTRAP");118 }119120 cmd.stderr(Stdio::null())121 .arg("--edition=2018")122 .arg("--crate-name=anyhow")123 .arg("--crate-type=lib")
44 unmodified lines