Skip to content

Makefile: Print all detected features when building source #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/Makefile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ endif # disassembler-four-args
ifneq ($(findstring disassembler-init-styled,$(FEATURE_TESTS)),)
DISASSEMBLER_STYLED_PROBE := '$(pound)include <dis-asm.h>\n'
DISASSEMBLER_STYLED_PROBE += 'int main(void) {'
DISASSEMBLER_STYLED_PROBE += ' init_disassemble_info(NULL, 0, NULL, NULL);'
DISASSEMBLER_STYLED_PROBE += ' init_disassemble_info(NULL, 0, NULL);'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The make was failing by throwing an error saying the number of arguments do not match. Hence, I had to change this locally to make it work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is precisely what this probe is checking: whether the number of arguments match, or not, depending on libbfd's version, so that we know how many of them to use in bpftool's code (in src/jit_disasm.c).

DISASSEMBLER_STYLED_PROBE += ' return 0;'
DISASSEMBLER_STYLED_PROBE += '}'

Expand All @@ -100,6 +100,26 @@ feature-disassembler-init-styled := \
$(findstring 1, $(call disassembler_build,$(DISASSEMBLER_STYLED_PROBE)))
endif # disassembler-init-styled

### feature-libelf-zstd

ifneq ($(findstring libelf-zstd,$(FEATURE_TESTS)),)
LIBELF_ZSTD_PROBE := '$(pound)include <elf.h>\n'
LIBELF_ZSTD_PROBE += 'int main(void) {'
LIBELF_ZSTD_PROBE += ' Elf *e = NULL;'
LIBELF_ZSTD_PROBE += ' return 0;'
LIBELF_ZSTD_PROBE += '}'
LIBELF_ZSTD_PROBE_CMD = printf '%b\n' $(LIBELF_ZSTD_PROBE) | \
$(CC) $(CFLAGS) -Wall -Werror -x c - -lelf -lz -S -o - >/dev/null

define libelf_zstd_build
$(call detect,$(LIBELF_ZSTD_PROBE_CMD))
endef

$(call LOG,Probing: feature-libelf-zstd)
feature-libelf-zstd := \
$(findstring 1, $(call libelf_zstd_build))
endif # libelf-zstd

Comment on lines +103 to +122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this one out for now, please. There's a bit more to it, it should be addressed in #179 (I need to get back to that one!).

### feature-libcap

ifneq ($(findstring libcap,$(FEATURE_TESTS)),)
Expand Down Expand Up @@ -169,9 +189,15 @@ endef
feature_print_status = $(eval $(print_status)) $(info $(MSG))

$(call feature_print_status,$(HAS_LIBBFD),libbfd)
$(call feature_print_status,$(feature-libbfd-liberty),libbfd-liberty)
$(call feature_print_status,$(feature-libbfd-liberty-z),libbfd-liberty-z)

$(foreach feature,$(filter-out libbfd%,$(FEATURE_DISPLAY)), \
$(call feature_print_status,$(feature-$(feature)),$(feature)))

$(call feature_print_status,$(feature-disassembler-four-args),disassembler-four-args)
$(call feature_print_status,$(feature-disassembler-init-styled),disassembler-init-styled)
$(call feature_print_status,$(feature-libelf-zstd),libelf-zstd)
Comment on lines +192 to +200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prints all values unconditionally. Did you check the output from make, without the VF=1?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologise for this mistake, I'll make the required changes in the new commit.


CFLAGS := $(CFLAGS_BACKUP)
undefine LOG LOG_RES