libpcap icon indicating copy to clipboard operation
libpcap copied to clipboard

Haiku build is broken in various ways

Open infrastation opened this issue 3 years ago • 20 comments

Tested using haiku-r1beta3-x86_64-anyboot.iso (plus the llvm9_clang and CMake packages installed via HaikuDepot) and the current master branch at commit ff7024d (after my recent CMake change reverted and a couple cosmetic improvements).

Autoconf 2.69 + GCC 8.3.0: (3 + 7) warnings and 2 errors

$ MATRIX_CMAKE=no MATRIX_CC=gcc ./build_matrix.sh
Haiku shredder 1 hrev55181+66 Jul  6 2022 08:03: x86_64 x86_64 Haiku
OS identification: Haiku-hrev55181
Wed Jul  6 14:00:17 GMT 2022
PREFIX set to '/tmp/libpcap_build_matrix.dgVOcCTs'
===== SETUP 1: CC=gcc CMAKE=no REMOTE=no =====
$ ./build.sh
gcc (2019_05_24) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiler identification: gcc-8.3.0
$ ./configure --prefix=/tmp/libpcap_build_matrix.dgVOcCTs --enable-remote=no

[...]

$ make -s
cc1plus: warning: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus: warning: command line option '-Wpointer-sign' is valid for C/ObjC but not for C++
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
pcap-haiku.cpp: In function 'int pcap_read_haiku(pcap_t*, int, pcap_handler, u_char*)':
pcap-haiku.cpp:55:21: warning: unused variable 'handlep' [-Wunused-variable]
  struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv;
                     ^~~~~~~
pcap-haiku.cpp:50:37: warning: unused parameter 'maxPackets' [-Wunused-parameter]
 pcap_read_haiku(pcap_t* handle, int maxPackets, pcap_handler callback,
                                 ~~~~^~~~~~~~~~
pcap-haiku.cpp: In function 'int pcap_inject_haiku(pcap_t*, const void*, int)':
pcap-haiku.cpp:111:47: warning: unused parameter 'buffer' [-Wunused-parameter]
 pcap_inject_haiku(pcap_t *handle, const void *buffer, int size)
                                   ~~~~~~~~~~~~^~~~~~
pcap-haiku.cpp:111:59: warning: unused parameter 'size' [-Wunused-parameter]
 pcap_inject_haiku(pcap_t *handle, const void *buffer, int size)
                                                       ~~~~^~~~
In file included from pcap-haiku.cpp:12:
pcap-haiku.cpp: In function 'pcap_t* pcap_create_interface(const char*, char*)':
pcap-int.h:494:21: error: types may not be defined in 'sizeof' expressions
      sizeof (struct { pcap_t __common; type __private; }), \
                     ^
pcap-haiku.cpp:252:19: note: in expansion of macro 'PCAP_CREATE_COMMON'
  pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku);
                   ^~~~~~~~~~~~~~~~~~
In file included from pcap-int.h:37,
                 from pcap-haiku.cpp:12:
pcap-int.h:495:23: error: types may not be defined within __builtin_offsetof
      offsetof (struct { pcap_t __common; type __private; }, __private))
                       ^
pcap-haiku.cpp:252:19: note: in expansion of macro 'PCAP_CREATE_COMMON'
  pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku);
                   ^~~~~~~~~~~~~~~~~~
pcap-haiku.cpp: In function 'int can_be_bound(const char*)':
pcap-haiku.cpp:268:26: warning: unused parameter 'name' [-Wunused-parameter]
 can_be_bound(const char *name)
              ~~~~~~~~~~~~^~~~
pcap-haiku.cpp: In function 'int get_if_flags(const char*, bpf_u_int32*, char*)':
pcap-haiku.cpp:274:26: warning: unused parameter 'name' [-Wunused-parameter]
 get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
              ~~~~~~~~~~~~^~~~
pcap-haiku.cpp:274:58: warning: unused parameter 'errbuf' [-Wunused-parameter]
 get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
                                                    ~~~~~~^~~~~~
<builtin>: recipe for target 'pcap-haiku.o' failed
make: *** [pcap-haiku.o] Error 1

Autoconf 2.69 + Clang 9.0.1: 5 errors

