Filter host libstdc++ ABI flag in rustc_llvm cross builds

This commit is contained in:
Xuntao Chi
2026-07-05 17:45:55 +08:00
parent ea088e0a3d
commit b1a5d8592f
+14
View File
@@ -160,6 +160,12 @@ impl<'a> IntoIterator for &'a LlvmConfigOutput {
}
}
fn is_libstdcxx_cxx11_abi_flag(flag: &str) -> bool {
flag == "-D_GLIBCXX_USE_CXX11_ABI"
|| flag.starts_with("-D_GLIBCXX_USE_CXX11_ABI=")
|| flag == "-U_GLIBCXX_USE_CXX11_ABI"
}
fn main() {
if cfg!(feature = "check_only") {
return;
@@ -255,6 +261,14 @@ fn main() {
continue;
}
// This is a libstdc++ implementation detail for the C++ library that
// built the runnable llvm-config. When cross-compiling, target LLVM may
// have been built against a target libstdc++ with a different default.
// Let the target compiler/toolchain select its ABI instead.
if is_crossed && is_libstdcxx_cxx11_abi_flag(flag.as_ref()) {
continue;
}
if flag.starts_with("-flto") {
continue;
}