rust-lang / libz-sys

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

Compilation issue on WSL for musl build #151

Closed wdecoster closed 1 year ago

wdecoster commented 1 year ago

Hi,

I get the following error with cargo build --release --target=x86_64-unknown-linux-musl, but cannot figure out what is missing. Weirdly enough this used to work just a few days ago, but something broke the musl build. Is there something I can do to debug?

Thanks!

   Compiling libz-sys v1.1.12
error: failed to run custom build command for `libz-sys v1.1.12`

Caused by:
  process didn't exit successfully: `/home/wdecoster/wsl-repos/tool/target/release/build/libz-sys-bbe4ff38303868db/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBZ_SYS_STATIC
  cargo:rerun-if-changed=build.rs
  CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-musl = None
  CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_musl = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-unknown-linux-musl = None
  CMAKE_GENERATOR_x86_64_unknown_linux_musl = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-unknown-linux-musl = None
  CMAKE_PREFIX_PATH_x86_64_unknown_linux_musl = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-unknown-linux-musl = None
  CMAKE_x86_64_unknown_linux_musl = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/home/wdecoster/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libz-sys-1.1.12/src/zlib-ng" "-DBUILD_SHARED_LIBS=OFF" "-DZLIB_COMPAT=ON" "-DZLIB_ENABLE_TESTS=OFF" "-DWITH_GZFILEOP=ON" "-DCMAKE_SYSTEM_NAME=Linux" "-DCMAKE_SYSTEM_PROCESSOR=x86_64" "-DCMAKE_INSTALL_PREFIX=/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/local/bin/musl-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/musl-g++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/local/bin/musl-gcc" "-DCMAKE_BUILD_TYPE=Release"
  -- Using CMake version 3.16.3
  -- ZLIB_HEADER_VERSION: 1.2.13
  -- ZLIBNG_HEADER_VERSION: 2.1.3
  -- Arch not recognized, falling back to cmake arch: 'x86_64'
  -- Basearch of 'x86_64' has been detected as: 'x86'
  -- Architecture-specific source files: arch/x86/x86_features.c;arch/x86/slide_hash_avx2.c;arch/x86/chunkset_avx2.c;arch/x86/compare256_avx2.c;arch/x86/adler32_avx2.c;arch/x86/adler32_avx512.c;arch/x86/adler32_avx512_vnni.c;arch/x86/adler32_sse42.c;arch/x86/insert_string_sse42.c;arch/x86/chunkset_sse2.c;arch/x86/compare256_sse2.c;arch/x86/slide_hash_sse2.c;arch/x86/adler32_ssse3.c;arch/x86/chunkset_ssse3.c;arch/x86/crc32_pclmulqdq.c;arch/x86/crc32_vpclmulqdq.c
  -- The following features have been enabled:

   * CMAKE_BUILD_TYPE, Build type: Release (selected)
   * AVX2_SLIDEHASH, Support AVX2 optimized slide_hash, using "-mavx2"
   * AVX2_CHUNKSET, Support AVX2 optimized chunkset, using "-mavx2"
   * AVX2_COMPARE256, Support AVX2 optimized compare256, using "-mavx2"
   * AVX2_ADLER32, Support AVX2-accelerated adler32, using "-mavx2"
   * AVX512_ADLER32, Support AVX512-accelerated adler32, using "-mavx512f -mavx512dq -mavx512bw -mavx512vl -mtune=cascadelake"
   * AVX512VNNI_ADLER32, Support AVX512VNNI adler32, using "-mavx512f -mavx512dq -mavx512bw -mavx512vl -mavx512vnni -mtune=cascadelake"
   * SSE42_CRC, Support SSE4.2 optimized CRC hash generation, using "-msse4.2"
   * SSSE3_ADLER32, Support SSSE3-accelerated adler32, using "-mssse3"
   * PCLMUL_CRC, Support CRC hash generation using PCLMULQDQ, using "-mssse3 -msse4.2 -mpclmul"
   * VPCLMUL_CRC, Support CRC hash generation using VPCLMULQDQ, using "-mvpclmulqdq -mavx512f -mavx512f -mavx512dq -mavx512bw -mavx512vl -mtune=cascadelake"
   * WITH_GZFILEOP, Compile with support for gzFile related functions
   * ZLIB_COMPAT, Compile with zlib compatible API
   * ZLIBNG_ENABLE_TESTS, Test zlib-ng specific API
   * WITH_SANITIZER, Enable sanitizer support
   * WITH_GTEST, Build gtest_zlib
   * WITH_OPTIM, Build with optimisation
   * WITH_NEW_STRATEGIES, Use new strategies
   * WITH_AVX2, Build with AVX2
   * WITH_AVX512, Build with AVX512
   * WITH_AVX512VNNI, Build with AVX512 VNNI
   * WITH_SSE2, Build with SSE2
   * WITH_SSSE3, Build with SSSE3
   * WITH_SSE42, Build with SSE42
   * WITH_PCLMULQDQ, Build with PCLMULQDQ
   * WITH_VPCLMULQDQ, Build with VPCLMULQDQ

  -- The following features have been disabled:

   * ZLIB_SYMBOL_PREFIX, Publicly exported symbols DO NOT have a custom prefix
   * ZLIB_ENABLE_TESTS, Build test binaries
   * WITH_FUZZERS, Build test/fuzz
   * WITH_BENCHMARKS, Build test/benchmarks
   * WITH_BENCHMARK_APPS, Build application benchmarks
   * WITH_NATIVE_INSTRUCTIONS, Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)
   * WITH_MAINTAINER_WARNINGS, Build with project maintainer warnings
   * WITH_CODE_COVERAGE, Enable code coverage reporting
   * WITH_INFLATE_STRICT, Build with strict inflate distance checking
   * WITH_INFLATE_ALLOW_INVALID_DIST, Build with zero fill for inflate invalid distances
   * INSTALL_UTILS, Copy minigzip and minideflate during install

  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build
  running: cd "/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build" && MAKEFLAGS="-j --jobserver-fds=7,8 --jobserver-auth=7,8" "cmake" "--build" "." "--target" "install" "--config" "Release"
  make[1]: Entering directory '/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build'
  make[2]: Entering directory '/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build'
  make[2]: Leaving directory '/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build'
  make[2]: Entering directory '/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build'
  [  2%] Linking C static library libz.a
  make[2]: Leaving directory '/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build'
  make[1]: Leaving directory '/home/wdecoster/wsl-repos/tool/target/x86_64-unknown-linux-musl/release/build/libz-sys-93d8e0778c03a801/out/build'

  --- stderr
  Error running link command: No such file or directory
  make[2]: *** [CMakeFiles/zlib.dir/build.make:760: libz.a] Error 2
  make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/zlib.dir/all] Error 2
  make: *** [Makefile:118: all] Error 2
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 2

  build script failed, must exit now', /home/wdecoster/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Byron commented 1 year ago

Could it be that the libz-sys crate was upgraded, which surfaced this error now. If so, what happens if you force it to an older version again? The goal would be to see if it's a version change that did this, or if it's something that changed locally (I assume that cargo clean has been called to be sure there is no invalid state affecting the build outcome, somehow).

wdecoster commented 1 year ago

cargo clean did not seem to solve the issue. But I am confused now about how these things work. Libz-sys is not a direct dependency of my tool (but rather a dependency of some of my dependencies), but explicitly adding it to Cargo.toml with "1.1.12" did solve the problem. Does that make any sense to you?

Byron commented 1 year ago

That's a great outcome! This means that the latest version of libz-sys seems to fix the problem. cargo update -p libz-sys should have done the trick as well then.

Can this issue be closed?

wdecoster commented 1 year ago

Yes, thank you!