Building a "statically compiled tcpdump" for ksniff
Hi all, I wanted to package ksniff aka kubectl-sniff (https://github.com/eldadru/ksniff) for openSUSE. It allows sniffing the network traffic inside a Kubernetes pod and forwards it to a local wireshark instance. Very helpful sometimes. Anyways, to work properly it needs a "static tcpdump binary" that it can inject into the pod. I wanted to build it inside the knsiff package. But as soon as I add the "CFLAGS=-static" from the ksniff makefile, the configure breaks as the compiler cannot create executables.
https://build.opensuse.org/package/show/home:ojkastl_buildservice:Branch_dev...
Here is the interesting Makefile part:
"CFLAGS=-static ./configure --without-crypto && make" I added all of the %configure macro options manually and tried to add BuildRequires, but I am stuck. Which package do I have to add to get this working? Thanks in advance! Kind Regards, Johannes
[ 37s] + CFLAGS='-O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -DGUESS_TSO -static' [ 37s] + export CFLAGS [ 37s] + ./configure --without-crypto [ 37s] checking build system type... x86_64-unknown-linux-gnu [ 37s] checking host system type... x86_64-unknown-linux-gnu [ 37s] checking for gcc... gcc [ 37s] checking whether the C compiler works... no [ 37s] configure: error: in `/home/abuild/rpmbuild/BUILD/ksniff-1.6.2/tcpdump-4.9.2': [ 37s] configure: error: C compiler cannot create executables [ 37s] See `config.log' for more details [ 37s] error: Bad exit status from /var/tmp/rpm-tmp.l57W35 (%build)
The config.log says:
Supported LTO compression algorithms: zlib zstd ... rest of stderr output deleted ... configure:2867: $? = 0 configure:2856: gcc -V >&5 gcc: error: unrecognized command-line option '-V' gcc: fatal error: no input files compilation terminated. configure:2867: $? = 1 configure:2856: gcc -qversion >&5 gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'? gcc: fatal error: no input files compilation terminated. configure:2867: $? = 1 configure:2887: checking whether the C compiler works configure:2909: gcc -static conftest.c >&5 /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/bin/ld: cannot find -lc: No such file or directory collect2: error: ld returned 1 exit status configure:2913: $? = 1 configure:2951: result: no configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "" | #define PACKAGE_TARNAME "" | #define PACKAGE_VERSION "" | #define PACKAGE_STRING "" | #define PACKAGE_BUGREPORT "" | #define PACKAGE_URL "" | /* end confdefs.h. */ |
-- Johannes Kastl Linux Consultant & Trainer Tel.: +49 (0) 151 2372 5802 Mail: kastl@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg http://www.b1-systems.de GF: Ralph Dehner Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
You need the static libraries for static linking, which are usually packaged separately, if available at all. So start with glibc-devel-static, and add whatever else is needed. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Hi Andreas, On 26.09.23 at 16:42 Andreas Schwab wrote:
You need the static libraries for static linking, which are usually packaged separately, if available at all. So start with glibc-devel-static, and add whatever else is needed.
I already had glibc-devel-static, but just noticed I had a typo and used glib2-... ("2", not "c"). That actually makes the compiler error thingy go away and the configure goes to a point where I can check what is actually missing... Thanks for the reply! Kind Regards, Johannes -- Johannes Kastl Linux Consultant & Trainer Tel.: +49 (0) 151 2372 5802 Mail: kastl@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg http://www.b1-systems.de GF: Ralph Dehner Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
participants (2)
-
Andreas Schwab
-
Johannes Kastl