Skip to content
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

Replace zlib with zlib-rs #8839

Merged
merged 1 commit into from
Mar 7, 2025
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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
[submodule "libcxx"]
path = native/src/external/libcxx
url = https://github.com/topjohnwu/libcxx.git
[submodule "zlib"]
path = native/src/external/zlib
url = https://android.googlesource.com/platform/external/zlib
[submodule "zopfli"]
path = native/src/external/zopfli
url = https://github.com/google/zopfli.git
Expand Down
1 change: 0 additions & 1 deletion native/src/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ LOCAL_STATIC_LIBRARIES := \
liblzma \
liblz4 \
libbz2 \
libz \
libzopfli \
libboot-rs

Expand Down
16 changes: 16 additions & 0 deletions native/src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions native/src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ syn = "2"
quote = "1"
proc-macro2 = "1"
argh = { version = "0.1.13", default-features = false }
libz-rs-sys = { version = "0.4.2", default-features = false, features=["c-allocator"] }

# Pin version to prevent cargo update break builds
block-buffer = "=0.11.0-rc.3"
Expand Down
1 change: 1 addition & 0 deletions native/src/boot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ der = { workspace = true, features = ["derive", "pem"] }
fdt = { workspace = true }
bytemuck = { workspace = true, features = ["derive", "min_const_generics"] }
num-traits = { workspace = true }
libz-rs-sys = { workspace = true }
4 changes: 2 additions & 2 deletions native/src/boot/compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class zopfli_encoder : public chunk_out_stream {
public:
explicit zopfli_encoder(out_strm_ptr &&base) :
chunk_out_stream(std::move(base), ZOPFLI_MASTER_BLOCK_SIZE),
zo{}, out(nullptr), outsize(0), crc(crc32_z(0L, Z_NULL, 0)), in_total(0), bp(0) {
zo{}, out(nullptr), outsize(0), crc(crc32(0L, Z_NULL, 0)), in_total(0), bp(0) {
ZopfliInitOptions(&zo);

// This config is already better than gzip -9
Expand Down Expand Up @@ -198,7 +198,7 @@ class zopfli_encoder : public chunk_out_stream {
auto in = static_cast<const unsigned char *>(buf);

in_total += len;
crc = crc32_z(crc, in, len);
crc = crc32(crc, in, len);

ZopfliDeflatePart(&zo, 2, final, in, 0, len, &bp, &out, &outsize);

Expand Down
1 change: 1 addition & 0 deletions native/src/boot/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![feature(iter_intersperse)]
#![feature(try_blocks)]

pub use libz_rs_sys::*;
pub use base;
use cpio::cpio_commands;
use dtb::dtb_commands;
Expand Down
27 changes: 0 additions & 27 deletions native/src/external/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -233,33 +233,6 @@ LOCAL_SRC_FILES := \
lsplt/lsplt/src/main/jni/lsplt.cc
include $(BUILD_STATIC_LIBRARY)

# libz.a
include $(CLEAR_VARS)
LOCAL_MODULE:= libz
LOCAL_C_INCLUDES := $(LOCAL_PATH)/zlib
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_CFLAGS := \
-DHAVE_HIDDEN -DZLIB_CONST -Wall -Werror \
-Wno-unused -Wno-unused-parameter -Wno-deprecated-non-prototype
LOCAL_SRC_FILES := \
zlib/adler32.c \
zlib/compress.c \
zlib/cpu_features.c \
zlib/crc32.c \
zlib/deflate.c \
zlib/gzclose.c \
zlib/gzlib.c \
zlib/gzread.c \
zlib/gzwrite.c \
zlib/infback.c \
zlib/inffast.c \
zlib/inflate.c \
zlib/inftrees.c \
zlib/trees.c \
zlib/uncompr.c \
zlib/zutil.c
include $(BUILD_STATIC_LIBRARY)

# libzopfli.a
include $(CLEAR_VARS)
LOCAL_MODULE:= libzopfli
Expand Down
1 change: 0 additions & 1 deletion native/src/external/zlib
Submodule zlib deleted from 3a0aa2