Skip to content

Commit 1bf2381

Browse files
committed
WIP
1 parent abc7c5e commit 1bf2381

File tree

1 file changed

+28
-24
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+28
-24
lines changed

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

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use std::fs;
1212
use std::path::PathBuf;
1313
use std::sync::OnceLock;
1414

15+
use build_helper::ci::CiEnv;
16+
1517
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
1618
use crate::core::config::TargetSelection;
1719
use crate::utils::exec::command;
@@ -112,21 +114,24 @@ impl Step for Gcc {
112114
return true;
113115
}
114116

115-
let deps_dir = out_dir.join("deps");
116-
t!(fs::create_dir_all(&deps_dir));
117-
118-
// Download dependencies into the build directory, to avoid modifying the source directory
119-
// The configure script should automatically find them in the build directory
120-
command(root.join("contrib/download_prerequisites"))
121-
// The script sadly tries to write symlinks to the source directory, even if we
122-
// actually download the dependencies elsewhere.
123-
// .allow_failure()
124-
.current_dir(&root)
125-
// .arg("--directory")
126-
// .arg(&deps_dir)
127-
.run(builder);
128-
129-
let mut configure_cmd = command(root.join("configure"));
117+
// GCC creates files (e.g. symlinks to the downloaded dependencies)
118+
// in the source directory, which does not work with our CI setup, where we mount
119+
// source directories as read-only on Linux.
120+
// Therefore, as a part of the build in CI, we first copy the whole source directory
121+
// to the build directory, and perform the build from there.
122+
let src_dir = if CiEnv::is_ci() {
123+
let src_dir = builder.gcc_out(target).join("src");
124+
if src_dir.exists() {
125+
builder.remove_dir(&src_dir);
126+
}
127+
builder.cp_link_r(&root, &src_dir);
128+
src_dir
129+
} else {
130+
root
131+
};
132+
133+
command(src_dir.join("contrib/download_prerequisites")).current_dir(&src_dir).run(builder);
134+
let mut configure_cmd = command(src_dir.join("configure"));
130135
configure_cmd
131136
.current_dir(&out_dir)
132137
.arg("--enable-host-shared")
@@ -135,20 +140,19 @@ impl Step for Gcc {
135140
.arg("--disable-bootstrap")
136141
.arg("--disable-multilib")
137142
.arg(format!("--prefix={}", install_dir.display()));
138-
let cc = builder.build.cc(target).display().to_string();
139-
// if let Some(ref ccache) = builder.build.config.ccache {
140-
// cc = format!("{ccache} {cc}");
141-
// }
143+
let mut cc = builder.build.cc(target).display().to_string();
144+
if let Some(ref ccache) = builder.build.config.ccache {
145+
cc = format!("{ccache} {cc}");
146+
}
142147
configure_cmd.env("CC", cc);
143148

144149
if let Ok(ref cxx) = builder.build.cxx(target) {
145-
let cxx = cxx.display().to_string();
146-
// if let Some(ref ccache) = builder.build.config.ccache {
147-
// cxx = format!("{ccache} {cxx}");
148-
// }
150+
let mut cxx = cxx.display().to_string();
151+
if let Some(ref ccache) = builder.build.config.ccache {
152+
cxx = format!("{ccache} {cxx}");
153+
}
149154
configure_cmd.env("CXX", cxx);
150155
}
151-
152156
configure_cmd.run(builder);
153157

154158
command("make").current_dir(&out_dir).arg(format!("-j{}", builder.jobs())).run(builder);

0 commit comments

Comments
 (0)