tcpdump icon indicating copy to clipboard operation
tcpdump copied to clipboard

mkdep does not detect compiler failures

Open infrastation opened this issue 1 year ago • 1 comments

This problem stands for all instances of mkdep, but it manifests in tcpdump only (tcpdump-4.99 commit 0bdde63):

> ./build_matrix.sh 
Haiku haikudev 1 hrev57709 Apr 21 2024 06:35:41 x86_64 x86_64 Haiku
OS identification: Haiku-hrev57709
Mon Apr 22 14:16:31 BST 2024
PREFIX set to '/boot/system/var/shared_memory/tcpdump_build_matrix.HkmGySf3'
Use system libpcap
make: *** No rule to make target 'distclean'.  Stop.
(Ignoring the make error.)
===== SETUP 1: CC=gcc BUILD_LIBPCAP=no REMOTE=? CMAKE=no CRYPTO=no SMB=no =====
$ ./build.sh
gcc (2023_08_10) 13.2.0
[...]
./mkdep -c gcc -m -M -s . -DHAVE_CONFIG_H -I. -I/packages/libpcap-1.10.4-2/.self/develop/headers fptype.c tcpdump.c <libnetdissect src list>
In file included from ./addrtoname.c:101:
./getservent.h:42:2: error: #error netdb.h and getservent.h are incompatible
   42 | #error netdb.h and getservent.h are incompatible
      |  ^~~~~
$ make -s clean
$ make -s CFLAGS=-Werror
In file included from ./missing/getservent.c:42:
./getservent.h:42:2: error: #error netdb.h and getservent.h are incompatible
   42 | #error netdb.h and getservent.h are incompatible
(and many other errors)

The reason why the script does not detect the compiler failure is because it is not the last command of a pipe:

$CC $DEPENDENCY_CFLAG $flags $sources |
sed "
        s; \./; ;g
        $SED" >> $TMP

Because the -o pipefail shell option is a bashism, a portable solution could be replacing the pipe with two independent commands and an additional temporary file.

infrastation avatar Apr 22 '24 21:04 infrastation

The compiler generates an error because HAVE_GETSERVENT is not defined because in tcpdump-4.99 Autoconf does not detect getservent(), which in Haiku requires -lnetwork. This problem is not new. Currently the tcpdump recipe in HaikuPorts uses a patch to work around that, and the master branch since commit de21eda uses a version of AC_LBL_LIBRARY_NET that correctly works on Haiku.

But the matter is, the compiler failure should have caused mkdep to fail.

infrastation avatar Apr 23 '24 22:04 infrastation