$ MATRIX_CMAKE=no MATRIX_CC=clang ./build_matrix.sh
Haiku shredder 1 hrev55181+66 Jul  6 2022 08:03: x86_64 x86_64 Haiku
OS identification: Haiku-hrev55181
Wed Jul  6 14:01:12 GMT 2022
PREFIX set to '/tmp/libpcap_build_matrix.v9ft5CHO'
===== SETUP 1: CC=clang CMAKE=no REMOTE=no =====
$ ./build.sh
clang version 9.0.1 
Target: x86_64-unknown-haiku
Thread model: posix
InstalledDir: /bin
Compiler identification: clang-9.0.1
$ ./configure --prefix=/tmp/libpcap_build_matrix.v9ft5CHO --enable-remote=no

[...]

$ make -s
g++: error: unrecognized command line option '-Wcomma'; did you mean '-Wcomment'?
g++: error: unrecognized command line option '-Wdocumentation'
g++: error: unrecognized command line option '-Wmissing-variable-declarations'; did you mean '-Wmissing-declarations'?
g++: error: unrecognized command line option '-Wused-but-marked-unused'
g++: error: unrecognized command line option '-Wshorten-64-to-32'
<builtin>: recipe for target 'pcap-haiku.o' failed
make: *** [pcap-haiku.o] Error 1

CMake 3.23.0 + GCC 8.3.0: (4 + 7) warnings and 2 errors

$ MATRIX_CMAKE=yes MATRIX_CC=gcc ./build_matrix.sh
Haiku shredder 1 hrev55181+66 Jul  6 2022 08:03: x86_64 x86_64 Haiku
OS identification: Haiku-hrev55181
Wed Jul  6 14:03:54 GMT 2022
PREFIX set to '/tmp/libpcap_build_matrix.gB9FeuxR'
===== SETUP 1: CC=gcc CMAKE=yes REMOTE=no =====
$ ./build.sh
gcc (2019_05_24) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiler identification: gcc-8.3.0
$ rm -rf CMakeFiles/ CMakeCache.txt
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/tmp/libpcap_build_matrix.gB9FeuxR -DENABLE_REMOTE=no ..

[...]

$ make
[  1%] Generating grammar.c, grammar.h
[  3%] Generating scanner.c, scanner.h
[  3%] Built target SerializeTarget
[  5%] Building C object CMakeFiles/pcap.dir/bpf_dump.c.o
[  7%] Building C object CMakeFiles/pcap.dir/bpf_filter.c.o
[  9%] Building C object CMakeFiles/pcap.dir/bpf_image.c.o
[ 10%] Building C object CMakeFiles/pcap.dir/etherent.c.o
[ 12%] Building C object CMakeFiles/pcap.dir/fmtutils.c.o
[ 14%] Building C object CMakeFiles/pcap.dir/gencode.c.o
[ 16%] Building C object CMakeFiles/pcap.dir/nametoaddr.c.o
[ 18%] Building C object CMakeFiles/pcap.dir/optimize.c.o
[ 20%] Building C object CMakeFiles/pcap.dir/pcap-common.c.o
[ 21%] Building C object CMakeFiles/pcap.dir/pcap-options.c.o
[ 23%] Building C object CMakeFiles/pcap.dir/pcap-usb-linux-common.c.o
[ 25%] Building C object CMakeFiles/pcap.dir/pcap.c.o
[ 27%] Building C object CMakeFiles/pcap.dir/savefile.c.o
[ 29%] Building C object CMakeFiles/pcap.dir/sf-pcapng.c.o
[ 30%] Building C object CMakeFiles/pcap.dir/sf-pcap.c.o
[ 32%] Building CXX object CMakeFiles/pcap.dir/pcap-haiku.cpp.o
cc1plus: warning: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus: warning: command line option '-Wpointer-sign' is valid for C/ObjC but not for C++
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
cc1plus: warning: command line option '-std=gnu99' is valid for C/ObjC but not for C++
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'int pcap_read_haiku(pcap_t*, int, pcap_handler, u_char*)':
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:55:21: warning: unused variable 'handlep' [-Wunused-variable]
  struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv;
                     ^~~~~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:50:37: warning: unused parameter 'maxPackets' [-Wunused-parameter]
 pcap_read_haiku(pcap_t* handle, int maxPackets, pcap_handler callback,
                                 ~~~~^~~~~~~~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'int pcap_inject_haiku(pcap_t*, const void*, int)':
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:111:47: warning: unused parameter 'buffer' [-Wunused-parameter]
 pcap_inject_haiku(pcap_t *handle, const void *buffer, int size)
                                   ~~~~~~~~~~~~^~~~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:111:59: warning: unused parameter 'size' [-Wunused-parameter]
 pcap_inject_haiku(pcap_t *handle, const void *buffer, int size)
                                                       ~~~~^~~~
In file included from /boot/home/gitrepos/libpcap/pcap-haiku.cpp:12:
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'pcap_t* pcap_create_interface(const char*, char*)':
/boot/home/gitrepos/libpcap/pcap-int.h:494:21: error: types may not be defined in 'sizeof' expressions
      sizeof (struct { pcap_t __common; type __private; }), \
                     ^
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:252:19: note: in expansion of macro 'PCAP_CREATE_COMMON'
  pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku);
                   ^~~~~~~~~~~~~~~~~~
