about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2025-03-11 11:53:57 +0100
committerJakub Beránek <berykubik@gmail.com>2025-03-11 15:33:56 +0100
commit75a69a48f3aebaaa7cb3ce2ffcd3816f10895f70 (patch)
tree6b20fca30a05be4aca3ddb5ebf145a75e387ab46 /src/bootstrap
parentdcc2b307dc3b4807fb9a1fb2ef8c26396bb8649b (diff)
downloadrust-75a69a48f3aebaaa7cb3ce2ffcd3816f10895f70.tar.gz
rust-75a69a48f3aebaaa7cb3ce2ffcd3816f10895f70.zip
Do not download GCC in tests
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/core/build_steps/gcc.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/bootstrap/src/core/build_steps/gcc.rs b/src/bootstrap/src/core/build_steps/gcc.rs
index 7e1ec39659a..5a4bc9bdbcb 100644
--- a/src/bootstrap/src/core/build_steps/gcc.rs
+++ b/src/bootstrap/src/core/build_steps/gcc.rs
@@ -13,11 +13,9 @@ use std::path::{Path, PathBuf};
 use std::sync::OnceLock;
 
 use build_helper::ci::CiEnv;
-use build_helper::git::get_closest_merge_commit;
 
-use crate::Config;
 use crate::core::builder::{Builder, Cargo, Kind, RunConfig, ShouldRun, Step};
-use crate::core::config::{GccCiMode, TargetSelection};
+use crate::core::config::TargetSelection;
 use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash};
 use crate::utils::exec::command;
 use crate::utils::helpers::{self, t};
@@ -93,9 +91,10 @@ pub enum GccBuildStatus {
 /// Tries to download GCC from CI if it is enabled and GCC artifacts
 /// are available for the given target.
 /// Returns a path to the libgccjit.so file.
+#[cfg(not(test))]
 fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<PathBuf> {
     // Try to download GCC from CI if configured and available
-    if !matches!(builder.config.gcc_ci_mode, GccCiMode::DownloadFromCi) {
+    if !matches!(builder.config.gcc_ci_mode, crate::core::config::GccCiMode::DownloadFromCi) {
         return None;
     }
     if target != "x86_64-unknown-linux-gnu" {
@@ -114,6 +113,11 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
     Some(root.join("libgccjit.so"))
 }
 
+#[cfg(test)]
+fn try_download_gcc(_builder: &Builder<'_>, _target: TargetSelection) -> Option<PathBuf> {
+    None
+}
+
 /// This returns information about whether GCC should be built or if it's already built.
 /// It transparently handles downloading GCC from CI if needed.
 ///
@@ -247,12 +251,16 @@ pub fn add_cg_gcc_cargo_flags(cargo: &mut Cargo, gcc: &GccOutput) {
 }
 
 /// The absolute path to the downloaded GCC artifacts.
-fn ci_gcc_root(config: &Config) -> PathBuf {
+#[cfg(not(test))]
+fn ci_gcc_root(config: &crate::Config) -> PathBuf {
     config.out.join(config.build).join("ci-gcc")
 }
 
 /// This retrieves the GCC sha we *want* to use, according to git history.
-fn detect_gcc_sha(config: &Config, is_git: bool) -> String {
+#[cfg(not(test))]
+fn detect_gcc_sha(config: &crate::Config, is_git: bool) -> String {
+    use build_helper::git::get_closest_merge_commit;
+
     let gcc_sha = if is_git {
         get_closest_merge_commit(
             Some(&config.src),