Skip to content
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

Makefile: Print all detected features when building source #186

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Shankari02
Copy link

Fixes #181

This PR introduces the functionality of printing all detected features when VF=1 in the repository, similar to the kernel behavior. Currently, the V=1 flag prints detailed information about feature detection, but the output is more concise when VF=1. By adding this functionality, we enhance the debugging experience by providing clear and structured feedback on the detected features during the build process.

The output of the modified src/Makefile.feature to display the features is as follows:

shankari@shankari-IdeaPad:~/bpftool/src$ VF=1 make
...                        libbfd: [ on  ]
...                libbfd-liberty: [ OFF ]
...              libbfd-liberty-z: [ OFF ]
...               clang-bpf-co-re: [ on  ]
...                          llvm: [ on  ]
...                        libcap: [ on  ]
...        disassembler-four-args: [ on  ]
...      disassembler-init-styled: [ on  ]
...                   libelf-zstd: [ OFF ]
make: Nothing to be done for 'all'.

Comment on lines +103 to +122
### 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

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!).

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).

Comment on lines +192 to +200
$(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)
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print all detected features when VF=1
2 participants