bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* samples/bpf not working?
@ 2019-10-04 22:21 Daniel T. Lee
  2019-10-05 18:27 ` Andrii Nakryiko
  2019-10-05 19:20 ` Eric Sage
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel T. Lee @ 2019-10-04 22:21 UTC (permalink / raw)
  To: bpf, xdp-newbies, Daniel Borkmann, Alexei Starovoitov, netdev

Currently, building the bpf samples isn't working.
Running make from the directory 'samples/bpf' will just shows following
result without compiling any samples.

$ make
make -C ../../ /git/linux/samples/bpf/ BPF_SAMPLES_PATH=/git/linux/samples/bpf
make[1]: Entering directory '/git/linux'
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
make[1]: Leaving directory '/git/linux'
$ ls *kern.o
ls: cannot access '*kern.o': No such file or directory

By using 'git bisect', found the problem is derived from below commit.
commit 394053f4a4b3 ("kbuild: make single targets work more correctly")

> Currently, the single target build directly descends into the directory
> of the target. For example,
>
>     $ make foo/bar/baz.o
>
> ... directly descends into foo/bar/.
>
> On the other hand, the normal build usually descends one directory at
> a time, i.e. descends into foo/, and then foo/bar/.
>
> This difference causes some problems.
>
> [...]
>
> This commit fixes those problems by making the single target build
> descend in the same way as the normal build does.

Not familiar with kbuild, so I'm not sure why this led to build failure.
My humble guess is, samples/bpf/Makefile tries to run make from current
directory, 'sample/bpf', but somehow upper commit changed the way it works.

samples/bpf/Makefile:232
# Trick to allow make to be run from this directory
all:
        $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)

I've tried to figure out the problem with 'make --trace', but not sure why
it's not working. Just a hunch with build directory.

Any ideas to fix this problem?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: samples/bpf not working?
  2019-10-04 22:21 samples/bpf not working? Daniel T. Lee
@ 2019-10-05 18:27 ` Andrii Nakryiko
  2019-10-05 19:20 ` Eric Sage
  1 sibling, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2019-10-05 18:27 UTC (permalink / raw)
  To: Daniel T. Lee
  Cc: bpf, xdp-newbies, Daniel Borkmann, Alexei Starovoitov, netdev

On Fri, Oct 4, 2019 at 3:28 PM Daniel T. Lee <danieltimlee@gmail.com> wrote:
>
> Currently, building the bpf samples isn't working.
> Running make from the directory 'samples/bpf' will just shows following
> result without compiling any samples.
>
> $ make
> make -C ../../ /git/linux/samples/bpf/ BPF_SAMPLES_PATH=/git/linux/samples/bpf
> make[1]: Entering directory '/git/linux'
>   CALL    scripts/checksyscalls.sh
>   CALL    scripts/atomic/check-atomics.sh
>   DESCEND  objtool
> make[1]: Leaving directory '/git/linux'
> $ ls *kern.o
> ls: cannot access '*kern.o': No such file or directory
>
> By using 'git bisect', found the problem is derived from below commit.
> commit 394053f4a4b3 ("kbuild: make single targets work more correctly")
>
> > Currently, the single target build directly descends into the directory
> > of the target. For example,
> >
> >     $ make foo/bar/baz.o
> >
> > ... directly descends into foo/bar/.
> >
> > On the other hand, the normal build usually descends one directory at
> > a time, i.e. descends into foo/, and then foo/bar/.
> >
> > This difference causes some problems.
> >
> > [...]
> >
> > This commit fixes those problems by making the single target build
> > descend in the same way as the normal build does.
>
> Not familiar with kbuild, so I'm not sure why this led to build failure.
> My humble guess is, samples/bpf/Makefile tries to run make from current
> directory, 'sample/bpf', but somehow upper commit changed the way it works.
>
> samples/bpf/Makefile:232
> # Trick to allow make to be run from this directory
> all:
>         $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
>
> I've tried to figure out the problem with 'make --trace', but not sure why
> it's not working. Just a hunch with build directory.
>
> Any ideas to fix this problem?

Yes, it's now a known problem. You need to run it as `make
M=samples/bpf` from root directory, as well as have all the recent
fixes both from bpf and bpf-next trees (:(, this will be a bit better
once bpf is merged into bpf-next).

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: samples/bpf not working?
  2019-10-04 22:21 samples/bpf not working? Daniel T. Lee
  2019-10-05 18:27 ` Andrii Nakryiko
@ 2019-10-05 19:20 ` Eric Sage
  2019-10-06  6:49   ` Andrii Nakryiko
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Sage @ 2019-10-05 19:20 UTC (permalink / raw)
  To: netdev; +Cc: bpf, daniel, xdp-newbies, ast, Eric Sage

394053f4a4b3 ("kbuild: make single targets work more correctly")
changed the way single target builds work. For example,
'make samples/bpf/' in the previous commit matched:

Makefile:1787
%/: prepare FORCE
  $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) need-modorder=1

