Skip to contentSkip to conversation

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

PATCH In review Daan De Meyer 2 participants 4 messages Nov 11, 2024 – Nov 12, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bpftool: Set srctree correctly when not building out of source tree

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(+)
tools/bpf/bpftool/Makefile +6 -0
index ba927379eb20..7c7d731077c9 100644
@@ -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)))
Signature · 1 line
2.47.0
#1 lore raw

2024-11-11 15:02 UTC+0100 ~ Daan De Meyer <[email protected]>

Quoted 5 lines

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:

Quoted 8 lines

"""
+ 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.

Quoted 21 lines
---
 tools/bpf/bpftool/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)
tools/bpf/bpftool/Makefile +6 -0
index ba927379eb20..7c7d731077c9 100644
@@ -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)))
#2 lore raw
Quoted 5 lines

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

Quoted 8 lines

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

Quoted 57 lines · Quentin Monnet

2024-11-11 15:02 UTC+0100 ~ Daan De Meyer <[email protected]>

Quoted 5 lines

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:

Quoted 8 lines

"""
+ 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.

Quoted 21 lines
---
 tools/bpf/bpftool/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)
tools/bpf/bpftool/Makefile +6 -0
index ba927379eb20..7c7d731077c9 100644
@@ -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)))
#3 lore raw

2024-11-12 12:02 UTC+0100 ~ Daan De Meyer <[email protected]>

Quoted 14 lines
Quoted 5 lines

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

Quoted 8 lines

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?

Quoted 4 lines

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