Skip to content

Commit 1c38c46

Browse files
committed
check host's libstdc++ version when using ci llvm
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]>
1 parent b54dd08 commit 1c38c46

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.0.0

src/bootstrap/src/core/sanity.rs

+16
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ pub fn check(build: &mut Build) {
9999
cmd_finder.must_have("git");
100100
}
101101

102+
if !build.config.dry_run() && build.config.llvm_from_ci {
103+
let cxx = build.cxx(build.build).unwrap();
104+
let mut cxx_cmd = Command::new(cxx);
105+
cxx_cmd.arg("-dumpversion");
106+
107+
let current_libstdcpp_v = semver::Version::parse(output(&mut cxx_cmd).trim()).unwrap();
108+
let libstdcpp_v_threshold = semver::Version::parse(include_str!("../../ci-llvm-libstdcpp-version-threshold")).unwrap();
109+
110+
if current_libstdcpp_v.lt(&libstdcpp_v_threshold) {
111+
eprintln!("\nCurrent libstdc++ version is '{current_libstdcpp_v}', which is too old and below the required threshold of '{libstdcpp_v_threshold}'.");
112+
// 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.
113+
eprintln!("If you think this is a mistake, you can bypass this sanity check by setting 'BOOTSTRAP_SKIP_TARGET_SANITY' env variable to '1'.");
114+
crate::exit!(1);
115+
}
116+
}
117+
102118
// We need cmake, but only if we're actually building LLVM or sanitizers.
103119
let building_llvm = build
104120
.hosts

0 commit comments

Comments
 (0)