Ensure that GCC is not built using Clang, as it misbehaves

This commit is contained in:
Jakub Beránek
2025-03-14 09:16:06 +01:00
parent 38fc11601e
commit bf095f6ece
2 changed files with 20 additions and 6 deletions
+9 -6
View File
@@ -184,6 +184,14 @@ fn libgccjit_built_path(install_dir: &Path) -> PathBuf {
}
fn build_gcc(metadata: &Meta, builder: &Builder<'_>, target: TargetSelection) {
if builder.build.cc_tool(target).is_like_clang()
|| builder.build.cxx_tool(target).is_like_clang()
{
panic!(
"Attempting to build GCC using Clang, which is known to misbehave. Please use GCC as the host C/C++ compiler. "
);
}
let Meta { stamp: _, out_dir, install_dir, root } = metadata;
t!(fs::create_dir_all(out_dir));
@@ -210,18 +218,13 @@ fn build_gcc(metadata: &Meta, builder: &Builder<'_>, target: TargetSelection) {
let mut configure_cmd = command(src_dir.join("configure"));
configure_cmd
.current_dir(out_dir)
// On CI, we compile GCC with Clang.
// The -Wno-everything flag is needed to make GCC compile with Clang 19.
// `-g -O2` are the default flags that are otherwise used by Make.
// FIXME(kobzol): change the flags once we have [gcc] configuration in config.toml.
.env("CXXFLAGS", "-Wno-everything -g -O2")
.env("CFLAGS", "-Wno-everything -g -O2")
.arg("--enable-host-shared")
.arg("--enable-languages=c,jit,lto")
.arg("--enable-checking=release")
.arg("--disable-bootstrap")
.arg("--disable-multilib")
.arg(format!("--prefix={}", install_dir.display()));
let cc = builder.build.cc(target).display().to_string();
let cc = builder
.build
+11
View File
@@ -27,6 +27,7 @@
use build_helper::ci::gha;
use build_helper::exit;
use cc::Tool;
use termcolor::{ColorChoice, StandardStream, WriteColor};
use utils::build_stamp::BuildStamp;
use utils::channel::GitInfo;
@@ -1218,6 +1219,16 @@ fn cc(&self, target: TargetSelection) -> PathBuf {
self.cc.borrow()[&target].path().into()
}
/// Returns the internal `cc::Tool` for the C compiler.
fn cc_tool(&self, target: TargetSelection) -> Tool {
self.cc.borrow()[&target].clone()
}
/// Returns the internal `cc::Tool` for the C++ compiler.
fn cxx_tool(&self, target: TargetSelection) -> Tool {
self.cxx.borrow()[&target].clone()
}
/// Returns C flags that `cc-rs` thinks should be enabled for the
/// specified target by default.
fn cc_handled_clags(&self, target: TargetSelection, c: CLang) -> Vec<String> {