Skip to content

Commit 9c16548

Browse files
Clean code and move check for GCC backend build in dist.rs directly
1 parent 2c4aa29 commit 9c16548

File tree

2 files changed

+6
-89
lines changed

2 files changed

+6
-89
lines changed

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,9 @@ impl Step for RustDev {
22732273
tarball.permit_symlinks(true);
22742274

22752275
builder.ensure(crate::core::build_steps::llvm::Llvm { target });
2276-
builder.ensure(crate::core::build_steps::gcc::Gcc { target });
2276+
if target.contains("linux") && target.contains("x86_64") {
2277+
builder.ensure(crate::core::build_steps::gcc::Gcc { target });
2278+
}
22772279

22782280
let src_bindir = builder.llvm_out(target).join("bin");
22792281
// If updating this, you likely want to change

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

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,12 @@ pub enum GccBuildStatus {
3535
/// It's used to avoid busting caches during x.py check -- if we've already built
3636
/// GCC, it's fine for us to not try to avoid doing so.
3737
pub fn prebuilt_gcc_config(builder: &Builder<'_>, target: TargetSelection) -> GccBuildStatus {
38-
// If we have gcc submodule initialized already, sync it.
39-
builder.update_existing_submodule("src/gcc");
38+
// Initialize the gcc submodule if not initialized already.
39+
builder.update_submodule("src/gcc");
4040

4141
// FIXME (GuillaumeGomez): To be done once gccjit has been built in the CI.
4242
// builder.config.maybe_download_ci_gcc();
4343

44-
// Initialize the gcc submodule if not initialized already.
45-
builder.update_submodule("src/gcc");
46-
4744
let root = "src/gcc";
4845
let out_dir = builder.gcc_out(target).join("build");
4946
let install_dir = builder.gcc_out(target).join("install");
@@ -77,84 +74,6 @@ pub fn prebuilt_gcc_config(builder: &Builder<'_>, target: TargetSelection) -> Gc
7774
GccBuildStatus::ShouldBuild(Meta { stamp, out_dir, install_dir, root: root.into() })
7875
}
7976

80-
// FIXME (GuillaumeGomez): When gcc-ci-download option is added, uncomment this code.
81-
// /// This retrieves the GCC sha we *want* to use, according to git history.
82-
// pub(crate) fn detect_gcc_sha(config: &Config, is_git: bool) -> String {
83-
// let gcc_sha = if is_git {
84-
// // We proceed in 2 steps. First we get the closest commit that is actually upstream. Then we
85-
// // walk back further to the last bors merge commit that actually changed GCC. The first
86-
// // step will fail on CI because only the `auto` branch exists; we just fall back to `HEAD`
87-
// // in that case.
88-
// let closest_upstream = get_git_merge_base(&config.git_config(), Some(&config.src))
89-
// .unwrap_or_else(|_| "HEAD".into());
90-
// let mut rev_list = config.git();
91-
// rev_list.args(&[
92-
// PathBuf::from("rev-list"),
93-
// format!("--author={}", config.stage0_metadata.config.git_merge_commit_email).into(),
94-
// "-n1".into(),
95-
// "--first-parent".into(),
96-
// closest_upstream.into(),
97-
// "--".into(),
98-
// config.src.join("src/gcc"),
99-
// config.src.join("src/bootstrap/download-ci-gcc-stamp"),
100-
// // the GCC shared object file is named `gcc-12-rust-{version}-nightly`
101-
// config.src.join("src/version"),
102-
// ]);
103-
// output(&mut rev_list).trim().to_owned()
104-
// } else if let Some(info) = channel::read_commit_info_file(&config.src) {
105-
// info.sha.trim().to_owned()
106-
// } else {
107-
// "".to_owned()
108-
// };
109-
110-
// if gcc_sha.is_empty() {
111-
// eprintln!("error: could not find commit hash for downloading GCC");
112-
// eprintln!("HELP: maybe your repository history is too shallow?");
113-
// eprintln!("HELP: consider disabling `download-ci-gcc`");
114-
// eprintln!("HELP: or fetch enough history to include one upstream commit");
115-
// panic!();
116-
// }
117-
118-
// gcc_sha
119-
// }
120-
121-
// /// Returns whether the CI-found GCC is currently usable.
122-
// ///
123-
// /// This checks both the build triple platform to confirm we're usable at all,
124-
// /// and then verifies if the current HEAD matches the detected GCC SHA head,
125-
// /// in which case GCC is indicated as not available.
126-
// pub(crate) fn is_ci_gcc_available(config: &Config, asserts: bool) -> bool {
127-
// let supported_platforms = [
128-
// // tier 1
129-
// ("x86_64-unknown-linux-gnu", true),
130-
// ];
131-
132-
// if !supported_platforms.contains(&(&*config.build.triple, asserts))
133-
// && (asserts || !supported_platforms.contains(&(&*config.build.triple, true)))
134-
// {
135-
// return false;
136-
// }
137-
138-
// if is_ci_gcc_modified(config) {
139-
// eprintln!("Detected GCC as non-available: running in CI and modified GCC in this change");
140-
// return false;
141-
// }
142-
143-
// true
144-
// }
145-
146-
// /// Returns true if we're running in CI with modified GCC (and thus can't download it)
147-
// pub(crate) fn is_ci_gcc_modified(config: &Config) -> bool {
148-
// CiEnv::is_ci() && config.rust_info.is_managed_git_subrepository() && {
149-
// // We assume we have access to git, so it's okay to unconditionally pass
150-
// // `true` here.
151-
// let gcc_sha = detect_gcc_sha(config, true);
152-
// let head_sha = output(config.git().arg("rev-parse").arg("HEAD"));
153-
// let head_sha = head_sha.trim();
154-
// gcc_sha == head_sha
155-
// }
156-
// }
157-
15877
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
15978
pub struct Gcc {
16079
pub target: TargetSelection,
@@ -176,12 +95,8 @@ impl Step for Gcc {
17695
/// Compile GCC for `target`.
17796
fn run(self, builder: &Builder<'_>) -> bool {
17897
let target = self.target;
179-
if !target.contains("linux") || !target.contains("x86_64") {
180-
return false;
181-
}
18298

183-
// If GCC has already been built or been downloaded through download-ci-gcc, we avoid
184-
// building it again.
99+
// If GCC has already been built, we avoid building it again.
185100
let Meta { stamp, out_dir, install_dir, root } = match prebuilt_gcc_config(builder, target)
186101
{
187102
GccBuildStatus::AlreadyBuilt => return true,

0 commit comments

Comments
 (0)