Skip to content

Commit

Permalink
Fix build determinism issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Jul 28, 2024
1 parent 3e220e7 commit fdd5d84
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion llamafile/zipalign.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ static void GetDosLocalTime(int64_t utcunixts, uint16_t *out_time, uint16_t *out
*out_date = DOS_DATE(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
}

static int NormalizeMode(int mode) {
int res = mode & S_IFMT;
if (mode & 0111)
res |= 0111;
return res | 0644;
}

int main(int argc, char *argv[]) {

if (llamafile_has(argv, "-h") || llamafile_has(argv, "-help") ||
Expand Down Expand Up @@ -402,7 +409,7 @@ int main(int argc, char *argv[]) {
p = ZIP_WRITE16(p, 0); // comment length
p = ZIP_WRITE16(p, 0); // disk number start
p = ZIP_WRITE16(p, kZipIattrBinary);
p = ZIP_WRITE32(p, st.st_mode << 16); // external file attributes
p = ZIP_WRITE32(p, NormalizeMode(st.st_mode) << 16); // external file attributes
p = ZIP_WRITE32(p, 0xffffffffu); // lfile offset
p = mempcpy(p, name, namlen);

Expand Down

0 comments on commit fdd5d84

Please sign in to comment.