diff --git a/src/bootstrap/ci-llvm-libstdcpp-version-threshold b/src/bootstrap/ci-llvm-libstdcpp-version-threshold new file mode 100644 index 0000000000000..ae9a76b9249ad --- /dev/null +++ b/src/bootstrap/ci-llvm-libstdcpp-version-threshold @@ -0,0 +1 @@ +8.0.0 diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 9c3df6fa9e39b..8132776fdd9e5 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -99,6 +99,22 @@ pub fn check(build: &mut Build) { cmd_finder.must_have("git"); } + if !build.config.dry_run() && build.config.llvm_from_ci { + let cxx = build.cxx(build.build).unwrap(); + let mut cxx_cmd = Command::new(cxx); + cxx_cmd.arg("-dumpversion"); + + let current_libstdcpp_v = semver::Version::parse(output(&mut cxx_cmd).trim()).unwrap(); + let libstdcpp_v_threshold = semver::Version::parse(include_str!("../../ci-llvm-libstdcpp-version-threshold")).unwrap(); + + if current_libstdcpp_v.lt(&libstdcpp_v_threshold) { + eprintln!("\nCurrent libstdc++ version is '{current_libstdcpp_v}', which is too old and below the required threshold of '{libstdcpp_v_threshold}'."); + // In case the user has a custom setup that includes a recent libstdc++ with an old c++ compiler, this information might be useful to them. + eprintln!("If you think this is a mistake, you can bypass this sanity check by setting 'BOOTSTRAP_SKIP_TARGET_SANITY' env variable to '1'."); + crate::exit!(1); + } + } + // We need cmake, but only if we're actually building LLVM or sanitizers. let building_llvm = build .hosts