Identification examples: tcc-0.9.27, tcc-0.9.28rc
There are currently warnings such as:
print-802_11.c:3317: warning: assignment discards qualifiers from pointer
target type
print-esp.c:373: warning: function might return no value: 'ldp_pdu_print'
So use: TCPDUMP_TAINTED=yes
Works on linux-amd64.
Does not work on linux-armv7l with BUILD_LIBPCAP=yes / CMAKE=yes
(Segmentation fault, libpcap dynamically linked). Works with 0.9.28rc.
TinyCC can be found at https://bellard.org/tcc/,
https://repo.or.cz/r/tinycc.git or as package on some distros.
This lets us remove a bunch of configure-time and compile-time tests.
Update documentation to reflect this.
WinPcap 4.1.3 is based on libpcap 1.0, but doesn't export all of the new
APIs, so it won't work with code that uses any of the other APIs, which
tcpdump does, so don't test with WinPcap.
As it turns out, the root cause of Clang warnings about tcpdump.c on
illumos has to do with illumos headers rather than tcpdump. Until the
bug fix is in place and has propagated well into illumos distributions,
use a workaround: add a new pair of diagnostic control macros for Clang
only and on illumos wrap the "offending" lines with it.
When the PREFIX variable is set before build.sh runs, this means it
points to a directory that build.sh needs neither to create nor to
remove, as that's a responsibility of whoever runs build.sh (which is
usually build_matrix.sh). When the variable is not set before build.sh
runs, it means build.sh needs to create a temporary directory and to
remove it afterwards.
This convention works in libpcap and tcpslice, but in tcpdump the script
does not delete the temporary directory because I did not port the logic
correctly in commit 75e92be. Get this right.
Put autoconf-generated files in the release tarball.
The minimum required version of autoconf is currently 2.69.
If version 2.69 or later is already installed and there is no
autoconf default, it may be necessary to set the AUTORECONF
environment variable to enable the one to use, like:
AUTORECONF=autoreconf-2.69 ./autogen.sh
or
AUTORECONF=autoreconf-2.71 ./autogen.sh
The new environment variable provides means to declare all or some libpcap
cmake run of a specific environment (CI or a working copy) as tainted.
Add explicit conditions to exempt the cmake run that emit warnings
now and request the compiler to treat warnings as errors *iff* the cmake
run is not tainted. This way if a cmake run that is warning-free now
degrades later, CI will fail it.
The treat warnings as errors cmake option used is:
-Werror=dev
Make developer warnings errors.
Make warnings that are meant for the author of the CMake-
Lists.txt files errors. By default this will also turn on depre-
cated warnings as errors.
As it turns out, the same warnings reproduce with other Clang versions
(at least 11) and other illumos distributions (at least OmniOS), so omit
Clang version in the pattern.
On FreeBSD CMake runs Clang with -std=gnu99, which used to emit three
warnings in a Capsicum-specific block along the following lines:
tcpdump.c:2432:32: warning: '_Generic' is a C11 extension
[-Wc11-extensions]
/usr/include/libgen.h:61:21: note: expanded from macro 'basename'
basename)(x)
/usr/include/sys/cdefs.h:325:2: note: expanded from macro '__generic'
_Generic(expr, t: yes, default: no)
(In the same context Autoconf does not request a specific C standard
from Clang, so it happens to use C17 and there is no warning.)
Type-generic expressions support in C99 mode seems to be a quirk of
Clang that cannot be disabled and is harmless in this context, so
introduce and use another pair of diagnostic control macros (for Clang
only) to squelch the warnings.
While at it, study the reason for _Generic use in /usr/include/libgen.h
and realize that tcpdump.c still assumes the behaviour before FreeBSD
12.0. Add two temporary buffers around basename() and dirname() calls
to get consistent results regardless of which FreeBSD version it is.
Remove the last remaining exemption rule.
The Capsicum workaround I added in commit 706c79e causes a side effect
on FreeBSD 11.4, 12.2 and 13.0 with local libpcap when Capsicum is
enabled, that is, in CMake builds (Capsicum detection is broken in
Autoconf builds, as it turns out). Add a workaround for the side effect
as well and get rid of another warning and respective exemption:
tcpdump.c:2286:3: warning: implicit declaration of function 'bpf_dump'
is invalid in C99 [-Wimplicit-function-declaration]
Address the warning below (specific to a few versions of Clang, CMake
and FreeBSD) and update the exemption rule comment in build.sh.
tcpdump.c:244:16: warning: no previous extern declaration for non-static
variable 'capdns' [-Wmissing-variable-declarations]
As it turns out, most FreeBSD/CMake tcpdump builds were emitting some
warnings. This was difficult to notice because make returned success
regardless of the warnings because the compiler never received -Werror
because there was no way to tell CMake to append any compiler flags at
the build time, but not at the buildsystem generation time. In other
words, the command "make CFLAGS=-Werror" had the same effect as just
"make".
Implement the desired behaviour with "cmake -DEXTRA_CFLAGS='xyz'" and
set the variable in build.sh when and as required. Reword the comment
for clarity and define two known exemptions.
Call print_so_deps() just after "make install", so if dynamic linking
has failed for some reason, the failure to run tcpdump binary will not
prevent printing the details. Lose "tcpdump --version" because version
information is a part of "tcpdump -h" output.
-- Installing: /tmp/tcpdump_build_matrix.XXyKaiEo/bin/tcpdump
-- Set runtime path of "/tmp/tcpdump_build_matrix.XXyKaiEo/bin/tcpdump" to ""
-- Installing: /tmp/tcpdump_build_matrix.XXyKaiEo/share/man/man1/tcpdump.1
$ /tmp/tcpdump_build_matrix.XXyKaiEo/bin/tcpdump --version
ld.so.1: tcpdump: fatal: libpcap.so.1: open failed: No such file or directory
In build_common.sh add minimal heuristics to print_cc_version() to help
it run the right command; add cc_id() and cc_werr_cflags() to pick the
right CFLAGS for the current compiler instead of the previously
hard-coded "-Werror". Add some comments.
In build.sh remove the CFLAGS exemptions for AIX and Solaris 9 builds,
which are in a better shape now and can complete specific subsets of the
full matrix without a warning. Set CFLAGS from cc_werr_cflags() to make
the best effort to catch as many warnings as possible. Let's see how well
that works.
Start using build_common.sh, make default assignments early and
uniformly, use Solaris-compatible command substitution and exports,
install bc on linux-amd64, deduplicate and reformat some long commands.
Run "make -s" without CFLAGS=-Werror when warnings are expected.
This implements initial support for AIX and Solaris in the tcpdump build
matrix scripts.
* AIX 7.1
M4='/opt/freeware/bin/m4' \
MATRIX_CC='gcc' \
MATRIX_CMAKE=no \
MATRIX_BUILD_LIBPCAP=yes \
./build_matrix.sh
* Solaris 9
MATRIX_CC=gcc \
MATRIX_CMAKE=no \
MATRIX_BUILD_LIBPCAP=no \
./build_matrix.sh
* Solaris 10 and 11
MATRIX_CC='gcc' \
MATRIX_CMAKE=no \
./build_matrix.sh
Compiling user-provided source code and running the resulting binary
with sudo was a security problem, thus instead of fixing two no-op
blocks remove them altogether. If anyone later needs to debug features
that require higher privileges, they will need to come up with a better
solution. Simplify the debug output test condition and rephrase the
associated comment for clarity.
Running ldd on Linux only originates from the Travis CI setup, where the
OS was either Linux or macOS. However, ldd is available in BSD systems
too, and macOS seems to have its own tool for the same job.
This change allows to test the build with HAVE_PCAP_FINDALLDEVS_EX and
HAVE_PCAP_OPEN enabled.
Some ways to run theses tests:
MATRIX_BUILD_LIBPCAP=yes MATRIX_REMOTE=yes MATRIX_CMAKE=no MATRIX_CC=gcc \
MATRIX_CRYPTO=no MATRIX_SMB=no ./build_matrix.sh
(configure should display:
checking for pcap_open... yes
checking for pcap_findalldevs_ex... yes)
MATRIX_BUILD_LIBPCAP=yes MATRIX_REMOTE=yes MATRIX_CMAKE=yes MATRIX_CC=gcc \
MATRIX_CRYPTO=no MATRIX_SMB=no ./build_matrix.sh
(cmake should display:
Looking for pcap_open - found
Looking for pcap_findalldevs_ex - found)
Don't enable the builds with REMOTE=yes by default.
This partially reverts commit 3861a41bfa.
"Remove the REMOTE dimension from the nested matrix."
Neither the build process nor the tests of tcpdump currently depend on
presence or absence of the libpcap remote feature, and there is already
the libpcap nested matrix to cover that dimension, thus in the tcpdump
nested matrix just leave this aspect of the local libpcap build
unspecified and reduce the total number of rounds from 48 to 32.
Use them with Travis CI to build with less builders and save CI runtime.
This will currently run five builders: amd64, arm64, ppc64le, s390x and osx.
The build_matrix.sh script executes the matrix loops, exclude tests and
cleaning.
It conditionally builds libpcap running the build.sh script of libpcap.
It calls the build.sh script which runs one build with setup environment
variables: BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB
(default: BUILD_LIBPCAP=no, REMOTE=no, CC=gcc, CMAKE=no, CRYPTO=no, SMB=no).
The matrix can be configured with environment variables
MATRIX_BUILD_LIBPCAP, MATRIX_REMOTE, MATRIX_CC, MATRIX_CMAKE, MATRIX_CRYPTO
and MATRIX_SMB
(default: MATRIX_BUILD_LIBPCAP='no yes', MATRIX_REMOTE='no yes',
MATRIX_CC='gcc clang', MATRIX_CMAKE='no yes', MATRIX_CRYPTO='no yes',
MATRIX_SMB='no yes').
These scripts can easily be updated to run new tests (32 bits builds,
sanitizers, coverage, etc).
They can be used locally for build tests or used with other CI systems.
Run examples:
./build_matrix.sh
MATRIX_BUILD_LIBPCAP=yes ./build_matrix.sh
MATRIX_CC=clang ./build_matrix.sh
CC=clang ./build.sh
CMAKE=yes ./build.sh
CC=clang CMAKE=yes CRYPTO=yes ./build.sh
Moreover:
Remove the old workaround PATH=$PATH...
Update the install directory prefix to /tmp/local.
Use vim modeline in the two shell scripts.