cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.71k stars 375 forks source link

`zstd` v0.11.2 with feature "thin" failed on armv7/aarch64 musl and glibc due to missing symbols #1075

Open NobodyXu opened 2 years ago

NobodyXu commented 2 years ago

Checklist

Describe your issue

Enabling feature "thin" on zstd v0.11.2 caused the armv7/aarch64 build for musl and glibc to fail due to missing symbols.

https://github.com/cargo-bins/cargo-binstall/pull/480

What target(s) are you cross-compiling for?

aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl, armv7-unknown-linux-gnueabihf, armv7-unknown-linux-musleabihf

Which operating system is the host (e.g computer cross is on) running?

What architecture is the host?

What container engine is cross using?

cross version

cross 0.2.4

Example

No response

Additional information / notes

No response

Emilgardis commented 2 years ago

The only thing this changes is (I think) https://github.com/gyscos/zstd-rs/blob/94f79b0a7b2c4ffc4b8732bd180e662f453f72ef/zstd-safe/zstd-sys/build.rs#L138-L145

Emilgardis commented 2 years ago

Need to try this on a real machine

NobodyXu commented 2 years ago

Might be related to this https://github.com/gyscos/zstd-rs/pull/172/files

After I added fallback to -flto=thin (-flto) and fallback to -Oz (-Os and -O2), CI for x86-64-unknown-linux-gnu suddenly failed.

Alexhuszagh commented 2 years ago

@NobodyXu Can you post the missing symbols?

NobodyXu commented 2 years ago

The error looks something like this:

  = note: /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libbinstall_zip-3ec920b13b440940.rlib(binstall_zip-3ec920b13b440940.binstall_zip.2d8b1d46-cgu.14.rcgu.o): in function `zstd_safe::DCtx::decompress_stream':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:907: undefined reference to `ZSTD_decompressStream'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libzstd_safe-9534da256530e36e.rlib(zstd_safe-9534da256530e36e.zstd_safe.5be749e1-cgu.9.rcgu.o): in function `zstd_safe::is_error':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:66: undefined reference to `ZSTD_isError'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libzstd_safe-9534da256530e36e.rlib(zstd_safe-9534da256530e36e.zstd_safe.5be749e1-cgu.9.rcgu.o): in function `zstd_safe::get_error_name':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:665: undefined reference to `ZSTD_getErrorName'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libzstd_safe-9534da256530e36e.rlib(zstd_safe-9534da256530e36e.zstd_safe.5be749e1-cgu.9.rcgu.o): in function `zstd_safe::DCtx::try_create':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:707: undefined reference to `ZSTD_createDCtx'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libzstd_safe-9534da256530e36e.rlib(zstd_safe-9534da256530e36e.zstd_safe.5be749e1-cgu.9.rcgu.o): in function `zstd_safe::DCtx::init':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:784: undefined reference to `ZSTD_initDStream'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libzstd_safe-9534da256530e36e.rlib(zstd_safe-9534da256530e36e.zstd_safe.5be749e1-cgu.9.rcgu.o): in function `zstd_safe::DCtx::reset':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:822: undefined reference to `ZSTD_DCtx_reset'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libzstd_safe-9534da256530e36e.rlib(zstd_safe-9534da256530e36e.zstd_safe.5be749e1-cgu.9.rcgu.o): in function `zstd_safe::DCtx::load_dictionary':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:832: undefined reference to `ZSTD_DCtx_loadDictionary'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libzstd_safe-9534da256530e36e.rlib(zstd_safe-9534da256530e36e.zstd_safe.5be749e1-cgu.9.rcgu.o): in function `zstd_safe::DCtx::in_size':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:920: undefined reference to `ZSTD_DStreamInSize'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /target/armv7-unknown-linux-musleabihf/debug/deps/libzstd_safe-9534da256530e36e.rlib(zstd_safe-9534da256530e36e.zstd_safe.5be749e1-cgu.9.rcgu.o): in function `<zstd_safe::DCtx as core::ops::drop::Drop>::drop':
          /cargo/registry/src/index.crates.io-e139d0d48fed7772/zstd-safe-5.0.2+zstd.1.5.2/src/lib.rs:993: undefined reference to `ZSTD_freeDCtx'
          collect2: error: ld returned 1 exit status

It's missing ZSTD_* symbols, which should be provided by zstd-sys but somehow enabling feature "thin" cause them to be missing.