Skip to content

Commit 745047d

Browse files
committed
remove crc dependency to support compiling with cranelift
1 parent 31e543f commit 745047d

File tree

3 files changed

+57
-22
lines changed

3 files changed

+57
-22
lines changed

Cargo.lock

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,13 @@ temporal_capi = { version = "0.1.0", features = ["zoneinfo64"] }
111111

112112
[build-dependencies]
113113
miniz_oxide = "0.8.8"
114-
gzip-header = "1.0.0"
115114
fslock = "0.2"
116115
which = "6"
117116
home = "0"
118117
bindgen = "0.72"
119118

120119
[dev-dependencies]
121120
miniz_oxide = "0.8.8"
122-
gzip-header = "1.0.0"
123121
bytes = "1"
124122
align-data = "0.1.0"
125123
fslock = "0.2"

build.rs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,62 @@ fn download_static_lib_binaries() {
688688
download_file(&url, &static_lib_path());
689689
}
690690

691+
/// Skip the gzip header without validating CRC.
692+
/// This avoids depending on crc32fast which uses hardware CRC intrinsics
693+
/// that aren't supported by all rustc backends (e.g., cranelift on aarch64).
694+
fn skip_gzip_header<R: Read>(input: &mut R) -> io::Result<()> {
695+
let mut header = [0u8; 10];
696+
input.read_exact(&mut header)?;
697+
698+
// Validate magic bytes (0x1f 0x8b) and compression method (8 = deflate)
699+
if header[0] != 0x1f || header[1] != 0x8b {
700+
return Err(io::Error::other("Invalid gzip magic"));
701+
}
702+
if header[2] != 8 {
703+
return Err(io::Error::other("Unsupported compression method"));
704+
}
705+
706+
let flags = header[3];
707+
708+
// FEXTRA - extra field
709+
if flags & 0x04 != 0 {
710+
let mut len = [0u8; 2];
711+
input.read_exact(&mut len)?;
712+
let extra_len = u16::from_le_bytes(len) as u64;
713+
io::copy(&mut input.by_ref().take(extra_len), &mut io::sink())?;
714+
}
715+
716+
// FNAME - original filename, null-terminated
717+
if flags & 0x08 != 0 {
718+
let mut byte = [0u8; 1];
719+
loop {
720+
input.read_exact(&mut byte)?;
721+
if byte[0] == 0 {
722+
break;
723+
}
724+
}
725+
}
726+
727+
// FCOMMENT - comment, null-terminated
728+
if flags & 0x10 != 0 {
729+
let mut byte = [0u8; 1];
730+
loop {
731+
input.read_exact(&mut byte)?;
732+
if byte[0] == 0 {
733+
break;
734+
}
735+
}
736+
}
737+
738+
// FHCRC - header CRC16 (skip without validating)
739+
if flags & 0x02 != 0 {
740+
let mut crc = [0u8; 2];
741+
input.read_exact(&mut crc)?;
742+
}
743+
744+
Ok(())
745+
}
746+
691747
fn decompress_to_writer<R, W>(input: &mut R, output: &mut W) -> io::Result<()>
692748
where
693749
R: Read,
@@ -699,7 +755,7 @@ where
699755
let mut input_offset = 0;
700756

701757
// Skip the gzip header
702-
gzip_header::read_gz_header(input)?;
758+
skip_gzip_header(input)?;
703759

704760
loop {
705761
let bytes_read = input.read(&mut input_buffer[input_offset..])?;

0 commit comments

Comments
 (0)