In file included from /boot/home/gitrepos/libpcap/pcap-int.h:37,
                 from /boot/home/gitrepos/libpcap/pcap-haiku.cpp:12:
/boot/home/gitrepos/libpcap/pcap-int.h:495:23: error: types may not be defined within __builtin_offsetof
      offsetof (struct { pcap_t __common; type __private; }, __private))
                       ^
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:252:19: note: in expansion of macro 'PCAP_CREATE_COMMON'
  pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku);
                   ^~~~~~~~~~~~~~~~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'int can_be_bound(const char*)':
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:268:26: warning: unused parameter 'name' [-Wunused-parameter]
 can_be_bound(const char *name)
              ~~~~~~~~~~~~^~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'int get_if_flags(const char*, bpf_u_int32*, char*)':
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:274:26: warning: unused parameter 'name' [-Wunused-parameter]
 get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
              ~~~~~~~~~~~~^~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:274:58: warning: unused parameter 'errbuf' [-Wunused-parameter]
 get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
                                                    ~~~~~~^~~~~~
CMakeFiles/pcap.dir/build.make:299: recipe for target 'CMakeFiles/pcap.dir/pcap-haiku.cpp.o' failed
make[2]: *** [CMakeFiles/pcap.dir/pcap-haiku.cpp.o] Error 1
CMakeFiles/Makefile2:159: recipe for target 'CMakeFiles/pcap.dir/all' failed
make[1]: *** [CMakeFiles/pcap.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

CMake 3.23.0 + Clang 9.0.1: (4 + 7) warnings and 2 errors

$ MATRIX_CMAKE=yes MATRIX_CC=clang ./build_matrix.sh
Haiku shredder 1 hrev55181+66 Jul  6 2022 08:03: x86_64 x86_64 Haiku
OS identification: Haiku-hrev55181
Wed Jul  6 14:04:59 GMT 2022
PREFIX set to '/tmp/libpcap_build_matrix.C3wftnfj'
===== SETUP 1: CC=clang CMAKE=yes REMOTE=no =====
$ ./build.sh
clang version 9.0.1 
Target: x86_64-unknown-haiku
Thread model: posix
InstalledDir: /bin
Compiler identification: clang-9.0.1
$ rm -rf CMakeFiles/ CMakeCache.txt
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/tmp/libpcap_build_matrix.C3wftnfj -DENABLE_REMOTE=no ..

[...]

$ make
[  1%] Generating grammar.c, grammar.h
[  3%] Generating scanner.c, scanner.h
[  3%] Built target SerializeTarget
[  5%] Building C object CMakeFiles/pcap.dir/bpf_dump.c.o
[  7%] Building C object CMakeFiles/pcap.dir/bpf_filter.c.o
[  9%] Building C object CMakeFiles/pcap.dir/bpf_image.c.o
[ 10%] Building C object CMakeFiles/pcap.dir/etherent.c.o
[ 12%] Building C object CMakeFiles/pcap.dir/fmtutils.c.o
[ 14%] Building C object CMakeFiles/pcap.dir/gencode.c.o
[ 16%] Building C object CMakeFiles/pcap.dir/nametoaddr.c.o
[ 18%] Building C object CMakeFiles/pcap.dir/optimize.c.o
[ 20%] Building C object CMakeFiles/pcap.dir/pcap-common.c.o
[ 21%] Building C object CMakeFiles/pcap.dir/pcap-options.c.o
[ 23%] Building C object CMakeFiles/pcap.dir/pcap-usb-linux-common.c.o
[ 25%] Building C object CMakeFiles/pcap.dir/pcap.c.o
[ 27%] Building C object CMakeFiles/pcap.dir/savefile.c.o
[ 29%] Building C object CMakeFiles/pcap.dir/sf-pcapng.c.o
[ 30%] Building C object CMakeFiles/pcap.dir/sf-pcap.c.o
[ 32%] Building CXX object CMakeFiles/pcap.dir/pcap-haiku.cpp.o
cc1plus: warning: command line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
cc1plus: warning: command line option '-Wpointer-sign' is valid for C/ObjC but not for C++
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
cc1plus: warning: command line option '-std=gnu99' is valid for C/ObjC but not for C++
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'int pcap_read_haiku(pcap_t*, int, pcap_handler, u_char*)':
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:55:21: warning: unused variable 'handlep' [-Wunused-variable]
  struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv;
                     ^~~~~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:50:37: warning: unused parameter 'maxPackets' [-Wunused-parameter]
 pcap_read_haiku(pcap_t* handle, int maxPackets, pcap_handler callback,
                                 ~~~~^~~~~~~~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'int pcap_inject_haiku(pcap_t*, const void*, int)':
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:111:47: warning: unused parameter 'buffer' [-Wunused-parameter]
 pcap_inject_haiku(pcap_t *handle, const void *buffer, int size)
                                   ~~~~~~~~~~~~^~~~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:111:59: warning: unused parameter 'size' [-Wunused-parameter]
 pcap_inject_haiku(pcap_t *handle, const void *buffer, int size)
                                                       ~~~~^~~~
In file included from /boot/home/gitrepos/libpcap/pcap-haiku.cpp:12:
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'pcap_t* pcap_create_interface(const char*, char*)':
/boot/home/gitrepos/libpcap/pcap-int.h:494:21: error: types may not be defined in 'sizeof' expressions
      sizeof (struct { pcap_t __common; type __private; }), \
                     ^
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:252:19: note: in expansion of macro 'PCAP_CREATE_COMMON'
  pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku);
                   ^~~~~~~~~~~~~~~~~~
In file included from /boot/home/gitrepos/libpcap/pcap-int.h:37,
                 from /boot/home/gitrepos/libpcap/pcap-haiku.cpp:12:
/boot/home/gitrepos/libpcap/pcap-int.h:495:23: error: types may not be defined within __builtin_offsetof
      offsetof (struct { pcap_t __common; type __private; }, __private))
                       ^
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:252:19: note: in expansion of macro 'PCAP_CREATE_COMMON'
  pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku);
                   ^~~~~~~~~~~~~~~~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'int can_be_bound(const char*)':
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:268:26: warning: unused parameter 'name' [-Wunused-parameter]
 can_be_bound(const char *name)
              ~~~~~~~~~~~~^~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp: In function 'int get_if_flags(const char*, bpf_u_int32*, char*)':
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:274:26: warning: unused parameter 'name' [-Wunused-parameter]
 get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
              ~~~~~~~~~~~~^~~~
