authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-04 01:45:37-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-02-04 01:45:37-08:00
log3c7970dc4ec5529a59a2c6f768a63c6d3b676c91
tree4f0e607095afdd5cd651bbea592af2fb6f1c75bf
parentd3fc2648cc94f0e98ab1299711c02bb5b3f2864c
parent8fa7635419e557f0fbf5d1ca448a2d753b681740
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #18801 from jacobly0/fix-cache-retry

Cache: fix logic for retrying cache hits

2 files changed, 15 insertions(+), 6 deletions(-)

lib/std/Build/Cache.zig+2-2
...@@ -482,11 +482,11 @@ pub const Manifest = struct {...@@ -482,11 +482,11 @@ pub const Manifest = struct {
482482
483 self.want_refresh_timestamp = true;483 self.want_refresh_timestamp = true;
484484
485 while (true) {485 const input_file_count = self.files.items.len;
486 while (true) : (self.unhit(bin_digest, input_file_count)) {
486 const file_contents = try self.manifest_file.?.reader().readAllAlloc(gpa, manifest_file_size_max);487 const file_contents = try self.manifest_file.?.reader().readAllAlloc(gpa, manifest_file_size_max);
487 defer gpa.free(file_contents);488 defer gpa.free(file_contents);
488489
489 const input_file_count = self.files.items.len;
490 var any_file_changed = false;490 var any_file_changed = false;
491 var line_iter = mem.tokenizeScalar(u8, file_contents, '\n');491 var line_iter = mem.tokenizeScalar(u8, file_contents, '\n');
492 var idx: usize = 0;492 var idx: usize = 0;
stage1/wasi.c+13-4
...@@ -203,7 +203,9 @@ struct DirEntry {...@@ -203,7 +203,9 @@ struct DirEntry {
203static uint32_t fd_len;203static uint32_t fd_len;
204static struct FileDescriptor {204static struct FileDescriptor {
205 uint32_t de;205 uint32_t de;
206 enum wasi_fdflags fdflags;
206 FILE *stream;207 FILE *stream;
208 uint64_t fs_rights_inheriting;
207} *fds;209} *fds;
208210
209static void *dupe(const void *data, size_t len) {211static void *dupe(const void *data, size_t len) {
...@@ -707,13 +709,17 @@ uint32_t wasi_snapshot_preview1_path_filestat_get(uint32_t fd, uint32_t flags, u...@@ -707,13 +709,17 @@ uint32_t wasi_snapshot_preview1_path_filestat_get(uint32_t fd, uint32_t flags, u
707}709}
708710
709uint32_t wasi_snapshot_preview1_fd_fdstat_get(uint32_t fd, uint32_t res_fdstat) {711uint32_t wasi_snapshot_preview1_fd_fdstat_get(uint32_t fd, uint32_t res_fdstat) {
710 (void)fd;712 uint8_t *const m = *wasm_memory;
711 (void)res_fdstat;713 struct wasi_fdstat *res_fdstat_ptr = (struct wasi_fdstat *)&m[res_fdstat];
712#if LOG_TRACE714#if LOG_TRACE
713 fprintf(stderr, "wasi_snapshot_preview1_fd_fdstat_get(%u)\n", fd);715 fprintf(stderr, "wasi_snapshot_preview1_fd_fdstat_get(%u)\n", fd);
714#endif716#endif
715717
716 panic("unimplemented");718 if (fd >= fd_len || fds[fd].de >= de_len) return wasi_errno_badf;
719 res_fdstat_ptr->fs_filetype = des[fds[fd].de].filetype;
720 res_fdstat_ptr->fs_flags = fds[fd].fdflags;
721 res_fdstat_ptr->padding = 0;
722 res_fdstat_ptr->fs_rights_inheriting = fds[fd].fs_rights_inheriting;
717 return wasi_errno_success;723 return wasi_errno_success;
718}724}
719725
...@@ -770,7 +776,6 @@ uint32_t wasi_snapshot_preview1_fd_write(uint32_t fd, uint32_t iovs, uint32_t io...@@ -770,7 +776,6 @@ uint32_t wasi_snapshot_preview1_fd_write(uint32_t fd, uint32_t iovs, uint32_t io
770uint32_t wasi_snapshot_preview1_path_open(uint32_t fd, uint32_t dirflags, uint32_t path, uint32_t path_len, uint32_t oflags, uint64_t fs_rights_base, uint64_t fs_rights_inheriting, uint32_t fdflags, uint32_t res_fd) {776uint32_t wasi_snapshot_preview1_path_open(uint32_t fd, uint32_t dirflags, uint32_t path, uint32_t path_len, uint32_t oflags, uint64_t fs_rights_base, uint64_t fs_rights_inheriting, uint32_t fdflags, uint32_t res_fd) {
771 uint8_t *const m = *wasm_memory;777 uint8_t *const m = *wasm_memory;
772 const char *path_ptr = (const char *)&m[path];778 const char *path_ptr = (const char *)&m[path];
773 (void)fs_rights_inheriting;
774 uint32_t *res_fd_ptr = (uint32_t *)&m[res_fd];779 uint32_t *res_fd_ptr = (uint32_t *)&m[res_fd];
775#if LOG_TRACE780#if LOG_TRACE
776 fprintf(stderr, "wasi_snapshot_preview1_path_open(%u, 0x%X, \"%.*s\", 0x%X, 0x%llX, 0x%llX, 0x%X)\n", fd, dirflags, (int)path_len, path_ptr, oflags, (unsigned long long)fs_rights_base, (unsigned long long)fs_rights_inheriting, fdflags);781 fprintf(stderr, "wasi_snapshot_preview1_path_open(%u, 0x%X, \"%.*s\", 0x%X, 0x%llX, 0x%llX, 0x%X)\n", fd, dirflags, (int)path_len, path_ptr, oflags, (unsigned long long)fs_rights_base, (unsigned long long)fs_rights_inheriting, fdflags);
...@@ -792,10 +797,12 @@ uint32_t wasi_snapshot_preview1_path_open(uint32_t fd, uint32_t dirflags, uint32...@@ -792,10 +797,12 @@ uint32_t wasi_snapshot_preview1_path_open(uint32_t fd, uint32_t dirflags, uint32
792 fds = new_fds;797 fds = new_fds;
793798
794 fds[fd_len].de = de;799 fds[fd_len].de = de;
800 fds[fd_len].fdflags = fdflags;
795 switch (des[de].filetype) {801 switch (des[de].filetype) {
796 case wasi_filetype_directory: fds[fd_len].stream = NULL; break;802 case wasi_filetype_directory: fds[fd_len].stream = NULL; break;
797 default: panic("unimplemented");803 default: panic("unimplemented");
798 }804 }
805 fds[fd_len].fs_rights_inheriting = fs_rights_inheriting;
799806
800#if LOG_TRACE807#if LOG_TRACE
801 fprintf(stderr, "fd = %u\n", fd_len);808 fprintf(stderr, "fd = %u\n", fd_len);
...@@ -855,7 +862,9 @@ uint32_t wasi_snapshot_preview1_path_open(uint32_t fd, uint32_t dirflags, uint32...@@ -855,7 +862,9 @@ uint32_t wasi_snapshot_preview1_path_open(uint32_t fd, uint32_t dirflags, uint32
855 fprintf(stderr, "fd = %u\n", fd_len);862 fprintf(stderr, "fd = %u\n", fd_len);
856#endif863#endif
857 fds[fd_len].de = de;864 fds[fd_len].de = de;
865 fds[fd_len].fdflags = fdflags;
858 fds[fd_len].stream = stream;866 fds[fd_len].stream = stream;
867 fds[fd_len].fs_rights_inheriting = fs_rights_inheriting;
859 *res_fd_ptr = fd_len;868 *res_fd_ptr = fd_len;
860 fd_len += 1;869 fd_len += 1;
861 return wasi_errno_success;870 return wasi_errno_success;