Skip to contentSkip to conversation

tools: bpf: Use !building_out_of_srctree to determine srctree

PATCH Applied Shuah Khan 4 participants 7 messages Sep 27, 2019 – Sep 30, 2019

Subsystems (5)
lore
Share & tools
lore

Shuah Khan

author maintainer
#0 lore raw

PATCH 1/1 tools: bpf: Use !building_out_of_srctree to determine srctree

make TARGETS=bpf kselftest fails with:

Makefile:127: tools/build/Makefile.include: No such file or directory

When the bpf tool make is invoked from tools Makefile, srctree is cleared and the current logic check for srctree equals to empty string to determine srctree location from CURDIR.

When the build in invoked from selftests/bpf Makefile, the srctree is set to "." and the same logic used for srctree equals to empty is needed to determine srctree.

Check building_out_of_srctree undefined as the condition for both cases to fix "make TARGETS=bpf kselftest" build failure.

---
 tools/bpf/Makefile     | 6 +++++-
 tools/lib/bpf/Makefile | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
tools/bpf/Makefile +5 -1
index fbf5e4a0cb9c..5d1995fd369c 100644
@@ -12,7 +12,11 @@ INSTALL ?= install
 CFLAGS += -Wall -O2
 CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
 
-ifeq ($(srctree),)
+# This will work when bpf is built in tools env. where srctree
+# isn't set and when invoked from selftests build, where srctree
+# is set to ".". building_out_of_srctree is undefined for in srctree
+# builds
+ifndef building_out_of_srctree
 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
 srctree := $(patsubst %/,%,$(dir $(srctree)))
 endif
tools/lib/bpf/Makefile +5 -1
index c6f94cffe06e..20772663d3e1 100644
@@ -8,7 +8,11 @@ LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION)))
 
 MAKEFLAGS += --no-print-directory
 
-ifeq ($(srctree),)
+# This will work when bpf is built in tools env. where srctree
+# isn't set and when invoked from selftests build, where srctree
+# is a ".". building_out_of_srctree is undefined for in srctree
+# builds
+ifndef building_out_of_srctree
 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
 srctree := $(patsubst %/,%,$(dir $(srctree)))
 srctree := $(patsubst %/,%,$(dir $(srctree)))
Signature · 1 line
2.20.1
#1 lore raw
Quoted 9 lines · Shuah Khan

make TARGETS=bpf kselftest fails with:

Makefile:127: tools/build/Makefile.include: No such file or directory

When the bpf tool make is invoked from tools Makefile, srctree is cleared and the current logic check for srctree equals to empty string to determine srctree location from CURDIR.

Quoted 8 lines

When the build in invoked from selftests/bpf Makefile, the srctree is set to "." and the same logic used for srctree equals to empty is needed to determine srctree.

Check building_out_of_srctree undefined as the condition for both cases to fix "make TARGETS=bpf kselftest" build failure.

The fix looks reasonable. Thanks!

However, I am still seeing some failure:

make TARGETS=bpf kselftest
[...]
test_verifier.c /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/test_stub.o /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/test_verifier make[3]: test_verifier.c: Command not found

Is this just a problem with my setup?

Thanks,
Song

author maintainer
#2 lore raw
Quoted 32 lines · Song Liu
Quoted 9 lines · Shuah Khan

make TARGETS=bpf kselftest fails with:

Makefile:127: tools/build/Makefile.include: No such file or directory

When the bpf tool make is invoked from tools Makefile, srctree is cleared and the current logic check for srctree equals to empty string to determine srctree location from CURDIR.

Quoted 8 lines

When the build in invoked from selftests/bpf Makefile, the srctree is set to "." and the same logic used for srctree equals to empty is needed to determine srctree.

Check building_out_of_srctree undefined as the condition for both cases to fix "make TARGETS=bpf kselftest" build failure.

The fix looks reasonable. Thanks!

However, I am still seeing some failure:

make TARGETS=bpf kselftest
[...]
test_verifier.c /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/test_stub.o /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/test_verifier make[3]: test_verifier.c: Command not found