/boot/home/gitrepos/libpcap/pcap-haiku.cpp:274:58: warning: unused parameter 'errbuf' [-Wunused-parameter]
 get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
                                                    ~~~~~~^~~~~~
CMakeFiles/pcap.dir/build.make:299: recipe for target 'CMakeFiles/pcap.dir/pcap-haiku.cpp.o' failed
make[2]: *** [CMakeFiles/pcap.dir/pcap-haiku.cpp.o] Error 1
CMakeFiles/Makefile2:159: recipe for target 'CMakeFiles/pcap.dir/all' failed
make[1]: *** [CMakeFiles/pcap.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

infrastation avatar Jul 06 '22 14:07 infrastation

Installing all system updates in HaikuDepot among other things updates Autoconf from 2.69 to 2.71 and GCC from 8.3.0 to 11.2.0 and ultimately results in even more warnings (noted in build.sh).

infrastation avatar Jul 06 '22 15:07 infrastation

@davidkaroly, @agnosticdev, @mmuman or @korli: it would be nice if you had a look at the Haiku-specific code and possibly made the problem smaller.

infrastation avatar Jul 08 '22 13:07 infrastation

I don't have an x86_64 install but I could see if it also happens on 32bit.

mmuman avatar Jul 08 '22 17:07 mmuman

If there is a happy path in the 32-bit space, it would be useful to know.

infrastation avatar Jul 08 '22 17:07 infrastation

It seems it's actually a construct that is forbidden in C++11.

I can build with the following patch but it uses a GCCism:

diff --git a/pcap-int.h b/pcap-int.h
index f1b97ce6..3d19be6b 100644
--- a/pcap-int.h
+++ b/pcap-int.h
@@ -490,9 +490,12 @@ pcap_t	*pcap_create_interface(const char *, char *);
  * bytes.
  */
 #define PCAP_CREATE_COMMON(ebuf, type) \
+({ \
+	struct foo { pcap_t __common; type __private; }; \
 	pcap_create_common(ebuf, \
-	    sizeof (struct { pcap_t __common; type __private; }), \
-	    offsetof (struct { pcap_t __common; type __private; }, __private))
+	    sizeof (struct foo), \
+	    offsetof (struct foo, __private)); \
+})
 pcap_t	*pcap_create_common(char *, size_t, size_t);
 int	pcap_do_addexit(pcap_t *);
 void	pcap_add_to_pcaps_to_close(pcap_t *);

