confluentinc / librdkafka

The Apache Kafka C/C++ library
Other
214 stars 3.14k forks source link

Cannot build on FreeBSD 13.2 with Clang 16 #4487

Open bluesmoon opened 11 months ago

bluesmoon commented 11 months ago

Read the FAQ first: https://github.com/confluentinc/librdkafka/wiki/FAQ

Do NOT create issues for questions, use the discussion forum: https://github.com/confluentinc/librdkafka/discussions

Description

I'm trying to build the librdkafka bindings for Julia and am running into trouble building it on FreeBSD with Clang 16. Other platforms appear to be fine.

When running the make command, I get this output:

[13:16:32] [ 28%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_pattern.c.o
--
  | [13:16:32] cd /workspace/srcdir/librdkafka/build/src && /opt/bin/x86_64-unknown-freebsd13.2-libgfortran3-cxx11/x86_64-unknown-freebsd13.2-clang --sysroot=/opt/x86_64-unknown-freebsd13.2/x86_64-unknown-freebsd13.2/sys-root/ -Drdkafka_EXPORTS -I/workspace/srcdir/librdkafka/src -I/workspace/srcdir/librdkafka/build/generated/dummy -O3 -DNDEBUG -fPIC -MD -MT src/CMakeFiles/rdkafka.dir/rdkafka_pattern.c.o -MF CMakeFiles/rdkafka.dir/rdkafka_pattern.c.o.d -o CMakeFiles/rdkafka.dir/rdkafka_pattern.c.o -c /workspace/srcdir/librdkafka/src/rdkafka_pattern.c
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_metadata_cache.c:32:
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_int.h:49:
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdtime.h:118:9: error: call to undeclared function 'gettimeofday'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  | [13:16:32]         rd_gettimeofday(&tv, NULL);
  | [13:16:32]         ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:156:33: note: expanded from macro 'rd_gettimeofday'
  | [13:16:32] #define rd_gettimeofday(tv, tz) gettimeofday(tv, tz)
  | [13:16:32]                                 ^
  | [13:16:32] 1 error generated.
  | [13:16:32] [ 29%] Building C object src/CMakeFiles/rdkafka.dir/rdkafka_queue.c.o
  | [13:16:32] make[2]: *** [src/CMakeFiles/rdkafka.dir/build.make:314: src/CMakeFiles/rdkafka.dir/rdkafka_metadata_cache.c.o] Error 1
  | [13:16:32] make[2]: *** Waiting for unfinished jobs....
  | [13:16:32] cd /workspace/srcdir/librdkafka/build/src && /opt/bin/x86_64-unknown-freebsd13.2-libgfortran3-cxx11/x86_64-unknown-freebsd13.2-clang --sysroot=/opt/x86_64-unknown-freebsd13.2/x86_64-unknown-freebsd13.2/sys-root/ -Drdkafka_EXPORTS -I/workspace/srcdir/librdkafka/src -I/workspace/srcdir/librdkafka/build/generated/dummy -O3 -DNDEBUG -fPIC -MD -MT src/CMakeFiles/rdkafka.dir/rdkafka_queue.c.o -MF CMakeFiles/rdkafka.dir/rdkafka_queue.c.o.d -o CMakeFiles/rdkafka.dir/rdkafka_queue.c.o -c /workspace/srcdir/librdkafka/src/rdkafka_queue.c
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_msg.c:31:
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_int.h:49:
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdtime.h:118:9: error: call to undeclared function 'gettimeofday'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  | [13:16:32]         rd_gettimeofday(&tv, NULL);
  | [13:16:32]         ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:156:33: note: expanded from macro 'rd_gettimeofday'
  | [13:16:32] #define rd_gettimeofday(tv, tz) gettimeofday(tv, tz)
  | [13:16:32]                                 ^
  | [13:16:32] 1 error generated.
  | [13:16:32] make[2]: *** [src/CMakeFiles/rdkafka.dir/build.make:328: src/CMakeFiles/rdkafka.dir/rdkafka_msg.c.o] Error 1
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_metadata.c:32:
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_int.h:49:
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdtime.h:118:9: error: call to undeclared function 'gettimeofday'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  | [13:16:32]         rd_gettimeofday(&tv, NULL);
  | [13:16:32]         ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:156:33: note: expanded from macro 'rd_gettimeofday'
  | [13:16:32] #define rd_gettimeofday(tv, tz) gettimeofday(tv, tz)
  | [13:16:32]                                 ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdkafka_metadata.c:1809:18: error: call to undeclared library function 'alloca' with type 'void *(unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  | [13:16:32]         topics = rd_alloca(sizeof(*topics) * topic_cnt);
  | [13:16:32]                  ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:74:22: note: expanded from macro 'rd_alloca'
  | [13:16:32] #define rd_alloca(N) alloca(N)
  | [13:16:32]                      ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdkafka_metadata.c:1809:18: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:74:22: note: expanded from macro 'rd_alloca'
  | [13:16:32] #define rd_alloca(N) alloca(N)
  | [13:16:32]                      ^
  | [13:16:32] 2 errors generated.
  | [13:16:32] make[2]: *** [src/CMakeFiles/rdkafka.dir/build.make:300: src/CMakeFiles/rdkafka.dir/rdkafka_metadata.c.o] Error 1
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_msgset_writer.c:30:
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_int.h:49:
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdtime.h:118:9: error: call to undeclared function 'gettimeofday'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  | [13:16:32]         rd_gettimeofday(&tv, NULL);
  | [13:16:32]         ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:156:33: note: expanded from macro 'rd_gettimeofday'
  | [13:16:32] #define rd_gettimeofday(tv, tz) gettimeofday(tv, tz)
  | [13:16:32]                                 ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdkafka_msgset_writer.c:1065:19: error: call to undeclared library function 'alloca' with type 'void *(unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  | [13:16:32]         iov     = rd_alloca(sizeof(*iov) * iov_max);
  | [13:16:32]                   ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:74:22: note: expanded from macro 'rd_alloca'
  | [13:16:32] #define rd_alloca(N) alloca(N)
  | [13:16:32]                      ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdkafka_msgset_writer.c:1065:19: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:74:22: note: expanded from macro 'rd_alloca'
  | [13:16:32] #define rd_alloca(N) alloca(N)
  | [13:16:32]                      ^
  | [13:16:32] 2 errors generated.
  | [13:16:32] make[2]: *** [src/CMakeFiles/rdkafka.dir/build.make:356: src/CMakeFiles/rdkafka.dir/rdkafka_msgset_writer.c.o] Error 1
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_msgset_reader.c:61:
  | [13:16:32] In file included from /workspace/srcdir/librdkafka/src/rdkafka_int.h:49:
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdtime.h:118:9: error: call to undeclared function 'gettimeofday'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  | [13:16:32]         rd_gettimeofday(&tv, NULL);
  | [13:16:32]         ^
  | [13:16:32] /workspace/srcdir/librdkafka/src/rdposix.h:156:33: note: expanded from macro 'rd_gettimeofday'
  | [13:16:32] #define rd_gettimeofday(tv, tz) gettimeofday(tv, tz)
  | [13:16:32]                                 ^
  | [13:16:32] 1 error generated.
  | [13:16:32] make[2]: *** [src/CMakeFiles/rdkafka.dir/build.make:342: src/CMakeFiles/rdkafka.dir/rdkafka_msgset_reader.c.o] Error 1
  | [13:16:33] make[2]: Leaving directory '/workspace/srcdir/librdkafka/build'
  | [13:16:33] make[1]: *** [CMakeFiles/Makefile2:116: src/CMakeFiles/rdkafka.dir/all] Error 2
  | [13:16:33] make[1]: Leaving directory '/workspace/srcdir/librdkafka/build'
  | [13:16:33] make: *** [Makefile:136: all] Error 2
  | [13:16:33]  ---> make -j${nproc}
  | [13:16:33]  ---> make -j${nproc}
  | [13:16:33] Previous command exited with 2
  | [13:16:33] Child Process exited, exit code 2
  | ERROR: LoadError: Build for librdkafka on x86_64-unknown-freebsd did not complete successfully

The CI build can be seen here: https://buildkite.com/julialang/yggdrasil/builds/6219#018b7144-2f02-4fa1-a318-4b4da601873c/618-886

How to reproduce

On FreeBSD, download latest source release of librdkafka:

cd librdkafka
mkdir build
cd build/
cmake -DCMAKE_INSTALL_PREFIX=${prefix} \
    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
    -DCMAKE_BUILD_TYPE=Release \
    -DRDKAFKA_BUILD_EXAMPLES=OFF \
    -DRDKAFKA_BUILD_TESTS=OFF \
    ..
make -j${nproc}

Checklist

IMPORTANT: We will close issues where the checklist has not been completed.

Please provide the following information:

ilejn commented 2 months ago

Same for librdkafka 2.4.0 and clang 18.