From ce6ecb677e3b15570f60771a5e863ea42b84a3dd Mon Sep 17 00:00:00 2001 From: corubba Date: Sun, 9 Nov 2025 16:10:09 +0100 Subject: [PATCH] instrument functions: Work around bfd inclusion guard In 2012 [0] [1] binutils added an inclusion guard to bfd.h, requiring to include the autoconf config.h beforehand. This guard is triggered when enabling instrumentation and development mode: % git clone https://github.com/the-tcpdump-group/tcpdump.git % cd tcpdump % touch .devel % ./autogen.sh % ./configure --enable-instrument-functions --enable-smb --quiet ./mkdep -c gcc -m -M -s . -DHAVE_CONFIG_H -I. fptype.c tcpdump.c \ print-smb.c smbutil.c instrument-functions.c In file included from ./instrument-functions.c:18: /usr/include/bfd.h:35:2: error: #error config.h must be included before this header 35 | #error config.h must be included before this header | ^~~~~ Note than this does *not* happen on Debian-based systems, because they remove [2] that guard since 2012 [3]. That's also why the Ubuntu-based Linux CI is not affected. [0] https://sourceware.org/bugzilla/show_bug.cgi?id=14072 [1] https://sourceware.org/git/?p=binutils-gdb.git;a=blobdiff;f=bfd/bfd-in.h;h=ae8149a2;hp=d88bcb6c;hb=df7b86aa;hpb=134fa82e [2] https://salsa.debian.org/toolchain-team/binutils/-/blob/38415eb8/debian/rules#L1045-1048 [3] https://code.launchpad.net/~doko/binutils/pkg-2.23-debian [skip ci] --- instrument-functions.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/instrument-functions.c b/instrument-functions.c index ba0a56a53..6a472a5fa 100644 --- a/instrument-functions.c +++ b/instrument-functions.c @@ -15,7 +15,15 @@ #include #include #include + +/* + * The binutils bfd header has a weird inclusion guard, requiring this + * macro to be defined. Some distributions patch the guard out, others + * don't. + */ +#define PACKAGE "binutils-bfd.h-guard-workaround" #include +#undef PACKAGE /* * Generate instrumentation calls for entry and exit to functions.