Skip to content

Commit df2a263

Browse files
authoredMar 4, 2025
Rollup merge of #137667 - Kobzol:gcc-dist-build, r=onur-ozkan
Add `dist::Gcc` build step This PR adds a `dist:Gcc` bootstrap step to distribute a prebuilt `libgccjit.so` from CI on x64 Linux. With primed sccache, the build takes ~4 minutes on CI, and produces a 50 MiB archive. I want to land this before adding something akin to `[gcc] download-ci-gcc = true`, to already have the artifacts available on CI, to make it easier to setup the download merge-base logic. r? ``@ghost``
2 parents dd594f6 + e4bfad2 commit df2a263

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed
 

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

+27
Original file line numberDiff line numberDiff line change
@@ -2464,3 +2464,30 @@ impl Step for ReproducibleArtifacts {
24642464
if added_anything { Some(tarball.generate()) } else { None }
24652465
}
24662466
}
2467+
2468+
/// Tarball containing a prebuilt version of the libgccjit library,
2469+
/// needed as a dependency for the GCC codegen backend (similarly to the LLVM
2470+
/// backend needing a prebuilt libLLVM).
2471+
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
2472+
pub struct Gcc {
2473+
pub target: TargetSelection,
2474+
}
2475+
2476+
impl Step for Gcc {
2477+
type Output = GeneratedTarball;
2478+
2479+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2480+
run.alias("gcc")
2481+
}
2482+
2483+
fn make_run(run: RunConfig<'_>) {
2484+
run.builder.ensure(Gcc { target: run.target });
2485+
}
2486+
2487+
fn run(self, builder: &Builder<'_>) -> Self::Output {
2488+
let tarball = Tarball::new(builder, "gcc", &self.target.triple);
2489+
let output = builder.ensure(super::gcc::Gcc { target: self.target });
2490+
tarball.add_file(output.libgccjit, ".", 0o644);
2491+
tarball.generate()
2492+
}
2493+
}

‎src/bootstrap/src/core/builder/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ impl<'a> Builder<'a> {
10721072
dist::PlainSourceTarball,
10731073
dist::BuildManifest,
10741074
dist::ReproducibleArtifacts,
1075+
dist::Gcc
10751076
),
10761077
Kind::Install => describe!(
10771078
install::Docs,

‎src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ENV SCRIPT python3 ../x.py build --set rust.debug=true opt-dist && \
101101
./build/$HOSTS/stage0-tools-bin/opt-dist linux-ci -- python3 ../x.py dist \
102102
--host $HOSTS --target $HOSTS \
103103
--include-default-paths \
104-
build-manifest bootstrap
104+
build-manifest bootstrap gcc
105105
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
106106

107107
# This is the only builder which will create source tarballs

‎src/tools/opt-dist/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ fn main() -> anyhow::Result<()> {
389389
"clippy",
390390
"miri",
391391
"rustfmt",
392+
"gcc",
392393
] {
393394
build_args.extend(["--skip".to_string(), target.to_string()]);
394395
}

0 commit comments

Comments
 (0)
Please sign in to comment.