Quoted 2 lines

Is this just a problem with my setup?

You are running into the second bpf failure because of the dependency on the latest llvm. This is known issue with bpf test and it doesn't compile on 5.4 and maybe even 5.3

You have upgrade to the bleeding edge llvm.

thanks,
-- Shuah

Acked-by
#3 lore raw
Quoted 35 lines · Shuah Khan
Quoted 18 lines · Song Liu
Quoted 9 lines · Shuah Khan

make TARGETS=bpf kselftest fails with:

Makefile:127: tools/build/Makefile.include: No such file or directory

When the bpf tool make is invoked from tools Makefile, srctree is cleared and the current logic check for srctree equals to empty string to determine srctree location from CURDIR.

Quoted 8 lines

When the build in invoked from selftests/bpf Makefile, the srctree is set to "." and the same logic used for srctree equals to empty is needed to determine srctree.

Check building_out_of_srctree undefined as the condition for both cases to fix "make TARGETS=bpf kselftest" build failure.

Quoted 11 lines

The fix looks reasonable. Thanks!
However, I am still seeing some failure:
make TARGETS=bpf kselftest
[...]
test_verifier.c /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/test_stub.o /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/libbpf.a -lcap -lelf -lrt -lpthread -o /data/users/songliubraving/kernel/linux-git/tools/testing/selftests/bpf/test_verifier make[3]: test_verifier.c: Command not found
Is this just a problem with my setup?

Quoted 4 lines

You are running into the second bpf failure because of the dependency on the latest llvm. This is known issue with bpf test and it doesn't compile on 5.4 and maybe even 5.3

Thanks for the clarification.

maintainer Applied
#4 lore raw
In reply to Shuah Khan
Quoted 8 lines · Shuah Khan

make TARGETS=bpf kselftest fails with:

Makefile:127: tools/build/Makefile.include: No such file or directory

When the bpf tool make is invoked from tools Makefile, srctree is cleared and the current logic check for srctree equals to empty string to determine srctree location from CURDIR.

Quoted 8 lines

When the build in invoked from selftests/bpf Makefile, the srctree is set to "." and the same logic used for srctree equals to empty is needed to determine srctree.

Check building_out_of_srctree undefined as the condition for both cases to fix "make TARGETS=bpf kselftest" build failure.

Applied, thanks!

author maintainer
#5 lore raw
Quoted 13 lines · Daniel Borkmann
Quoted 12 lines · Shuah Khan

make TARGETS=bpf kselftest fails with:

Makefile:127: tools/build/Makefile.include: No such file or directory

When the bpf tool make is invoked from tools Makefile, srctree is cleared and the current logic check for srctree equals to empty string to determine srctree location from CURDIR.

When the build in invoked from selftests/bpf Makefile, the srctree is set to "." and the same logic used for srctree equals to empty is needed to determine srctree.

Quoted 7 lines
Quoted 4 lines

Check building_out_of_srctree undefined as the condition for both cases to fix "make TARGETS=bpf kselftest" build failure.

Applied, thanks!

Hi Daniel!

Is the tree the patch went into included in the linux-next?

thanks,
-- Shuah

maintainer
#6 lore raw
Quoted 17 lines · Shuah Khan
Quoted 16 lines · Daniel Borkmann
Quoted 15 lines · Shuah Khan

make TARGETS=bpf kselftest fails with:

Makefile:127: tools/build/Makefile.include: No such file or directory

When the bpf tool make is invoked from tools Makefile, srctree is cleared and the current logic check for srctree equals to empty string to determine srctree location from CURDIR.

When the build in invoked from selftests/bpf Makefile, the srctree is set to "." and the same logic used for srctree equals to empty is needed to determine srctree.

Check building_out_of_srctree undefined as the condition for both cases to fix "make TARGETS=bpf kselftest" build failure.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Applied, thanks!

Hi Daniel!

Is the tree the patch went into included in the linux-next?

Yes, both bpf and bpf-next are included in linux-next.

Thanks,
Daniel