Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 75a69a4

Browse files
committedMar 11, 2025
Do not download GCC in tests
1 parent dcc2b30 commit 75a69a4

File tree

1 file changed

+14
-6
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+14
-6
lines changed
 

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

+14-6
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ use std::path::{Path, PathBuf};
1313
use std::sync::OnceLock;
1414

1515
use build_helper::ci::CiEnv;
16-
use build_helper::git::get_closest_merge_commit;
1716

18-
use crate::Config;
1917
use crate::core::builder::{Builder, Cargo, Kind, RunConfig, ShouldRun, Step};
20-
use crate::core::config::{GccCiMode, TargetSelection};
18+
use crate::core::config::TargetSelection;
2119
use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash};
2220
use crate::utils::exec::command;
2321
use crate::utils::helpers::{self, t};
@@ -93,9 +91,10 @@ pub enum GccBuildStatus {
9391
/// Tries to download GCC from CI if it is enabled and GCC artifacts
9492
/// are available for the given target.
9593
/// Returns a path to the libgccjit.so file.
94+
#[cfg(not(test))]
9695
fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<PathBuf> {
9796
// Try to download GCC from CI if configured and available
98-
if !matches!(builder.config.gcc_ci_mode, GccCiMode::DownloadFromCi) {
97+
if !matches!(builder.config.gcc_ci_mode, crate::core::config::GccCiMode::DownloadFromCi) {
9998
return None;
10099
}
101100
if target != "x86_64-unknown-linux-gnu" {
@@ -114,6 +113,11 @@ fn try_download_gcc(builder: &Builder<'_>, target: TargetSelection) -> Option<Pa
114113
Some(root.join("libgccjit.so"))
115114
}
116115

116+
#[cfg(test)]
117+
fn try_download_gcc(_builder: &Builder<'_>, _target: TargetSelection) -> Option<PathBuf> {
118+
None
119+
}
120+
117121
/// This returns information about whether GCC should be built or if it's already built.
118122
/// It transparently handles downloading GCC from CI if needed.
119123
///
@@ -247,12 +251,16 @@ pub fn add_cg_gcc_cargo_flags(cargo: &mut Cargo, gcc: &GccOutput) {
247251
}
248252

249253
/// The absolute path to the downloaded GCC artifacts.
250-
fn ci_gcc_root(config: &Config) -> PathBuf {
254+
#[cfg(not(test))]
255+
fn ci_gcc_root(config: &crate::Config) -> PathBuf {
251256
config.out.join(config.build).join("ci-gcc")
252257
}
253258

254259
/// This retrieves the GCC sha we *want* to use, according to git history.
255-
fn detect_gcc_sha(config: &Config, is_git: bool) -> String {
260+
#[cfg(not(test))]
261+
fn detect_gcc_sha(config: &crate::Config, is_git: bool) -> String {
262+
use build_helper::git::get_closest_merge_commit;
263+
256264
let gcc_sha = if is_git {
257265
get_closest_merge_commit(
258266
Some(&config.src),

0 commit comments

Comments
 (0)
Failed to load comments.