diff mbox series

[v2] bpftool: Set srctree correctly when not building out of source tree

Message ID 20241111140305.832808-1-daan.j.demeyer@gmail.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [v2] bpftool: Set srctree correctly when not building out of source tree | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-18 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17-O2
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-17 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-38 success Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-31 success Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-40 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18-O2
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-39 success Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc

Commit Message

Daan De Meyer Nov. 11, 2024, 2:02 p.m. UTC
This allows building bpftool directly via "make -C tools/bpf/bpftool".

Without this change, building bpftool via "make -C tools/bpf/bpftool"
fails with the following error:

"""
+ make ARCH=x86 -C tools/bpf/bpftool bootstrap
Makefile:127: tools/build/Makefile.feature: No such file or directory
make[3]: *** No rule to make target 'tools/build/Makefile.feature'.  Stop.
error: Bad exit status from /var/tmp/rpm-tmp.3p0IcJ (%build)
"""

This is the same workaround that is also applied in tools/bpf/Makefile.
---
 tools/bpf/bpftool/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Quentin Monnet Nov. 11, 2024, 3:39 p.m. UTC | #1
2024-11-11 15:02 UTC+0100 ~ Daan De Meyer <daan.j.demeyer@gmail.com>
> This allows building bpftool directly via "make -C tools/bpf/bpftool".
> 
> Without this change, building bpftool via "make -C tools/bpf/bpftool"
> fails with the following error:
> 
> """
> + make ARCH=x86 -C tools/bpf/bpftool bootstrap
> Makefile:127: tools/build/Makefile.feature: No such file or directory
> make[3]: *** No rule to make target 'tools/build/Makefile.feature'.  Stop.
> error: Bad exit status from /var/tmp/rpm-tmp.3p0IcJ (%build)
> """
> 
> This is the same workaround that is also applied in tools/bpf/Makefile.


