Skip to contentSkip to conversation

selftests: bpf: fix urandom_read build issue

PATCH Superseded Anders Roxell 3 participants 9 messages Jun 7, 2018 – Jun 11, 2018

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

PATCH 1/1 selftests: bpf: fix urandom_read build issue

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed
To fix this issue remove the urandom_read target and so target TEST_CUSTOM_PROGS gets used.

Fixes 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/bpf/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/Makefile +2 -4
index 607ed8729c06..67285591ffd7 100644
@@ -16,10 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread
 TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
 all: $(TEST_CUSTOM_PROGS)
 
-$(TEST_CUSTOM_PROGS): urandom_read
-
-urandom_read: urandom_read.c
-	$(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id
+$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c
+	$(CC) -o $@ -static $< -Wl,--build-id
 
 # Order correspond to 'make run_tests' order
 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
Signature · 6 lines
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 14 lines · Anders Roxell

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed

What is the build/make command to reproduce the above failure?

Quoted 27 lines

To fix this issue remove the urandom_read target and so target TEST_CUSTOM_PROGS gets used.

Fixes 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/bpf/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/Makefile +2 -5
index 607ed8729c06..67285591ffd7 100644
@@ -16,10 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread
 TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
 all: $(TEST_CUSTOM_PROGS)
 
-$(TEST_CUSTOM_PROGS): urandom_read
-
-urandom_read: urandom_read.c
-       $(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id
+$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c
+       $(CC) -o $@ -static $< -Wl,--build-id
 
 # Order correspond to 'make run_tests' order
 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
--
Quoted 2 lines

2.17.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 17 lines · Y Song
Quoted 14 lines · Anders Roxell

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed

What is the build/make command to reproduce the above failure?

make -C tools/testing/selftests

Cheers,
Anders

Quoted 25 lines
Quoted 25 lines

To fix this issue remove the urandom_read target and so target TEST_CUSTOM_PROGS gets used.

Fixes 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/bpf/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/Makefile +2 -4
index 607ed8729c06..67285591ffd7 100644
@@ -16,10 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread
 TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
 all: $(TEST_CUSTOM_PROGS)
 
-$(TEST_CUSTOM_PROGS): urandom_read
-
-urandom_read: urandom_read.c
-       $(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id
+$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c
+       $(CC) -o $@ -static $< -Wl,--build-id
 
Quoted 5 lines
Quoted 5 lines
tools/testing/selftests/bpf/Makefile +0 -1
 # Order correspond to 'make run_tests' order
 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
--

2.17.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 19 lines · Anders Roxell
Quoted 17 lines · Y Song
Quoted 14 lines · Anders Roxell

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed

What is the build/make command to reproduce the above failure?

Quoted 1 line

make -C tools/testing/selftests

Thanks. The patch will break
make -C tools/testing/selftests/bpf

[yhs at localhost bpf-next]$ make -C tools/testing/selftests/bpf
make: Entering directory '/home/yhs/work/bpf-next/tools/testing/selftests/bpf' gcc -o /urandom_read -static urandom_read.c -Wl,--build-id /usr/bin/ld: cannot open output file /urandom_read: Permission denied
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: /urandom_read] Error 1
make: Leaving directory '/home/yhs/work/bpf-next/tools/testing/selftests/bpf' [yhs at localhost bpf-next]$

Could you still make the above command work?

Quoted 29 lines

Cheers,
Anders

Quoted 25 lines
Quoted 25 lines

To fix this issue remove the urandom_read target and so target TEST_CUSTOM_PROGS gets used.

Fixes 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/bpf/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/Makefile +2 -4
index 607ed8729c06..67285591ffd7 100644
@@ -16,10 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread
 TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
 all: $(TEST_CUSTOM_PROGS)
 
-$(TEST_CUSTOM_PROGS): urandom_read
-
-urandom_read: urandom_read.c
-       $(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id
+$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c
+       $(CC) -o $@ -static $< -Wl,--build-id
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
tools/testing/selftests/bpf/Makefile +0 -1
 # Order correspond to 'make run_tests' order
 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
--

2.17.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 25 lines · Y Song
Quoted 19 lines · Anders Roxell
Quoted 17 lines · Y Song
Quoted 14 lines · Anders Roxell

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed

What is the build/make command to reproduce the above failure?

Quoted 1 line

make -C tools/testing/selftests

Thanks. The patch will break
make -C tools/testing/selftests/bpf

Quoted 8 lines

[yhs at localhost bpf-next]$ make -C tools/testing/selftests/bpf
make: Entering directory '/home/yhs/work/bpf-next/tools/testing/selftests/bpf' gcc -o /urandom_read -static urandom_read.c -Wl,--build-id /usr/bin/ld: cannot open output file /urandom_read: Permission denied
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: /urandom_read] Error 1
make: Leaving directory '/home/yhs/work/bpf-next/tools/testing/selftests/bpf' [yhs at localhost bpf-next]$

urgh, I'm sorry, missed that.

Quoted 2 lines

Could you still make the above command work?

$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c

        $(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id

That worked both with:
make -C tools/testing/selftests
and
make -C tools/testing/selftests/bpf

for me.

what do you think?

Quoted 30 lines
Quoted 30 lines

Cheers,
Anders

Quoted 25 lines
Quoted 25 lines

To fix this issue remove the urandom_read target and so target TEST_CUSTOM_PROGS gets used.

Fixes 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/bpf/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/Makefile +2 -4
index 607ed8729c06..67285591ffd7 100644
@@ -16,10 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread
 TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
 all: $(TEST_CUSTOM_PROGS)
 
-$(TEST_CUSTOM_PROGS): urandom_read
-
-urandom_read: urandom_read.c
-       $(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id
+$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c
+       $(CC) -o $@ -static $< -Wl,--build-id
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
tools/testing/selftests/bpf/Makefile +0 -1
 # Order correspond to 'make run_tests' order
 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
--

2.17.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by Yonghong Song
#5 lore raw
Quoted 43 lines · Anders Roxell
Quoted 25 lines · Y Song
Quoted 19 lines · Anders Roxell
Quoted 17 lines · Y Song
Quoted 14 lines · Anders Roxell

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed

What is the build/make command to reproduce the above failure?

Quoted 1 line

make -C tools/testing/selftests

Thanks. The patch will break
make -C tools/testing/selftests/bpf

Quoted 8 lines

[yhs at localhost bpf-next]$ make -C tools/testing/selftests/bpf
make: Entering directory '/home/yhs/work/bpf-next/tools/testing/selftests/bpf' gcc -o /urandom_read -static urandom_read.c -Wl,--build-id /usr/bin/ld: cannot open output file /urandom_read: Permission denied
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: /urandom_read] Error 1
make: Leaving directory '/home/yhs/work/bpf-next/tools/testing/selftests/bpf' [yhs at localhost bpf-next]$

urgh, I'm sorry, missed that.

Quoted 2 lines

Could you still make the above command work?

$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c

        $(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id
Quoted 8 lines

That worked both with:
make -C tools/testing/selftests
and
make -C tools/testing/selftests/bpf

for me.

what do you think?

This indeed works. You can submit a revised patch and add my Ack.
Acked-by: Yonghong Song <yhs at fb.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 49 lines · Y Song
Quoted 48 lines · Anders Roxell
Quoted 25 lines · Y Song
Quoted 19 lines · Anders Roxell
Quoted 17 lines · Y Song
Quoted 14 lines · Anders Roxell

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed

What is the build/make command to reproduce the above failure?

Quoted 1 line

make -C tools/testing/selftests

Thanks. The patch will break
make -C tools/testing/selftests/bpf

Quoted 8 lines

[yhs at localhost bpf-next]$ make -C tools/testing/selftests/bpf
make: Entering directory '/home/yhs/work/bpf-next/tools/testing/selftests/bpf' gcc -o /urandom_read -static urandom_read.c -Wl,--build-id /usr/bin/ld: cannot open output file /urandom_read: Permission denied
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: /urandom_read] Error 1
make: Leaving directory '/home/yhs/work/bpf-next/tools/testing/selftests/bpf' [yhs at localhost bpf-next]$

urgh, I'm sorry, missed that.

Quoted 2 lines

Could you still make the above command work?

$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c

        $(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id

That worked both with:
make -C tools/testing/selftests
and
make -C tools/testing/selftests/bpf

Quoted 6 lines
Quoted 3 lines

for me.

what do you think?

This indeed works. You can submit a revised patch and add my Ack.
Acked-by: Yonghong Song <yhs at fb.com>

Thank you for your time reviewing this.
I will send that out shortly.

Cheers,
Anders
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

PATCH v2 1/1 selftests: bpf: fix urandom_read build issue

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed
To fix this issue remove the urandom_read target and so target TEST_CUSTOM_PROGS gets used.

Fixes 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
Acked-by Yonghong Song <yhs at fb.com>
---
 tools/testing/selftests/bpf/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/testing/selftests/bpf/Makefile +1 -3
index 607ed8729c06..7a6214e9ae58 100644
@@ -16,9 +16,7 @@ LDLIBS += -lcap -lelf -lrt -lpthread
 TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
 all: $(TEST_CUSTOM_PROGS)
 
-$(TEST_CUSTOM_PROGS): urandom_read
-
-urandom_read: urandom_read.c
+$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c
 	$(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id
 
 # Order correspond to 'make run_tests' order
Signature · 6 lines
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#8 lore raw
Quoted 17 lines · Anders Roxell

gcc complains that urandom_read gets built twice.

gcc -o tools/testing/selftests/bpf/urandom_read
-static urandom_read.c -Wl,--build-id
gcc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../lib/bpf
-I../../../../include/generated -I../../../include urandom_read.c
urandom_read -lcap -lelf -lrt -lpthread -o tools/testing/selftests/bpf/urandom_read
gcc: fatal error: input file ‘tools/testing/selftests/bpf/urandom_read’ is the
same as output file
compilation terminated.
../lib.mk:110: recipe for target 'tools/testing/selftests/bpf/urandom_read' failed
To fix this issue remove the urandom_read target and so target TEST_CUSTOM_PROGS gets used.

Quoted 3 lines
Fixes 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
Acked-by Yonghong Song <yhs at fb.com>

Applied to bpf, thanks Anders!
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html