There's another use of this later on but it doesn't seem to be compiled in.

mmuman avatar Jul 08 '22 20:07 mmuman

I supposed this version could be guarded by an ifdef on __cplusplus && gnuc

mmuman avatar Jul 08 '22 20:07 mmuman

The goal here is to have a single contiguous block of data containing both a pcap_t and the module's private data, with both of the structures properly aligned.

I guess for C++ code (and C code if C ever bans this), we could just declare such a structure explicitly and directly call pcap_create_common() rather than using the macro.

guyharris avatar Jul 08 '22 20:07 guyharris

Ah yes it's actually only a problem for the haiku file itself.

mmuman avatar Jul 08 '22 20:07 mmuman

With a few fixes applied the current status is as follows:

Autoconf + GCC now builds

(albeit with warnings, as shown above)

Autoconf + Clang is still broken

(same as above, which is a C++ compiler invocation error)

CMake + GCC is still broken

$ cmake -DCMAKE_INSTALL_PREFIX=/tmp/libpcap_build_matrix.9s6xPkBI -DENABLE_REMOTE=no ..
CMake Deprecation Warning at CMakeLists.txt:7 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at CMakeLists.txt:16 (cmake_policy):
  The OLD behavior for policy CMP0042 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Checking C compiler flag -std=gnu99
-- Use DYNAMIC runtime
CMake Error at CMakeLists.txt:467 (message):
  vsnprintf() is required but wasn't found


-- Configuring incomplete, errors occurred!
See also "/boot/home/gitrepos/libpcap/build/CMakeFiles/CMakeOutput.log".
See also "/boot/home/gitrepos/libpcap/build/CMakeFiles/CMakeError.log".

The CMakeError.log file contains the following:

