Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A way for cargo to build crates locally or remotely and share and fine-grained--cache them via a Docker registry.

License

Notifications You must be signed in to change notification settings

fenollp/supergreen

Repository files navigation

Faster Rust builds!

  • cargo-green: Cargo plugin and $RUSTC_WRAPPER to sandbox, cache & remote exec cargo builds

A rusty crab character named Ferris, featuring a unique hairstyle resembling 'Ruby Road', a vibrant and textured hairdo often seen in flamboyant red

Goals

  • seamlessly build on another machine (with more cores, more cache)
    • support remote builds by setting env DOCKER_HOST= with e.g. ssh://[email protected]
      • Build cache is saved remotely, artifacts are saved locally
      • Tests building happens on remote machine, execution happens on local machine
  • seamlessly integrate with normal cargo usage
    • only pull sources from local filesystem
    • produce the same intermediary artefacts as local cargo does
    • fallback to normal, local rustc anytime
      • switching from this wrapper back to local rustc does necessitate a fresh build
  • wrap rustc calls in buildkit-like calls (docker, podman)
    • docker
    • podman
    • deps compatibility
      • handle Rust-only deps
      • handle all the other deps (expand this list) (use crater)
        • C deps
        • ...
    • runner compatibility
      • set .dockerignores (to be authoritative on srcs)
    • trace these outputs (STDOUT/STDERR) for debugging
  • available as a rustc wrapper through $RUSTC_WRAPPER
  • available as a cargo subcommand
    • configuration profiles (user, team, per-workspace, per-crate, CI, ...)
    • seamlessly use current/local rustc version
      • support overriding rustc base image
    • seamlessly use current/local tools (mold, ...)
      • config expressions on top of base image config?
      • just suggest an inline Dockerfile stage?
    • support CRUD-ish operations on local/remotes cache
    • [SEC] support building a crate without it having network access
  • integrate with shipping OCI images
  • share cache with the World cf. user-wide-cache
    • never rebuild a dep (for a given version of rustc, ...)
      • ensure finest cache granularity (crate-level)
      • free users from cache key built from Cargo.lock (changes on every release cut!)
    • share cache with other projects on local machine
      • fix WORKDIRs + rewrite paths with remap-path-prefix
    • share cache with CI and team
      • share cache with CI (at least for a single user)
    • [SEC] ensure private deps don't leak through/to cache
    • CLI gives the Dockerfile that cargo install's any crate
  • suggest a global cache -faciliting configuration profile
  • integrate with cross
    • build for a non-local target
    • run/test for a non-local target (with cross's same caveats ie. QEMU)

Upstream issues & patches

Origins

Hacking

./hack/cli.sh ...

# Usage:           $0                              #=> generate CI
#
# Usage:           $0 ( <name@version> | <name> )  #=> cargo install name@version
# Usage:           $0   ok                         #=> cargo install all working bins
#
# Usage:           $0 ( build | test )             #=> cargo build ./cargo-green
#
# Usage:    jobs=1 $0 ..                           #=> cargo --jobs=$jobs
# Usage: offline=1 $0 ..                           #=> cargo --frozen (defaults to just: --locked)
# Usage:    rmrf=1 $0 ..                           #=> rm -rf $CARGO_TARGET_DIR/*; cargo ...
# Usage:   reset=1 $0 ..                           #=> docker buildx rm $BUILDX_BUILDER; cargo ...
# Usage:   clean=1 $0 ..                           #=> Both reset=1 + rmrf=1
# Usage:   final=1 $0 ..                           #=> Generate final Containerfile
#
# Usage:    DOCKER_HOST=.. $0 ..                   #=> Overrides machine
# Usage: BUILDX_BUILDER=.. $0 ..                   #=> Overrides builder (set to "empty" to set BUILDX_BUILDER='')

./hack/recipes.sh

Syncs ./recipes/*.Dockerfile files.

./hack/caching.sh

Verifies properties about caching crates & granularity.

docker buildx prune --all --force

./hack/hit.sh

Estimate of amount of crates reused through compilation of ./recipes/ --> ~5%! Expecting more with larger/more representative corpus + smart locking of transitive deps.

recipes/[email protected]
8< 8< 8<
3: dep-l-utf8parse-0.2.1-522ff71b25340e24
5: dep-l-bitflags-1.3.2-70ce9f1f2fa253bc
5: dep-l-strsim-0.10.0-fd42a4ea370e31ec
5: dep-l-unicode-ident-1.0.12-4c1dc76c11b3deb8
6: dep-l-cfg-if-1.0.0-da34da6838abd7f1

Total recipes: 15
Total stages: 1065
Stages in common: 58
5.44%

When git-bisecting

all:
	cargo +nightly fmt --all
	./hack/clis.sh | tee .github/workflows/clis.yml
	./hack/self.sh | tee .github/workflows/self.yml
	CARGO_TARGET_DIR=$${CARGO_TARGET_DIR:-target/clippy} cargo clippy --locked --frozen --offline --all-targets --all-features -- --no-deps -W clippy::cast_lossless -W clippy::redundant_closure_for_method_calls -W clippy::str_to_string -W clippy::unnecessary_wraps
	RUST_MIN_STACK=8000000 cargo nextest run --all-targets --all-features --locked --frozen --offline --no-fail-fast
	git --no-pager diff --exit-code

About

A way for cargo to build crates locally or remotely and share and fine-grained--cache them via a Docker registry.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •  

Languages