samples/bpf: Partially fixes the bpf.o build
Subsystems (3)
PATCH 1/1 samples/bpf: Partially fixes the bpf.o build
Do not build lib/bpf/bpf.o with this Makefile but use the one from the library directory. This avoid making a buggy bpf.o file (e.g. missing symbols).
This patch is useful if some code (e.g. Landlock tests) needs both the bpf.o (from tools/lib/bpf) and the bpf_load.o (from samples/bpf).
---
This is not a complet fix because the call to multi_depend with $(host-cmulti) from scripts/Makefile.host force the build of bpf.o anyway. I'm not sure how to completely avoid this automatic build though.
--- samples/bpf/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
samples/bpf/Makefile +4 -1
@@ -201,13 +201,16 @@ CLANG_ARCH_ARGS = -target $(ARCH) endif # Trick to allow make to be run from this directory -all: +all: $(LIBBPF) $(MAKE) -C ../../ $(CURDIR)/ clean: $(MAKE) -C ../../ M=$(CURDIR) clean @rm -f *~ +$(LIBBPF): FORCE + $(MAKE) -C $(dir $@) $(notdir $@) + $(obj)/syscall_nrs.s: $(src)/syscall_nrs.c $(call if_changed_dep,cc_s_c)
Signature · 1 line
2.15.1
Quoted 3 lines · Mickaël Salaün
Do not build
lib/bpf/bpf.owith thisMakefilebut use the one from the library directory. This avoid making a buggy bpf.o file (e.g. missing symbols).
could you provide an example?
What symbols will be missing?
I don't think there is an issue with existing Makefile.
Quoted 2 lines
This patch is useful if some code (e.g. Landlock tests) needs both the bpf.o (from
tools/lib/bpf) and the bpf_load.o (fromsamples/bpf).
is that some future patches?
we're trying to move everything form samples/bpf/ into selftests/bpf/ and convert to use libbpf.a instead of obsolete bpf_load.c Please use this approach for landlock as well.
Quoted 38 lines
Signed-off-by Mickaël Salaün <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>---
This is not a complet fix because the call to
multi_dependwith $(host-cmulti) fromscripts/Makefile.hostforce the build of bpf.o anyway. I'm not sure how to completely avoid this automatic build though.--- samples/bpf/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)samples/bpf/Makefile +4
-1@@ -201,13 +201,16 @@ CLANG_ARCH_ARGS = -target $(ARCH) endif # Trick to allow make to be run from this directory -all: +all: $(LIBBPF) $(MAKE) -C ../../ $(CURDIR)/ clean: $(MAKE) -C ../../ M=$(CURDIR) clean @rm -f *~ +$(LIBBPF): FORCE + $(MAKE) -C $(dir $@) $(notdir $@) + $(obj)/syscall_nrs.s: $(src)/syscall_nrs.c $(call if_changed_dep,cc_s_c)Signature · 1 line
2.15.1
Quoted 8 lines · Alexei Starovoitov
Quoted 3 lines · Mickaël Salaün
Do not build
lib/bpf/bpf.owith thisMakefilebut use the one from the library directory. This avoid making a buggy bpf.o file (e.g. missing symbols).could you provide an example?
What symbols will be missing?
I don't think there is an issue with existingMakefile.
You can run this commands:
make -C samples/bpf; nm tools/lib/bpf/bpf.o > a; make -C tools/lib/bpf; nm tools/lib/bpf/bpf.o > b; diff -u a b
Symbols like bzero and sys_bpf are missing with the samples/bpf Makefile, which makes the bpf.o shrink from 25K to 7K.
Quoted 5 lines
Quoted 3 lines
This patch is useful if some code (e.g. Landlock tests) needs both the bpf.o (from
tools/lib/bpf) and the bpf_load.o (fromsamples/bpf).is that some future patches?
Yes, I'll send them next week.
Quoted 4 lines
we're trying to move everything form
samples/bpf/into selftests/bpf/ and convert to use libbpf.a instead of obsoletebpf_load.cPlease use this approach for landlock as well.
Ok, it should be better with this lib.
Quoted 40 lines
Quoted 39 lines
Signed-off-by Mickaël Salaün <[email protected]>Cc Alexei Starovoitov <[email protected]>Cc Daniel Borkmann <[email protected]>---
This is not a complet fix because the call to
multi_dependwith $(host-cmulti) fromscripts/Makefile.hostforce the build of bpf.o anyway. I'm not sure how to completely avoid this automatic build though.--- samples/bpf/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)samples/bpf/Makefile +4
-1@@ -201,13 +201,16 @@ CLANG_ARCH_ARGS = -target $(ARCH) endif # Trick to allow make to be run from this directory -all: +all: $(LIBBPF) $(MAKE) -C ../../ $(CURDIR)/ clean: $(MAKE) -C ../../ M=$(CURDIR) clean @rm -f *~ +$(LIBBPF): FORCE + $(MAKE) -C $(dir $@) $(notdir $@) + $(obj)/syscall_nrs.s: $(src)/syscall_nrs.c $(call if_changed_dep,cc_s_c)Signature · 1 line
2.15.1
Quoted 10 lines · Mickaël Salaün
Quoted 8 lines · Alexei Starovoitov
Quoted 3 lines · Mickaël Salaün
Do not build
lib/bpf/bpf.owith thisMakefilebut use the one from the library directory. This avoid making a buggy bpf.o file (e.g. missing symbols).could you provide an example?
What symbols will be missing?
I don't think there is an issue with existingMakefile.
Quoted 6 lines
You can run this commands:
make -Csamples/bpf; nmtools/lib/bpf/bpf.o> a; make -Ctools/lib/bpf; nmtools/lib/bpf/bpf.o> b; diff -u a bSymbols like bzero and
sys_bpfare missing with thesamples/bpfMakefile, which makes the bpf.o shrink from 25K to 7K.
I've applied it to bpf-next, thanks Mickaël!