rust-lang / libz-sys

Rust crate package to link to a system libz (zlib)
Apache License 2.0
117 stars 77 forks source link

Build fails on powerpc64 and powerpc64le: error: use of undeclared identifier 'power_cpu_has_arch_3_00' #183

Open yurivict opened 8 months ago

yurivict commented 8 months ago
  /wrkdirs/usr/ports/devel/gitoxide/work/gitoxide-git-repository-v0.32.0/cargo-crates/libz-sys-1.1.8/src/zlib-ng/functable.c:125:9: error: use of undeclared identifier 'power_cpu_has_arch_3_00'
      if (power_cpu_has_arch_3_00)
          ^
  /wrkdirs/usr/ports/devel/gitoxide/work/gitoxide-git-repository-v0.32.0/cargo-crates/libz-sys-1.1.8/src/zlib-ng/functable.c:158:9: error: use of undeclared identifier 'power_cpu_has_arch_3_00'
      if (power_cpu_has_arch_3_00)
          ^

See the log.

Version: 1.1.8 rust-1.75.0 FreeBSD 14.0

ofek commented 4 months ago

I also cannot build on PowerPC but am getting different errors:

error: failed to run custom build command for `libz-ng-sys v1.1.15`

Caused by:
  process didn't exit successfully: `/target/debug/build/libz-ng-sys-c4f0ab3fecb10f49/build-script-build_zng` (exit status: 101)

...

  /cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-ng-sys-1.1.15/src/zlib-ng/arch/power/compare256_power9.c: In function 'compare256_power9_static':
  /cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-ng-sys-1.1.15/src/zlib-ng/arch/power/compare256_power9.c:34:36: warning: implicit declaration of function 'vec_cmpne' [-Wimplicit-function-declaration]
           vc = (vector unsigned char)vec_cmpne(vsrc0, vsrc1);
                                      ^
  /cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-ng-sys-1.1.15/src/zlib-ng/arch/power/compare256_power9.c:34:9: error: AltiVec argument passed to unprototyped function
           vc = (vector unsigned char)vec_cmpne(vsrc0, vsrc1);
           ^
  /cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-ng-sys-1.1.15/src/zlib-ng/arch/power/compare256_power9.c:15:43: warning: implicit declaration of function '__builtin_vec_vctzlsbb' [-Wimplicit-function-declaration]
   #  define zng_vec_vctzlsbb(vc, len) len = __builtin_vec_vctzlsbb(vc)
                                             ^
  /cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-ng-sys-1.1.15/src/zlib-ng/arch/power/compare256_power9.c:39:9: note: in expansion of macro 'zng_vec_vctzlsbb'
           zng_vec_vctzlsbb(vc, cmplen);
           ^
  /cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-ng-sys-1.1.15/src/zlib-ng/arch/power/compare256_power9.c:39:9: error: AltiVec argument passed to unprototyped function
  make[2]: *** [CMakeFiles/zlib.dir/arch/power/compare256_power9.c.o] Error 1
  make[1]: *** [CMakeFiles/zlib.dir/all] Error 2
  make: *** [all] Error 2
  thread 'main' panicked at /cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 2
Byron commented 4 months ago

Thanks for reporting!

This architecture isn't tested on CI here, and I'd think that maybe zlib-ng itself isn't validated on this platform.

In flate2, there now is a zlib-rs feature which is a pure-Rust version of zlib-ng - maybe a little slower still, but might be more compatible already. Since it uses SIMD, it could of course be that it also won't compile on PowerPC just yet.

ofek commented 4 months ago

I didn't know about that, nice! Since I don't see such a feature in zip, how would you recommend using that?

Byron commented 4 months ago

It's a backend for the flate2 crate, which is probably the more convenient way of using it (if it compiles).

ofek commented 4 months ago

Just tried, but very broken for my use case apparently https://github.com/ofek/pyapp/pull/127

Byron commented 4 months ago

If any zlib implementation will do, then the default of flate2 for miniz_oxide should definitely compile. Maybe you can do it so that the default is used on PowerPC, and zlib-ng in all other (or known to be working) cases.

ofek commented 4 months ago

I ended up removing ng in all cases to avoid CMake: