Skip to content

chore: Cache random stuff #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/enzyme-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ jobs:
with:
path: build/build/x86_64-unknown-linux-gnu/enzyme
key: ${{ matrix.os }}-enzyme-${{ steps.enzyme-commit.outputs.HEAD }}
- name: Cache bootstrap/stage0 artifacts for incremental builds
uses: actions/cache@v4
with:
path: |
build/build/bootstrap/
build/build/x86_64-unknown-linux-gnu/stage0-rustc/
build/build/x86_64-unknown-linux-gnu/stage0-std/
build/build/x86_64-unknown-linux-gnu/stage0-tools/
build/build/x86_64-unknown-linux-gnu/stage1-std/
# Approximate stable hash. It doesn't matter too much when this goes out of sync as it just caches
# some stage0/stage1 dependencies and stdlibs which *hopefully* are hash-keyed.
key: enzyme-rust-incremental-${{ runner.os }}-${{ hashFiles('src/**/Cargo.lock', 'Cargo.lock') }}
restore-keys: |
enzyme-rust-incremental-${{ runner.os }}
- name: Build
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,12 @@ impl HashStamp {

fn is_done(&self) -> bool {
match fs::read(&self.path) {
Ok(h) => self.hash.as_deref().unwrap_or(b"") == h.as_slice(),
Ok(h) => {
let unwrapped = self.hash.as_deref().unwrap_or(b"");
let res = unwrapped == h.as_slice();
eprintln!("Result for {:?}: {res:?} for expected '{unwrapped:?}' and read '{h:?}'", self.path);
res
},
Err(e) if e.kind() == io::ErrorKind::NotFound => false,
Err(e) => {
panic!("failed to read stamp file `{}`: {}", self.path.display(), e);
Expand Down
11 changes: 10 additions & 1 deletion src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,9 @@ pub fn generate_smart_stamp_hash(dir: &Path, additional_input: &str) -> String {
.map(|o| String::from_utf8(o.stdout).unwrap_or_default())
.unwrap_or_default();

eprintln!("Computing stamp for {dir:?}");
eprintln!("Diff output: {diff:?}");

let status = Command::new("git")
.current_dir(dir)
.arg("status")
Expand All @@ -1876,13 +1879,19 @@ pub fn generate_smart_stamp_hash(dir: &Path, additional_input: &str) -> String {
.map(|o| String::from_utf8(o.stdout).unwrap_or_default())
.unwrap_or_default();

eprintln!("Status output: {status:?}");
eprintln!("Additional input: {additional_input:?}");
let mut hasher = sha2::Sha256::new();

hasher.update(diff);
hasher.update(status);
hasher.update(additional_input);

hex_encode(hasher.finalize().as_slice())
let result = hex_encode(hasher.finalize().as_slice());

eprintln!("Final hash: {result:?}");

result
}

/// Ensures that the behavior dump directory is properly initialized.
Expand Down
Loading