make[1]: Entering directory '/boot/home/gitrepos/libpcap/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_2778b.dir/CheckSymbolExists.c.o
/bin/clang    -MD -MT CMakeFiles/cmTC_2778b.dir/CheckSymbolExists.c.o -MF CMakeFiles/cmTC_2778b.dir/CheckSymbolExists.c.o.d -o CMakeFiles/cmTC_2778b.dir/CheckSymbolExists.c.o -c /boot/home/gitrepos/libpcap/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_2778b
/boot/system/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2778b.dir/link.txt --verbose=1
/bin/clang CMakeFiles/cmTC_2778b.dir/CheckSymbolExists.c.o -o cmTC_2778b 
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: CMakeFiles/cmTC_2778b.dir/CheckSymbolExists.c.o: relocation R_X86_64_32S against symbol `vsnprintf' can not be used when making a shared object; recompile with -fPIC
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
clang-9: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_2778b.dir/build.make:99: recipe for target 'cmTC_2778b' failed
make[1]: *** [cmTC_2778b] Error 1
make[1]: Leaving directory '/boot/home/gitrepos/libpcap/build/CMakeFiles/CMakeTmp'
Makefile:127: recipe for target 'cmTC_2778b/fast' failed
make: *** [cmTC_2778b/fast] Error 2

Besides the linking error it is possible to see that CMake for some reason uses Clang to perform the tests, although CC=gcc. This for some reason happens even with CXX=gcc.

CMake + Clang is still broken

This is effectively the same as above right now (Clang + GCC linker).

infrastation avatar Jul 09 '22 09:07 infrastation

Another little mystery solved. For reasons unknown git status on Hauki does not display the build directory left over from a previous unsuccessful CMake round of build.sh. On other systems this directory usually fails the build in an obvious way and I remove it manually, but in this case it failed the build in a non-obvious way and I did not see why.

CMake + GCC now builds

(with warnings, as above)

infrastation avatar Jul 09 '22 10:07 infrastation

Apparently, on this OS with this CMake CMakeCache.txt and CMakeFiles/ end up under build/, which explains the projection of effects from one build to another, and the absence of build/ from git status output when there is no other contents in the directory (.gitignore does not specify the directory for these entries). Commit a44b7a5 removes these details from the problem space.

infrastation avatar Jul 09 '22 10:07 infrastation

Apparently, on this OS with this CMake CMakeCache.txt and CMakeFiles/ end up under build/

Even if you're not doing a build in a build directory?

That's what I've always seen happen if you do the build in a build directory.

guyharris avatar Jul 09 '22 11:07 guyharris

Some time ago I definitely had to remove CMakeFiles/ manually from the top directory on many occasions, but it is difficult to remember if that included any automatic builds using build_matrix.sh. Anyway, the cleanup now covers both cases in both libpcap and tcpdump.

I upgraded Clang to 12.0 and tried to work around the GCC linker mismatch, with mixed results (the process fails later on):

CXX=clang++ MATRIX_CC=clang MATRIX_CMAKE=no ./build_matrix.sh 
Haiku shredder 1 hrev55181+66 Jul  6 2022 08:03: x86_64 x86_64 Haiku
OS identification: Haiku-hrev55181
Sat Jul  9 11:06:55 GMT 2022
PREFIX set to '/tmp/libpcap_build_matrix.dy8TnkTA'
===== SETUP 1: CC=clang CMAKE=no REMOTE=no =====
$ ./build.sh
clang version 12.0.1
Target: x86_64-unknown-haiku
Thread model: posix
InstalledDir: /bin
Compiler identification: clang-12.0.1
$ ./configure --prefix=/tmp/libpcap_build_matrix.dy8TnkTA --enable-remote=no

[...]

$ make -s testprogs
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /tmp/can_set_rfmon_test-96eb7f.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
clang-12: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
Makefile:107: recipe for target 'can_set_rfmon_test' failed

Setting up a Haiku Buildbot worker would really improve the OS support. For reference, my VirtualBox VM setup steps are as follows:

  1. Install a VM from haiku-r1beta3-x86_64-anyboot.iso.
  2. Launch Applications -> HaikuDepot, run HaikuDepot -> Check for updates and install all updates
  3. Reboot.
  4. Launch Applications -> HaikuDepot, install: Vim, llvm12_clang, CMake, VirtualBox Guest Additions.
  5. Reboot.

infrastation avatar Jul 09 '22 11:07 infrastation

That error seems to be 64bit specific, maybe a bug in the compiler setup.

I can have a look at the warnings later on.

mmuman avatar Jul 09 '22 12:07 mmuman

You are welcome to reduce this problem space more if you can. Ideally libpcap and tcpdump releases should be able to build on Haiku right after unpacking the tarballs, although I am not sure how realistic that is. Also it looks like Haiku CI ideally would use a 64-bit worker and a 32-bit worker.

infrastation avatar Jul 09 '22 12:07 infrastation

Yes the 32bit gcc2h version is still the official one until after R1.

mmuman avatar Jul 09 '22 12:07 mmuman

With a freshly installed haiku-r1beta3-x86_gcc2h-anyboot.iso GCC 8.3.0 (which needs to be run as gcc-x86) produces a number of new warnings. Looks like this issue is going to remain open for a while before all pending fixes get applied.

infrastation avatar Jul 09 '22 12:07 infrastation

You can export PATH=/bin/x86:$PATH or call setarch x86 to have it as gcc.

mmuman avatar Jul 09 '22 14:07 mmuman

@mmuman, do you think it would be possible to convert pcap-haiku.cpp to plain C? Building the project in two languages is often such an inconvenience.

infrastation avatar Jul 12 '22 06:07 infrastation

At first glance I don't see why it's a .cpp file… Only seems to use C API. Maybe it was just copied from the BeOS version at some point? Would need to try I suppose.

mmuman avatar Jul 12 '22 08:07 mmuman

Short update on libpcap 9deff43

Haiku x86_64 hrev56710, gcc 11.2.0

Successful build with autoconf+make and CMake+Ninja 4 warnings in gencode.c related to alignment

I built using default commands:

./configure
make

resp

cmake -S . -B build -G Ninja
cmake --build build

Haiku x86 hrev56710, gcc 2.95.3

Build fails on pcap-haiku.cpp, ~~some more investigation is needed~~ I'll look into converting it to C.

Haiku x86 hrev56710, gcc 11.2.0

Successful build with using the following commands (unfortunately it's a bit clunky) 4 warnings in gencode.c related to alignment

CC=gcc-x86 CXX=g++-x86 LD=ld-x86 ./configure
CC=gcc-x86 CXX=g++-x86 LD=ld-x86 make

resp

CC=gcc-x86 CXX=g++-x86 LD=ld-x86 cmake -S . -B build -G Ninja
cmake --build build

davidkaroly avatar Jan 15 '23 20:01 davidkaroly

Thank you for the update. You would be welcome to document non-obvious details of current Haiku support in a new doc/README.haiku.md file.

infrastation avatar Jan 21 '23 13:01 infrastation

Thank you for the update. You would be welcome to document non-obvious details of current Haiku support in a new doc/README.haiku.md file.

ok sounds like a good suggestion

but before that, a short update on build matrix.

git rev 2f13170dc2 on Haiku hrev56724

Haiku x86_64, gcc 11.2.0

Build matrix gives 4 successful builds - CMAKE=yes/no, REMOTE=yes/no, with the following command

MATRIX_CC=gcc ./build_matrix.sh

Haiku x86, gcc 2.95.3 legacy toolchain

I'd rather just foget about this combo :wink:

Haiku x86, gcc 11.2.0

Build matrix gives 4 successful builds - CMAKE=yes/no, REMOTE=yes/no, with the following command

MATRIX_CC=gcc setarch x86 ./build_matrix.sh

Clang

Some more investigation is needed

  • I had no luck with clang++ so let's return to this once the review for #1153 has concluded
  • we'll need to add -fPIC

davidkaroly avatar Jan 22 '23 15:01 davidkaroly

Another useful thing would be to see how many of the compiler warnings listed in build.sh still stand and which can be properly resolved. Ideally it would be nice to reach a state with no warnings and to stop setting LIBPCAP_TAINTED on Haiku, this way build_matrix.sh would fail as soon as a warning appears again.

infrastation avatar Jan 28 '23 00:01 infrastation

As discussed, build.sh is now up to date (4 compiler warnings remain). Also there is a new README file, which currently documents the 64-bit leg. You are welcome to improve this further.

infrastation avatar Feb 11 '23 16:02 infrastation

Looks like Guy has cracked the Clang part of problem: the current master branch passes the full build matrix on 64-bit R1/beta4.

infrastation avatar Feb 14 '23 22:02 infrastation

Alright, thanks to everyone who participated, this problem has been solved. Let's keep it this way.

infrastation avatar Feb 15 '23 00:02 infrastation

@infrastation I see you suggested setting up a Haiku buildbot. I set it up as an example in my fork (only for r1beta4): https://github.com/korli/libpcap/commit/145663de6ec1db890af06dfb32be343a00d0f436

korli avatar Mar 17 '24 18:03 korli