So that 'samples/bpf/Makefile' was processed directly.
Commit 394053f4a4b3 removed this rule and now requires that
'CONFIG_SAMPLES=y' and that 'bpf/' be added to 'samples/Makefile'
so it is added to the list of targets processed by the new
'ifdef single-build' section of 'scripts/Makefile.build'.

This commit adds a new 'CONFIG_SAMPLE_BPF' under 'CONFIG_SAMPLES' to
match what the other sample subdirs have done.

Signed-off-by: Eric Sage <eric@sage.org>
---
 samples/Kconfig  | 6 ++++++
 samples/Makefile | 1 +
 2 files changed, 7 insertions(+)

diff --git a/samples/Kconfig b/samples/Kconfig
index c8dacb4dda80..396e87ba97e0 100644
--- a/samples/Kconfig
+++ b/samples/Kconfig
@@ -6,6 +6,12 @@ menuconfig SAMPLES
 
 if SAMPLES
 
+config SAMPLE_BPF
+	tristate "Build bpf examples"
+	depends on EVENT_TRACING && m
+	help
+	  This builds the bpf example modules.
+
 config SAMPLE_TRACE_EVENTS
 	tristate "Build trace_events examples -- loadable modules only"
 	depends on EVENT_TRACING && m
diff --git a/samples/Makefile b/samples/Makefile
index 7d6e4ca28d69..e133a78f3fb8 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -2,6 +2,7 @@
 # Makefile for Linux samples code
 
 obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS)	+= binderfs/
+obj-$(CONFIG_SAMPLE_BPF) += bpf/
 obj-$(CONFIG_SAMPLE_CONFIGFS)		+= configfs/
 obj-$(CONFIG_SAMPLE_CONNECTOR)		+= connector/
 subdir-$(CONFIG_SAMPLE_HIDRAW)		+= hidraw
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: samples/bpf not working?
  2019-10-05 19:20 ` Eric Sage
@ 2019-10-06  6:49   ` Andrii Nakryiko
  0 siblings, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2019-10-06  6:49 UTC (permalink / raw)
  To: Eric Sage
  Cc: Networking, bpf, Daniel Borkmann, xdp-newbies,
	Alexei Starovoitov, Björn Töpel

On Sat, Oct 5, 2019 at 12:24 PM Eric Sage <eric@sage.org> wrote:
>
> 394053f4a4b3 ("kbuild: make single targets work more correctly")
> changed the way single target builds work. For example,
> 'make samples/bpf/' in the previous commit matched:
>
> Makefile:1787
> %/: prepare FORCE
>   $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) need-modorder=1
>
> So that 'samples/bpf/Makefile' was processed directly.
> Commit 394053f4a4b3 removed this rule and now requires that
> 'CONFIG_SAMPLES=y' and that 'bpf/' be added to 'samples/Makefile'
> so it is added to the list of targets processed by the new
> 'ifdef single-build' section of 'scripts/Makefile.build'.
>
> This commit adds a new 'CONFIG_SAMPLE_BPF' under 'CONFIG_SAMPLES' to
> match what the other sample subdirs have done.
>
> Signed-off-by: Eric Sage <eric@sage.org>
> ---

See [0], Björn already attempted this.

  [0] https://lore.kernel.org/bpf/20191001101429.24965-1-bjorn.topel@gmail.com/

>  samples/Kconfig  | 6 ++++++
>  samples/Makefile | 1 +
>  2 files changed, 7 insertions(+)
>
> diff --git a/samples/Kconfig b/samples/Kconfig
> index c8dacb4dda80..396e87ba97e0 100644
> --- a/samples/Kconfig
> +++ b/samples/Kconfig
> @@ -6,6 +6,12 @@ menuconfig SAMPLES
>
>  if SAMPLES
>
> +config SAMPLE_BPF
> +       tristate "Build bpf examples"
> +       depends on EVENT_TRACING && m
> +       help
> +         This builds the bpf example modules.
> +
>  config SAMPLE_TRACE_EVENTS
>         tristate "Build trace_events examples -- loadable modules only"
>         depends on EVENT_TRACING && m
> diff --git a/samples/Makefile b/samples/Makefile
> index 7d6e4ca28d69..e133a78f3fb8 100644
> --- a/samples/Makefile
> +++ b/samples/Makefile
> @@ -2,6 +2,7 @@
>  # Makefile for Linux samples code
>
>  obj-$(CONFIG_SAMPLE_ANDROID_BINDERFS)  += binderfs/
> +obj-$(CONFIG_SAMPLE_BPF) += bpf/
>  obj-$(CONFIG_SAMPLE_CONFIGFS)          += configfs/
>  obj-$(CONFIG_SAMPLE_CONNECTOR)         += connector/
>  subdir-$(CONFIG_SAMPLE_HIDRAW)         += hidraw
> --
> 2.18.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-06  6:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 22:21 samples/bpf not working? Daniel T. Lee
2019-10-05 18:27 ` Andrii Nakryiko
2019-10-05 19:20 ` Eric Sage
2019-10-06  6:49   ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).