My understanding of the check on building_out_of_srctree in
tools/bpf/Makefile (from commit 55d554f5d140's description) is that it
fixes the build from "make TARGETS=bpf kselftest", not from "make -C
tools/bpf".

Trying again "make ARCH=x86 -C tools/bpf/bpftool bootstrap" at the root
of the Linux repo, not building out-of-tree, this works fine for me,
without the need for your patch. I'm trying to understand what your
setup is and what creates the failure that you observe (and that I can't
reproduce), so I'd like more context if possible. Are you just running
that command from the root of the tree? If that's the case, what values
do you observe for $(srctree) and $(building_out_of_srctree) when
entering bpftool's Makefile?

Your v2 also still misses your sign-off, and please remember as well to
add all relevant maintainers in copy of your email.


> ---
>  tools/bpf/bpftool/Makefile | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index ba927379eb20..7c7d731077c9 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -2,6 +2,12 @@
>  include ../../scripts/Makefile.include
>  
>  ifeq ($(srctree),)
> +update_srctree := 1
> +endif
> +ifndef building_out_of_srctree
> +update_srctree := 1
> +endif
> +ifeq ($(update_srctree),1)
>  srctree := $(patsubst %/,%,$(dir $(CURDIR)))
>  srctree := $(patsubst %/,%,$(dir $(srctree)))
>  srctree := $(patsubst %/,%,$(dir $(srctree)))
Daan De Meyer Nov. 12, 2024, 11:02 a.m. UTC | #2
> My understanding of the check on building_out_of_srctree in
> tools/bpf/Makefile (from commit 55d554f5d140's description) is that it
> fixes the build from "make TARGETS=bpf kselftest", not from "make -C
> tools/bpf".

> Trying again "make ARCH=x86 -C tools/bpf/bpftool bootstrap" at the root
> of the Linux repo, not building out-of-tree, this works fine for me,
> without the need for your patch. I'm trying to understand what you
> setup is and what creates the failure that you observe (and that I can't
> reproduce), so I'd like more context if possible. Are you just running
> that command from the root of the tree? If that's the case, what values
> do you observe for $(srctree) and $(building_out_of_srctree) when
> entering bpftool's Makefile?

I do the same thing and I get this error, srctree is set to ".". I have no clue
what's different about my environment that would cause this error. This is
a Fedora Rawhide image and I'm using the master branch from Linus's repo
(https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git)

Cheers,

Daan

On Mon, 11 Nov 2024 at 16:39, Quentin Monnet <qmo@qmon.net> wrote:
>
> 2024-11-11 15:02 UTC+0100 ~ Daan De Meyer <daan.j.demeyer@gmail.com>
> > This allows building bpftool directly via "make -C tools/bpf/bpftool".
> >
> > Without this change, building bpftool via "make -C tools/bpf/bpftool"
> > fails with the following error:
> >
> > """
> > + make ARCH=x86 -C tools/bpf/bpftool bootstrap
> > Makefile:127: tools/build/Makefile.feature: No such file or directory
> > make[3]: *** No rule to make target 'tools/build/Makefile.feature'.  Stop.
> > error: Bad exit status from /var/tmp/rpm-tmp.3p0IcJ (%build)
> > """
> >
> > This is the same workaround that is also applied in tools/bpf/Makefile.
>
>
> My understanding of the check on building_out_of_srctree in
> tools/bpf/Makefile (from commit 55d554f5d140's description) is that it
> fixes the build from "make TARGETS=bpf kselftest", not from "make -C
> tools/bpf".
>
> Trying again "make ARCH=x86 -C tools/bpf/bpftool bootstrap" at the root
> of the Linux repo, not building out-of-tree, this works fine for me,
> without the need for your patch. I'm trying to understand what your
> setup is and what creates the failure that you observe (and that I can't
> reproduce), so I'd like more context if possible. Are you just running
> that command from the root of the tree? If that's the case, what values
> do you observe for $(srctree) and $(building_out_of_srctree) when
> entering bpftool's Makefile?
>
> Your v2 also still misses your sign-off, and please remember as well to
> add all relevant maintainers in copy of your email.
>
>
> > ---
> >  tools/bpf/bpftool/Makefile | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> > index ba927379eb20..7c7d731077c9 100644
> > --- a/tools/bpf/bpftool/Makefile
> > +++ b/tools/bpf/bpftool/Makefile
> > @@ -2,6 +2,12 @@
> >  include ../../scripts/Makefile.include
> >
> >  ifeq ($(srctree),)
> > +update_srctree := 1
> > +endif
> > +ifndef building_out_of_srctree
> > +update_srctree := 1
> > +endif
> > +ifeq ($(update_srctree),1)
> >  srctree := $(patsubst %/,%,$(dir $(CURDIR)))
> >  srctree := $(patsubst %/,%,$(dir $(srctree)))
> >  srctree := $(patsubst %/,%,$(dir $(srctree)))
>
Quentin Monnet Nov. 12, 2024, 5:02 p.m. UTC | #3
2024-11-12 12:02 UTC+0100 ~ Daan De Meyer <daan.j.demeyer@gmail.com>
>> My understanding of the check on building_out_of_srctree in
>> tools/bpf/Makefile (from commit 55d554f5d140's description) is that it
>> fixes the build from "make TARGETS=bpf kselftest", not from "make -C
>> tools/bpf".
> 
>> Trying again "make ARCH=x86 -C tools/bpf/bpftool bootstrap" at the root
>> of the Linux repo, not building out-of-tree, this works fine for me,
>> without the need for your patch. I'm trying to understand what you
>> setup is and what creates the failure that you observe (and that I can't
>> reproduce), so I'd like more context if possible. Are you just running
>> that command from the root of the tree? If that's the case, what values
>> do you observe for $(srctree) and $(building_out_of_srctree) when
>> entering bpftool's Makefile?
> 
> I do the same thing and I get this error, srctree is set to ".". I have no clue
> what's different about my environment that would cause this error. This is
> a Fedora Rawhide image and I'm using the master branch from Linus's repo
> (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git)


Hi Daan,

I'm sorry I still don't manage to reproduce. I installed a VM with a
Rawhide image (Fedora-Workstation-Live-x86_64-Rawhide-20241112.n.0.iso),
I installed packages elfutils-libelf-devel, gcc, and make in it, I
cloned Linus' repo, and ran the same command as you did (make ARCH=x86
-C tools/bpf/bpftool bootstrap), and this works well for me.

	test@localhost-live:~/linux$ lsb_release -a
	LSB Version:	n/a
	Distributor ID:	Fedora
	Description:	Fedora Linux 42 (Workstation Edition Prerelease)
	Release:	42
	Codename:	n/a
	test@localhost-live:~/linux$ uname -r
	6.12.0-0.rc7.58.fc42.x86_64

$(srctree) appears to be empty in my case. Have you tried tracing it
(and $(building_out_of_srctree)) with -p to see where it's set in your case?

Quentin
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index ba927379eb20..7c7d731077c9 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -2,6 +2,12 @@ 
 include ../../scripts/Makefile.include
 
 ifeq ($(srctree),)
+update_srctree := 1
+endif
+ifndef building_out_of_srctree
+update_srctree := 1
+endif
+ifeq ($(update_srctree),1)
 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
 srctree := $(patsubst %/,%,$(dir $(srctree)))
 srctree := $(patsubst %/,%,$(dir $(srctree)))