Skip to content

Commit

Permalink
check host's libstdc++ version when using ci llvm
Browse files Browse the repository at this point in the history
If the host's libstdc++ version is too old using ci-llvm may result in an ABI mismatch
between the local libstdc++ and libLLVM.so. This PR adds a sanity check to immediately fail
at the beginning of the bootstrap before starting the actual build. I am not sure if '8.0.0'
is the best threshold, but it should be a good start and we can increase it anytime if needed.

Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed May 22, 2024
1 parent b54dd08 commit f2d2bc4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bootstrap/ci-llvm-libstdcpp-version-threshold
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0.0
16 changes: 16 additions & 0 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f2d2bc4

Please sign in to comment.