alexcrichton / xz2-rs

Bindings to liblzma in Rust (xz streams in Rust)
Apache License 2.0
81 stars 52 forks source link

Optimize `liblzma.a` build #107

Open NobodyXu opened 1 year ago

NobodyXu commented 1 year ago

Signed-off-by: Jiahao XU Jiahao_XU@outlook.com

NobodyXu commented 1 year ago

The CI seems to be broken by new feature thin:

  running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "xz-5.2/src/liblzma/api" "-I" "xz-5.2/src/liblzma/lzma" "-I" "xz-5.2/src/liblzma/lz" "-I" "xz-5.2/src/liblzma/check" "-I" "xz-5.2/src/liblzma/simple" "-I" "xz-5.2/src/liblzma/delta" "-I" "xz-5.2/src/liblzma/common" "-I" "xz-5.2/src/liblzma/rangecoder" "-I" "xz-5.2/src/common" "-I" "/home/runner/work/xz2-rs/xz2-rs/lzma-sys" "-Wall" "-Wextra" "-std=c99" "-pthread" "-ffunction-sections" "-fdata-sections" "-fmerge-all-constants" "-Wl,--gc-sections" "-flto" "-DHAVE_CONFIG_H=1" "-DHAVE_SMALL=1" "-o" "/home/runner/work/xz2-rs/xz2-rs/target/debug/build/lzma-sys-817308151459d6e7/out/xz-5.2/src/liblzma/check/crc64_fast.o" "-c" "xz-5.2/src/liblzma/check/crc64_fast.c"
  cargo:warning=xz-5.2/src/liblzma/check/crc64_fast.c: In function ‘lzma_crc64’:
  cargo:warning=xz-5.2/src/liblzma/check/crc64_fast.c:40:31: error: ‘lzma_crc64_table’ undeclared (first use in this function); did you mean ‘lzma_crc32_table’?
  cargo:warning=   40 |                         crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
  cargo:warning=      |                               ^~~~~~~~~~~~~~~~
  cargo:warning=      |                               lzma_crc32_table
  cargo:warning=xz-5.2/src/liblzma/check/crc64_fast.c:40:31: note: each undeclared identifier is reported only once for each function it appears in

This is probably an upstream bug, since HAVE_THIN disables lzma_crc64_table and only keeps lzma_crc32_table here:

#ifdef HAVE_SMALL
extern uint32_t lzma_crc32_table[1][256];
extern void lzma_crc32_init(void);
#else
extern const uint32_t lzma_crc32_table[8][256];
extern const uint64_t lzma_crc64_table[4][256];
#endif
NobodyXu commented 1 year ago

I think upgrading xz to latest v5.4.1 might fix this.

NobodyXu commented 1 year ago

I think #108 might fix the error in this PR, so I would retry after that PR is merged.