Skip to contentSkip to conversation

samples/bpf/Makefile: Create tools/testing/selftests/bpf dir

PATCH In review Hui Zhu 2 participants 2 messages Dec 14, 2020 – Dec 15, 2020

Subsystems (3)
lore
Share & tools
lore

Hui Zhu

author
#0 lore raw

PATCH 1/1 samples/bpf/Makefile: Create tools/testing/selftests/bpf dir

From: Hui Zhu <[email protected]>

Got an error when I built samples/bpf in a separate directory:
make O=../bk/ defconfig
make -j64 bzImage
make headers_install
make V=1 M=samples/bpf
...
...
make -C /home/teawater/kernel/linux/samples/bpf/../..//tools/build
CFLAGS= LDFLAGS= fixdep
make -f
/home/teawater/kernel/linux/samples/bpf/../..//tools/build/Makefile.build
dir=. obj=fixdep
make all_cmd
Warning: Kernel ABI header at 'tools/include/uapi/linux/netlink.h'
differs from latest version at 'include/uapi/linux/netlink.h'
Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h'
differs from latest version at 'include/uapi/linux/if_link.h'
gcc
-Wp,-MD,samples/bpf/../../tools/testing/selftests/bpf/.cgroup_helpers.o.d
-Wall -O2 -Wmissing-prototypes -Wstrict-prototypes -I./usr/include -I/home/teawater/kernel/linux/tools/testing/selftests/bpf/ -I/home/teawater/kernel/linux/tools/lib/ -I/home/teawater/kernel/linux/tools/include -I/home/teawater/kernel/linux/tools/perf -DHAVE_ATTR_TEST=0 -c -o samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.o /home/teawater/kernel/linux/samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c /home/teawater/kernel/linux/samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:315:1:
fatal error: opening dependency file samples/bpf/../../tools/testing/selftests/bpf/.cgroup_helpers.o.d: No
such file or directory

ls -al samples/bpf/../../tools/testing/selftests/bpf/
ls: cannot access 'samples/bpf/../../tools/testing/selftests/bpf/': No such file or directory

There is no samples/bpf/../../tools/testing/selftests/bpf/ causing a compilation error.

This commit add a "make -p" before build files in samples/bpf/../../tools/testing/selftests/bpf/ to handle the issue.

---
 samples/bpf/Makefile | 1 +
 1 file changed, 1 insertion(+)
samples/bpf/Makefile +1 -0
index aeebf5d12f32..5b940eedf2e8 100644
@@ -262,6 +262,7 @@ clean:
 
 $(LIBBPF): FORCE
 # Fix up variables inherited from Kbuild that tools/ build system won't like
+	mkdir -p $(obj)/../../tools/testing/selftests/bpf/
 	$(MAKE) -C $(dir $@) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \
 		LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ O=
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 54 lines · Hui Zhu

From: Hui Zhu <[email protected]>

Got an error when I built samples/bpf in a separate directory:
make O=../bk/ defconfig
make -j64 bzImage
make headers_install
make V=1 M=samples/bpf
...
...
make -C /home/teawater/kernel/linux/samples/bpf/../..//tools/build CFLAGS= LDFLAGS= fixdep
make -f /home/teawater/kernel/linux/samples/bpf/../..//tools/build/Makefile.build dir=. obj=fixdep
make all_cmd
Warning: Kernel ABI header at 'tools/include/uapi/linux/netlink.h' differs from latest version at 'include/uapi/linux/netlink.h'
Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h'
gcc

(quoted diff) +0 -6
-Wp,-MD,samples/bpf/../../tools/testing/selftests/bpf/.cgroup_helpers.o.d
-Wall -O2 -Wmissing-prototypes -Wstrict-prototypes -I./usr/include
-I/home/teawater/kernel/linux/tools/testing/selftests/bpf/
-I/home/teawater/kernel/linux/tools/lib/
-I/home/teawater/kernel/linux/tools/include
-I/home/teawater/kernel/linux/tools/perf -DHAVE_ATTR_TEST=0  -c -o

samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.o /home/teawater/kernel/linux/samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c /home/teawater/kernel/linux/samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:315:1:
fatal error: opening dependency file samples/bpf/../../tools/testing/selftests/bpf/.cgroup_helpers.o.d: No
such file or directory

ls -al samples/bpf/../../tools/testing/selftests/bpf/
ls: cannot access 'samples/bpf/../../tools/testing/selftests/bpf/': No such file or directory

There is no samples/bpf/../../tools/testing/selftests/bpf/ causing a compilation error.

This commit add a "make -p" before build files in samples/bpf/../../tools/testing/selftests/bpf/ to handle the issue.

---
 samples/bpf/Makefile | 1 +
 1 file changed, 1 insertion(+)
samples/bpf/Makefile +0 -0
index aeebf5d12f32..5b940eedf2e8 100644

samples/bpf/Makefile clean: · line 265

Quoted 4 lines
samples/bpf/Makefile +1 -0
@@ -262,6 +262,7 @@ clean:
 
 $(LIBBPF): FORCE
 # Fix up variables inherited from Kbuild that tools/ build system won't like
+       mkdir -p $(obj)/../../tools/testing/selftests/bpf/

This is not a real fix, rather ad-hoc work-around. Let's try to understand why this path is necessary and do adjustments to either samples' or libbpf's Makefile to work in such cases.

Quoted 6 lines
samples/bpf/Makefile +0 -1
        $(MAKE) -C $(dir $@) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \
                LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ O=
 
--

2.17.1