diff mbox series

[bpf-next,1/3] samples/bpf: Fix building out of srctree

Message ID 20200728120059.132256-2-iii@linux.ibm.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series samples/bpf: A couple s390 fixes | expand

Commit Message

Ilya Leoshkevich July 28, 2020, noon UTC
Building BPF samples out of srctree fails, because the output directory
for progs shared with selftests (CGROUP_HELPERS, TRACE_HELPERS) is
missing and the compiler cannot create output files.

Fix by creating the output directory in Makefile.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 samples/bpf/Makefile | 1 +
 1 file changed, 1 insertion(+)

Comments

Song Liu July 28, 2020, 8:48 p.m. UTC | #1
On Tue, Jul 28, 2020 at 5:15 AM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> Building BPF samples out of srctree fails, because the output directory
> for progs shared with selftests (CGROUP_HELPERS, TRACE_HELPERS) is
> missing and the compiler cannot create output files.
>
> Fix by creating the output directory in Makefile.

What is the make command line we use here? I am trying:

   make M=samples/bpf O=./xxx

w/o this patch, make created ./xxx/samples/bpf.

Did I miss something?

Thanks,
Song
Ilya Leoshkevich July 28, 2020, 9:12 p.m. UTC | #2
On Tue, 2020-07-28 at 13:48 -0700, Song Liu wrote:
> On Tue, Jul 28, 2020 at 5:15 AM Ilya Leoshkevich <iii@linux.ibm.com>
> wrote:
> > Building BPF samples out of srctree fails, because the output
> > directory
> > for progs shared with selftests (CGROUP_HELPERS, TRACE_HELPERS) is
> > missing and the compiler cannot create output files.
> > 
> > Fix by creating the output directory in Makefile.
> 
> What is the make command line we use here? I am trying:
> 
>    make M=samples/bpf O=./xxx
> 
> w/o this patch, make created ./xxx/samples/bpf.
> 
> Did I miss something?

I'm using

make O=$HOME/linux-build 'CC=ccache gcc' M=samples/bpf -j12

My make version is GNU Make 4.2.1.

Best regards,
Ilya
Ilya Leoshkevich July 28, 2020, 9:37 p.m. UTC | #3
On Tue, 2020-07-28 at 23:12 +0200, Ilya Leoshkevich wrote:
> On Tue, 2020-07-28 at 13:48 -0700, Song Liu wrote:
> > On Tue, Jul 28, 2020 at 5:15 AM Ilya Leoshkevich <iii@linux.ibm.com
> > >
> > wrote:
> > > Building BPF samples out of srctree fails, because the output
> > > directory
> > > for progs shared with selftests (CGROUP_HELPERS, TRACE_HELPERS)
> > > is
> > > missing and the compiler cannot create output files.
> > > 
> > > Fix by creating the output directory in Makefile.
> > 
> > What is the make command line we use here? I am trying:
> > 
> >    make M=samples/bpf O=./xxx
> > 
> > w/o this patch, make created ./xxx/samples/bpf.
> > 
> > Did I miss something?
> 
> I'm using
> 
> make O=$HOME/linux-build 'CC=ccache gcc' M=samples/bpf -j12
> 
> My make version is GNU Make 4.2.1.

Hmm, I wanted to elaborate a little bit more on why this fix should
work, and realized that it works only by accident: cgroup_helpers
and trace_helpers are userspace code, and my fix modifies the recipe
for building bpf programs.

Please disregard this patch - I will have to come up with a better fix.
diff mbox series

Patch

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index f87ee02073ba..81ba0beca0a3 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -301,6 +301,7 @@  $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
 # But, there is no easy way to fix it, so just exclude it since it is
 # useless for BPF samples.
 $(obj)/%.o: $(src)/%.c
+	$(Q)mkdir -p $(@D)
 	@echo "  CLANG-bpf " $@
 	$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \
 		-I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \