Skip to content

Commit bf095f6

Browse files
committed
Ensure that GCC is not built using Clang, as it misbehaves
1 parent 38fc116 commit bf095f6

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/bootstrap/src/core/build_steps/gcc.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ fn libgccjit_built_path(install_dir: &Path) -> PathBuf {
184184
}
185185

186186
fn build_gcc(metadata: &Meta, builder: &Builder<'_>, target: TargetSelection) {
187+
if builder.build.cc_tool(target).is_like_clang()
188+
|| builder.build.cxx_tool(target).is_like_clang()
189+
{
190+
panic!(
191+
"Attempting to build GCC using Clang, which is known to misbehave. Please use GCC as the host C/C++ compiler. "
192+
);
193+
}
194+
187195
let Meta { stamp: _, out_dir, install_dir, root } = metadata;
188196

189197
t!(fs::create_dir_all(out_dir));
@@ -210,18 +218,13 @@ fn build_gcc(metadata: &Meta, builder: &Builder<'_>, target: TargetSelection) {
210218
let mut configure_cmd = command(src_dir.join("configure"));
211219
configure_cmd
212220
.current_dir(out_dir)
213-
// On CI, we compile GCC with Clang.
214-
// The -Wno-everything flag is needed to make GCC compile with Clang 19.
215-
// `-g -O2` are the default flags that are otherwise used by Make.
216-
// FIXME(kobzol): change the flags once we have [gcc] configuration in config.toml.
217-
.env("CXXFLAGS", "-Wno-everything -g -O2")
218-
.env("CFLAGS", "-Wno-everything -g -O2")
219221
.arg("--enable-host-shared")
220222
.arg("--enable-languages=c,jit,lto")
221223
.arg("--enable-checking=release")
222224
.arg("--disable-bootstrap")
223225
.arg("--disable-multilib")
224226
.arg(format!("--prefix={}", install_dir.display()));
227+
225228
let cc = builder.build.cc(target).display().to_string();
226229
let cc = builder
227230
.build

src/bootstrap/src/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use std::{env, fs, io, str};
2727

2828
use build_helper::ci::gha;
2929
use build_helper::exit;
30+
use cc::Tool;
3031
use termcolor::{ColorChoice, StandardStream, WriteColor};
3132
use utils::build_stamp::BuildStamp;
3233
use utils::channel::GitInfo;
@@ -1218,6 +1219,16 @@ Executed at: {executed_at}"#,
12181219
self.cc.borrow()[&target].path().into()
12191220
}
12201221

1222+
/// Returns the internal `cc::Tool` for the C compiler.
1223+
fn cc_tool(&self, target: TargetSelection) -> Tool {
1224+
self.cc.borrow()[&target].clone()
1225+
}
1226+
1227+
/// Returns the internal `cc::Tool` for the C++ compiler.
1228+
fn cxx_tool(&self, target: TargetSelection) -> Tool {
1229+
self.cxx.borrow()[&target].clone()
1230+
}
1231+
12211232
/// Returns C flags that `cc-rs` thinks should be enabled for the
12221233
/// specified target by default.
12231234
fn cc_handled_clags(&self, target: TargetSelection, c: CLang) -> Vec<String> {

0 commit comments

Comments
 (0)