Skip to content

Commit

Permalink
mirror: Define PACKAGE at build time when trying to detect libbfd
Browse files Browse the repository at this point in the history
Feature detection from the Makefile.feature for libbfd (with the
different variants of the probe) may fail on some systems where the
bfd.h and dis-asm.h headers expect the PACKAGE or PACKAGE_VERSION macros
to be defined [0]. In the kernel tree, feature detection addresses it by
defining the PACKAGE macro when invoking the compiler [1]. Add a similar
definition for the mirror repository.

Note that this issue has remained undetected for a while. This is
because the bfd.h included in some distributions (Debian/Ubuntu, for
example) does not contain the inclusion guard [2].

[0] https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/bfd-in.h;h=04e65aad5f0c235a5013513c545e57a01e96541f;hb=binutils-2_43_1#l27
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/build/feature/Makefile?h=v6.11#n114
[2] https://git.launchpad.net/ubuntu/+source/binutils/tree/debian/rules?h=applied/2.43.1-5#n1031

Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Signed-off-by: Quentin Monnet <qmo@kernel.org>
  • Loading branch information
qmonnet committed Oct 14, 2024
1 parent 39d789e commit 977e56a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Makefile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ LIBBFD_PROBE += ' bfd_demangle(0, 0, 0);'
LIBBFD_PROBE += ' return 0;'
LIBBFD_PROBE += '}'
LIBBFD_PROBE_CMD = printf '%b\n' $(LIBBFD_PROBE) | \
$(CC) $(CFLAGS) -Wall -Werror -x c - $(1) -o /dev/null >/dev/null
$(CC) $(CFLAGS) -Wall -Werror -x c -DPACKAGE='"bpftool"' - $(1) -o /dev/null >/dev/null

define libbfd_build
$(call detect,$(LIBBFD_PROBE_CMD))
Expand Down Expand Up @@ -78,7 +78,7 @@ DISASSEMBLER_PROBE += ' return 0;'
DISASSEMBLER_PROBE += '}'

DISASSEMBLER_PROBE_CMD = printf '%b\n' $(1) | \
$(CC) $(CFLAGS) -Wall -Werror -x c - -lbfd -lopcodes -S -o - >/dev/null
$(CC) $(CFLAGS) -Wall -Werror -x c -DPACKAGE='"bpftool"' - -lbfd -lopcodes -S -o - >/dev/null
define disassembler_build
$(call detect,$(DISASSEMBLER_PROBE_CMD))
endef
Expand Down

0 comments on commit 977e56a

Please sign in to comment.