Conversation
832c52d to
d136b17
Compare
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces Cargo build caching functionality to improve Rust compilation performance by implementing sccache (Shared Compilation Cache) support across various targets and platforms.
- Adds automatic Cargo cache injection when Rust dependencies are detected
- Implements sccache-based caching for Rust/Cargo builds with cross-platform support
- Integrates test coverage for the new Cargo caching functionality
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| cache.go | Defines CargoBuildCache types, constants, and sccache installation logic |
| generator_cargohome.go | Updates cargo home generation to support sccache binary caching |
| docs/spec.schema.json | Adds schema definitions for the new CargoBuildCache configuration |
| targets/windows/handle_zip.go | Implements Windows-specific cargo cache setup and sccache environment |
| targets/linux/deb/distro/pkg.go | Adds cargo cache support for Debian packaging with alternative Rust paths |
| targets/linux/rpm/distro/pkg.go | Implements cargo cache support for RPM packaging |
| packaging/linux/deb/debroot.go | Sets up sccache environment in Debian build scripts |
| packaging/linux/rpm/rpmbuild.go | Integrates cargo cache setup in RPM build process |
| test/cache_test.go | Adds comprehensive test cases for cargo build caching |
| test/linux_target_test.go | Adds cargo cache test integration for Linux targets |
| test/windows_test.go | Adds cargo cache test and package override for Windows |
| helpers.go | Adds HasRust helper function to detect Rust dependencies |
| load_test.go | Updates validation error messages to include cargobuild |
| targets/linux/deb/debian/bullseye.go | Updates Debian archive URL (unrelated change) |
4576ec2 to
385239d
Compare
686ea7f to
bc50a0f
Compare
366c9fb to
706b3a8
Compare
0e7cb18 to
2524101
Compare
cpuguy83
left a comment
There was a problem hiding this comment.
This is also going to need changes to the website caching docs.
cache.go
Outdated
| BazelDefaultSocketID = "bazel-default" // Default ID for bazel socket | ||
|
|
||
| // SccacheVersion defines the version of sccache to install | ||
| SccacheVersion = "v0.10.0" |
There was a problem hiding this comment.
Do we need all these exported vars?
There was a problem hiding this comment.
Can you unexport these values? It seems like they aren't used outside of this package.
cache.go
Outdated
| // Set up a simple environment variable to enable sccache | ||
| llb.AddEnv("RUSTC_WRAPPER", sccacheBinary).SetRunOption(ei) | ||
|
|
||
| // Create a symbolic link from /usr/local/bin/sccache to the actual binary |
There was a problem hiding this comment.
Comment about symbolic link doesn't seem correct since this is mounting the actual binary.
targets/linux/deb/distro/pkg.go
Outdated
| } | ||
|
|
||
| if addCargoCache { | ||
| spec.Build.Caches = append(spec.Build.Caches, dalec.CacheConfig{ |
There was a problem hiding this comment.
This should only add a cargo cache if its not already there.
targets/linux/deb/distro/pkg.go
Outdated
| }) | ||
| } | ||
|
|
||
| cargoBin, err := searchForAltRust(ctx, client, spec, targetKey, worker, opts...) |
There was a problem hiding this comment.
Was this needed for the change?
I know we have this for go because it was actually problematic (but unrelated to caching).
|
Help your reviewers by using PR descriptions and commit messages with full descriptions of what was changed and why. (For future commits to this PR, don't bother going back and adding descriptions to your old commits). |
cache.go
Outdated
| BazelDefaultSocketID = "bazel-default" // Default ID for bazel socket | ||
|
|
||
| // SccacheVersion defines the version of sccache to install | ||
| SccacheVersion = "v0.10.0" |
There was a problem hiding this comment.
Can you unexport these values? It seems like they aren't used outside of this package.
54571f9 to
767a726
Compare
cache.go
Outdated
| // sccache target architectures | ||
| sccacheArchLinuxX64 = "x86_64-unknown-linux-musl" | ||
| sccacheArchLinuxArm64 = "aarch64-unknown-linux-musl" | ||
| sccacheArchLinuxArmV7 = "armv7-unknown-linux-musleabihf" |
There was a problem hiding this comment.
This seems to be a mismatch with what's on the release page.
| sccacheArchLinuxArmV7 = "armv7-unknown-linux-musleabihf" | |
| sccacheArchLinuxArmV7 = "armv7-unknown-linux-musleabi" |
test/linux_target_test.go
Outdated
| testAutoGobuildCache(ctx, t, testConfig.Target) | ||
| }) | ||
|
|
||
| t.Run("auto cargobuild cache", func(t *testing.T) { |
There was a problem hiding this comment.
Test naming is no longer quite right.
Also rust cache
test/cache_test.go
Outdated
| }) | ||
| } | ||
|
|
||
| func testAutoCargobuildCache(ctx context.Context, t *testing.T, cfg targetConfig) { |
test/cache_test.go
Outdated
| } | ||
|
|
||
| testEnv.RunTest(ctx, t, func(ctx context.Context, client gwclient.Client) { | ||
| // Test that cargo cache is NOT automatically enabled (it's opt-in only now) |
There was a problem hiding this comment.
Comment is not neccessary, or could be updated to something along the lines of // test no cache
7e78ed8 to
c68fdd4
Compare
cpuguy83
left a comment
There was a problem hiding this comment.
Just one more set of minor things and this should be good to go!
test/windows_test.go
Outdated
| testAutoGobuildCache(ctx, t, tcfg) | ||
| }) | ||
|
|
||
| t.Run("auto rust cache", func(t *testing.T) { |
There was a problem hiding this comment.
Let's rename this test, it's just testing the rust caching (no auto)
test/linux_target_test.go
Outdated
| testAutoGobuildCache(ctx, t, testConfig.Target) | ||
| }) | ||
|
|
||
| t.Run("auto rust cache", func(t *testing.T) { |
There was a problem hiding this comment.
Let's rename this test, it's just testing the rust caching (no auto)
test/cache_test.go
Outdated
| }) | ||
| } | ||
|
|
||
| func testAutoRustCache(ctx context.Context, t *testing.T, cfg targetConfig) { |
There was a problem hiding this comment.
Let's rename this test, it's just testing the rust caching (no auto)
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, using
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when the PR gets merged):Fixes #612
Special notes for your reviewer: