fede1024 / rust-rdkafka

A fully asynchronous, futures-based Kafka client library for Rust based on librdkafka
MIT License
1.63k stars 280 forks source link

Failed to compile 'rdkafka' on 'x86_64-unknown-linux-musl' target with 'cmake' version > '0.1.48' #598

Open vigneshs-12 opened 1 year ago

vigneshs-12 commented 1 year ago

Issue description

We're using rdkafka in our rust project and it fails to compile on x86_64-unknown-linux-musl if the cmake crate version is > 0.1.48.

On checking this issue, we found that cmake v0.1.49 introduced a change which sets CMAKE_SYSTEM_NAME if HOST!=TARGET (which is our case as we're compiling for x86_64-unknown-linux-musl from x86_64-unknown-linux-gnu toolchain).


Is this has something to do with rdkafka's build script or related to this cmake issue? Let me know if you need any additional information or if there are any updates regarding this issue.

Steps to reproduce

...

error: failed to run custom build command for `rdkafka-sys v4.5.0+1.9.2`

Caused by:
  process didn't exit successfully: `/workspace/rdkafka-test/target/debug/build/rdkafka-sys-46f4da784de26db7/build-script-build` (exit status: 101)
  --- stdout
  Configuring and compiling librdkafka
  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 "/workspace/rdkafka-test/target/x86_64-unknown-linux-musl/debug/build/rdkafka-sys-ccebc1fbfa5ab608/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/usr/local/rust/registry/src/github.com-1ecc6299db9ec823/rdkafka-sys-4.5.0+1.9.2/librdkafka" "-DRDKAFKA_BUILD_STATIC=1" "-DRDKAFKA_BUILD_TESTS=0" "-DRDKAFKA_BUILD_EXAMPLES=0" "-DCMAKE_INSTALL_LIBDIR=lib" "-DWITH_ZLIB=0" "-DWITH_CURL=0" "-DWITH_SSL=0" "-DWITH_SASL=0" "-DWITH_ZSTD=0" "-DENABLE_LZ4_EXT=0" "-DCMAKE_SYSTEM_NAME=Linux" "-DCMAKE_SYSTEM_PROCESSOR=x86_64" "-DCMAKE_INSTALL_PREFIX=/workspace/rdkafka-test/target/x86_64-unknown-linux-musl/debug/build/rdkafka-sys-ccebc1fbfa5ab608/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/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/bin/musl-gcc" "-DCMAKE_BUILD_TYPE=Debug"
  -- The C compiler identification is GNU 9.4.0
  -- The CXX compiler identification is GNU 9.4.0
  -- Check for working C compiler: /usr/bin/musl-gcc
  -- Check for working C compiler: /usr/bin/musl-gcc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/musl-g++
  -- Check for working CXX compiler: /usr/bin/musl-g++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Looking for pow in m
  -- Looking for pow in m - found
  -- Checking for module 'libsasl2'
  --   No package 'libsasl2' found
  -- Looking for pthread.h
  -- Looking for pthread.h - found
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
  -- Found Threads: TRUE  
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /workspace/rdkafka-test/target/x86_64-unknown-linux-musl/debug/build/rdkafka-sys-ccebc1fbfa5ab608/out/build
  running: cd "/workspace/rdkafka-test/target/x86_64-unknown-linux-musl/debug/build/rdkafka-sys-ccebc1fbfa5ab608/out/build" && MAKEFLAGS="-j --jobserver-fds=16,17 --jobserver-auth=16,17" "cmake" "--build" "." "--target" "install" "--config" "Debug"
  Scanning dependencies of target rdkafka
  [  4%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_buf.c.o
  [  4%] Building C object src/CMakeFiles/rdkafka.dir/crc32c.c.o
  [  4%] Building C object src/CMakeFiles/rdkafka.dir/rdbuf.c.o
  [  4%] Building C object src/CMakeFiles/rdkafka.dir/rdavl.c.o
  [  7%] Building C object src/CMakeFiles/rdkafka.dir/rdaddr.c.o
  [  8%] Building C object src/CMakeFiles/rdkafka.dir/rdfnv1a.c.o
  [  9%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka.c.o
  [ 10%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_assignor.c.o
  [ 11%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_broker.c.o
  [ 11%] Building C object src/CMakeFiles/rdkafka.dir/rdcrc32.c.o
  [ 13%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_cgrp.c.o
  [ 14%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_conf.c.o
  [ 15%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_event.c.o
  [ 16%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_feature.c.o
  [ 17%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_lz4.c.o
  [ 19%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_metadata.c.o
  [ 20%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_metadata_cache.c.o
  [ 21%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_msg.c.o
  [ 22%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_msgset_reader.c.o
  [ 23%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_msgset_writer.c.o
  [ 25%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_offset.c.o
  [ 26%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_op.c.o
  [ 27%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_partition.c.o
  [ 28%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_pattern.c.o
  [ 29%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_queue.c.o
  [ 30%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_range_assignor.c.o
  [ 32%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_request.c.o
  [ 33%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_roundrobin_assignor.c.o
  [ 34%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_sasl.c.o
  [ 35%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_sasl_plain.c.o
  [ 36%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_sticky_assignor.c.o
  [ 38%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_subscription.c.o
  [ 39%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_assignment.c.o
  [ 41%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_timer.c.o
  [ 41%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_topic.c.o
  [ 42%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_transport.c.o
  [ 44%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_interceptor.c.o
  [ 45%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_header.c.o
  [ 46%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_admin.c.o
  [ 47%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_aux.c.o
  [ 48%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_background.c.o
  [ 50%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_idempotence.c.o
  [ 51%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_txnmgr.c.o
  [ 53%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_coord.c.o
  [ 53%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_cert.c.o
  [ 54%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_mock.c.o
  [ 55%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_mock_handlers.c.o
  [ 57%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_mock_cgrp.c.o
  [ 58%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_error.c.o
  [ 59%] Building C object src/CMakeFiles/rdkafka.dir/rdlist.c.o
  [ 60%] Building C object src/CMakeFiles/rdkafka.dir/rdlog.c.o
  [ 61%] Building C object src/CMakeFiles/rdkafka.dir/rdmurmur2.c.o
  [ 63%] Building C object src/CMakeFiles/rdkafka.dir/rdports.c.o
  [ 64%] Building C object src/CMakeFiles/rdkafka.dir/rdrand.c.o
  [ 65%] Building C object src/CMakeFiles/rdkafka.dir/rdregex.c.o
  [ 66%] Building C object src/CMakeFiles/rdkafka.dir/rdstring.c.o
  [ 67%] Building C object src/CMakeFiles/rdkafka.dir/rdunittest.c.o
  [ 69%] Building C object src/CMakeFiles/rdkafka.dir/rdvarint.c.o
  [ 70%] Building C object src/CMakeFiles/rdkafka.dir/rdmap.c.o
  [ 71%] Building C object src/CMakeFiles/rdkafka.dir/snappy.c.o
  [ 72%] Building C object src/CMakeFiles/rdkafka.dir/tinycthread.c.o
  [ 73%] Building C object src/CMakeFiles/rdkafka.dir/rdxxhash.c.o
  [ 75%] Building C object src/CMakeFiles/rdkafka.dir/cJSON.c.o
  [ 76%] Building C object src/CMakeFiles/rdkafka.dir/tinycthread_extra.c.o
  [ 77%] Building C object src/CMakeFiles/rdkafka.dir/rdhdrhistogram.c.o
  [ 78%] Building C object src/CMakeFiles/rdkafka.dir/rddl.c.o
  [ 79%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_plugin.c.o
  [ 80%] Building C object src/CMakeFiles/rdkafka.dir/lz4.c.o
  [ 82%] Building C object src/CMakeFiles/rdkafka.dir/lz4frame.c.o
  [ 83%] Building C object src/CMakeFiles/rdkafka.dir/lz4hc.c.o
  [ 84%] Linking C static library librdkafka.a

  --- stderr
  Building and linking librdkafka statically
  CMake Warning:
    Manually-specified variables were not used by the project:

      CMAKE_ASM_COMPILER
      CMAKE_ASM_FLAGS

  Error running link command: No such file or directory
  make[2]: *** [src/CMakeFiles/rdkafka.dir/build.make:1120: src/librdkafka.a] Error 2
  make[1]: *** [CMakeFiles/Makefile2:115: src/CMakeFiles/rdkafka.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', /usr/local/rust/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.50/src/lib.rs:1098:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
jerome-caucat commented 2 months ago

I've got the same problem, any solution or workaround?

EDIT: forcing the cmake crate version to 0.1.48 allowed me to build.