selftests: Fix pthread link option
Subsystems (10)
PATCH 1/1 selftests: Fix pthread link option
To support pthread correctly, it is better to use -pthread instead of -lpthread.
--- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/membarrier/Makefile | 2 +- tools/testing/selftests/mqueue/Makefile | 2 +- tools/testing/selftests/net/Makefile | 4 ++-- .../testing/selftests/powerpc/benchmarks/Makefile | 4 ++-- tools/testing/selftests/powerpc/dscr/Makefile | 2 +- tools/testing/selftests/powerpc/mm/Makefile | 2 +- tools/testing/selftests/rseq/Makefile | 2 +- tools/testing/selftests/rtc/Makefile | 2 +- tools/testing/selftests/seccomp/Makefile | 2 +- tools/testing/selftests/timers/Makefile | 2 +- tools/testing/selftests/vm/Makefile | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-)
tools/testing/selftests/bpf/Makefile +1 -1
@@ -22,7 +22,7 @@ CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \ -I$(GENDIR) -I$(TOOLSDIR) -I$(CURDIR) \ -Dbpf_prog_load=bpf_prog_test_load \ -Dbpf_load_program=bpf_test_load_program -LDLIBS += -lcap -lelf -lrt -lpthread +LDLIBS += -lcap -lelf -lrt -pthread # Order correspond to 'make run_tests' order TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
tools/testing/selftests/membarrier/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only CFLAGS += -g -I../../../../usr/include/ -LDLIBS += -lpthread +LDLIBS += -pthread TEST_GEN_PROGS := membarrier_test_single_thread \ membarrier_test_multi_thread
tools/testing/selftests/mqueue/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -O2 -LDLIBS = -lrt -lpthread -lpopt +LDLIBS = -lrt -pthread -lpopt TEST_GEN_PROGS := mq_open_tests mq_perf_tests
tools/testing/selftests/net/Makefile +2 -2
@@ -25,5 +25,5 @@ KSFT_KHDR_INSTALL := 1 include ../lib.mk $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma -$(OUTPUT)/tcp_mmap: LDFLAGS += -lpthread -$(OUTPUT)/tcp_inq: LDFLAGS += -lpthread +$(OUTPUT)/tcp_mmap: LDFLAGS += -pthread +$(OUTPUT)/tcp_inq: LDFLAGS += -pthread
tools/testing/selftests/powerpc/benchmarks/Makefile +2 -2
@@ -11,8 +11,8 @@ $(TEST_GEN_PROGS): ../harness.c $(OUTPUT)/context_switch: ../utils.c $(OUTPUT)/context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec -$(OUTPUT)/context_switch: LDLIBS += -lpthread +$(OUTPUT)/context_switch: LDLIBS += -pthread -$(OUTPUT)/fork: LDLIBS += -lpthread +$(OUTPUT)/fork: LDLIBS += -pthread $(OUTPUT)/exec_target: CFLAGS += -static -nostartfiles
tools/testing/selftests/powerpc/dscr/Makefile +1 -1
@@ -6,6 +6,6 @@ TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test \ top_srcdir = ../../../../.. include ../../lib.mk -$(OUTPUT)/dscr_default_test: LDLIBS += -lpthread +$(OUTPUT)/dscr_default_test: LDLIBS += -pthread $(TEST_GEN_PROGS): ../harness.c
tools/testing/selftests/powerpc/mm/Makefile +1 -1
@@ -20,4 +20,4 @@ $(OUTPUT)/large_vm_fork_separation: CFLAGS += -m64 $(OUTPUT)/tempfile: dd if=/dev/zero of=$@ bs=64k count=1 -$(OUTPUT)/tlbie_test: LDLIBS += -lpthread +$(OUTPUT)/tlbie_test: LDLIBS += -pthread
tools/testing/selftests/rseq/Makefile +1 -1
@@ -6,7 +6,7 @@ endif CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ \ $(CLANG_FLAGS) -LDLIBS += -lpthread +LDLIBS += -pthread # Own dependencies because we only want to build against 1st prerequisite, but # still track changes to header files and depend on shared object.
tools/testing/selftests/rtc/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -O3 -Wl,-no-as-needed -Wall -LDFLAGS += -lrt -lpthread -lm +LDFLAGS += -lrt -pthread -lm TEST_GEN_PROGS = rtctest
tools/testing/selftests/seccomp/Makefile +1 -1
@@ -9,7 +9,7 @@ BINARIES := seccomp_bpf seccomp_benchmark CFLAGS += -Wl,-no-as-needed -Wall seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h - $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $< -pthread -o $@ TEST_PROGS += $(BINARIES) EXTRA_CLEAN := $(BINARIES)
tools/testing/selftests/timers/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -O3 -Wl,-no-as-needed -Wall -LDLIBS += -lrt -lpthread -lm +LDLIBS += -lrt -pthread -lm # these are all "safe" tests that don't modify # system time or require escalated privileges
tools/testing/selftests/vm/Makefile +1 -1
@@ -31,6 +31,6 @@ TEST_FILES := test_vmalloc.sh KSFT_KHDR_INSTALL := 1 include ../lib.mk -$(OUTPUT)/userfaultfd: LDLIBS += -lpthread +$(OUTPUT)/userfaultfd: LDLIBS += -pthread $(OUTPUT)/mlock-random-test: LDLIBS += -lcap
Quoted 24 lines · Masami Hiramatsu
To support pthread correctly, it is better to use -pthread instead of -lpthread.
Signed-off-by Masami Hiramatsu <[email protected]>--- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/membarrier/Makefile | 2 +- tools/testing/selftests/mqueue/Makefile | 2 +- tools/testing/selftests/net/Makefile | 4 ++-- .../testing/selftests/powerpc/benchmarks/Makefile | 4 ++-- tools/testing/selftests/powerpc/dscr/Makefile | 2 +- tools/testing/selftests/powerpc/mm/Makefile | 2 +- tools/testing/selftests/rseq/Makefile | 2 +- tools/testing/selftests/rtc/Makefile | 2 +- tools/testing/selftests/seccomp/Makefile | 2 +- tools/testing/selftests/timers/Makefile | 2 +- tools/testing/selftests/vm/Makefile | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-)tools/testing/selftests/bpf/Makefile +0
-0
tools/testing/selftests/bpf/Makefile CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \ · line 25
Quoted 5 lines
tools/testing/selftests/bpf/Makefile +1
-1@@ -22,7 +22,7 @@ CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \ -I$(GENDIR) -I$(TOOLSDIR) -I$(CURDIR) \ -Dbpf_prog_load=bpf_prog_test_load \ -Dbpf_load_program=bpf_test_load_program -LDLIBS += -lcap -lelf -lrt -lpthread +LDLIBS += -lcap -lelf -lrt -pthread
Please split this bit into separate patch and send it to bpf@vger targeting bpf-next. selftests/bpf are going through a lot of changes and I'd like to avoid any chance of conflicts.
Quoted 20 lines · On Wed, 15 Jan 2020 11:25:30 -0800 Alexei Starovoitov…
Quoted 19 lines · Masami Hiramatsu
To support pthread correctly, it is better to use -pthread instead of -lpthread.
Signed-off-by Masami Hiramatsu <[email protected]>--- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/membarrier/Makefile | 2 +- tools/testing/selftests/mqueue/Makefile | 2 +- tools/testing/selftests/net/Makefile | 4 ++-- .../testing/selftests/powerpc/benchmarks/Makefile | 4 ++-- tools/testing/selftests/powerpc/dscr/Makefile | 2 +- tools/testing/selftests/powerpc/mm/Makefile | 2 +- tools/testing/selftests/rseq/Makefile | 2 +- tools/testing/selftests/rtc/Makefile | 2 +- tools/testing/selftests/seccomp/Makefile | 2 +- tools/testing/selftests/timers/Makefile | 2 +- tools/testing/selftests/vm/Makefile | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-)
Quoted 14 lines
tools/testing/selftests/bpf/Makefile CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \ · line 25
Quoted 10 lines
tools/testing/selftests/bpf/Makefile +1
-1@@ -22,7 +22,7 @@ CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \ -I$(GENDIR) -I$(TOOLSDIR) -I$(CURDIR) \ -Dbpf_prog_load=bpf_prog_test_load \ -Dbpf_load_program=bpf_test_load_program -LDLIBS += -lcap -lelf -lrt -lpthread +LDLIBS += -lcap -lelf -lrt -pthreadPlease split this bit into separate patch and send it to bpf@vger targeting bpf-next. selftests/bpf are going through a lot of changes and I'd like to avoid any chance of conflicts.
OK, I'll split it.
Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>
Quoted 2 lines · On Wed, 15 Jan 2020 18:16:07 +0900 Masami Hiramatsu <[email protected]> wrote:
To support pthread correctly, it is better to use -pthread instead of -lpthread.
Oops, this should be refined, since LDLIBS will not be passed when compiling. -pthread is complier option but -lpthread is linker option.
Thank you,
Quoted 166 lines
Signed-off-by Masami Hiramatsu <[email protected]>--- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/membarrier/Makefile | 2 +- tools/testing/selftests/mqueue/Makefile | 2 +- tools/testing/selftests/net/Makefile | 4 ++-- .../testing/selftests/powerpc/benchmarks/Makefile | 4 ++-- tools/testing/selftests/powerpc/dscr/Makefile | 2 +- tools/testing/selftests/powerpc/mm/Makefile | 2 +- tools/testing/selftests/rseq/Makefile | 2 +- tools/testing/selftests/rtc/Makefile | 2 +- tools/testing/selftests/seccomp/Makefile | 2 +- tools/testing/selftests/timers/Makefile | 2 +- tools/testing/selftests/vm/Makefile | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-)tools/testing/selftests/bpf/Makefile +1
-1@@ -22,7 +22,7 @@ CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \ -I$(GENDIR) -I$(TOOLSDIR) -I$(CURDIR) \ -Dbpf_prog_load=bpf_prog_test_load \ -Dbpf_load_program=bpf_test_load_program -LDLIBS += -lcap -lelf -lrt -lpthread +LDLIBS += -lcap -lelf -lrt -pthread # Order correspond to 'make run_tests' order TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \tools/testing/selftests/membarrier/Makefile +1
-1@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only CFLAGS += -g -I../../../../usr/include/ -LDLIBS += -lpthread +LDLIBS += -pthread TEST_GEN_PROGS := membarrier_test_single_thread \ membarrier_test_multi_threadtools/testing/selftests/mqueue/Makefile +1
-1@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -O2 -LDLIBS = -lrt -lpthread -lpopt +LDLIBS = -lrt -pthread -lpopt TEST_GEN_PROGS := mq_open_tests mq_perf_teststools/testing/selftests/net/Makefile +2
-2@@ -25,5 +25,5 @@ KSFT_KHDR_INSTALL := 1 include ../lib.mk $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma -$(OUTPUT)/tcp_mmap: LDFLAGS += -lpthread -$(OUTPUT)/tcp_inq: LDFLAGS += -lpthread +$(OUTPUT)/tcp_mmap: LDFLAGS += -pthread +$(OUTPUT)/tcp_inq: LDFLAGS += -pthreadtools/testing/selftests/powerpc/benchmarks/Makefile +2
-2@@ -11,8 +11,8 @@ $(TEST_GEN_PROGS): ../harness.c $(OUTPUT)/context_switch: ../utils.c $(OUTPUT)/context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec -$(OUTPUT)/context_switch: LDLIBS += -lpthread +$(OUTPUT)/context_switch: LDLIBS += -pthread -$(OUTPUT)/fork: LDLIBS += -lpthread +$(OUTPUT)/fork: LDLIBS += -pthread $(OUTPUT)/exec_target: CFLAGS += -static -nostartfilestools/testing/selftests/powerpc/dscr/Makefile +1
-1@@ -6,6 +6,6 @@ TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test \ top_srcdir = ../../../../.. include ../../lib.mk -$(OUTPUT)/dscr_default_test: LDLIBS += -lpthread +$(OUTPUT)/dscr_default_test: LDLIBS += -pthread $(TEST_GEN_PROGS): ../harness.ctools/testing/selftests/powerpc/mm/Makefile +1
-1@@ -20,4 +20,4 @@ $(OUTPUT)/large_vm_fork_separation: CFLAGS += -m64 $(OUTPUT)/tempfile: dd if=/dev/zero of=$@ bs=64k count=1 -$(OUTPUT)/tlbie_test: LDLIBS += -lpthread +$(OUTPUT)/tlbie_test: LDLIBS += -pthreadtools/testing/selftests/rseq/Makefile +1
-1@@ -6,7 +6,7 @@ endif CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ \ $(CLANG_FLAGS) -LDLIBS += -lpthread +LDLIBS += -pthread # Own dependencies because we only want to build against 1st prerequisite, but # still track changes to header files and depend on shared object.tools/testing/selftests/rtc/Makefile +1
-1@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -O3 -Wl,-no-as-needed -Wall -LDFLAGS += -lrt -lpthread -lm +LDFLAGS += -lrt -pthread -lm TEST_GEN_PROGS = rtctesttools/testing/selftests/seccomp/Makefile +1
-1@@ -9,7 +9,7 @@ BINARIES := seccomp_bpf seccomp_benchmark CFLAGS += -Wl,-no-as-needed -Wall seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h - $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $< -pthread -o $@ TEST_PROGS += $(BINARIES) EXTRA_CLEAN := $(BINARIES)tools/testing/selftests/timers/Makefile +1
-1@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -O3 -Wl,-no-as-needed -Wall -LDLIBS += -lrt -lpthread -lm +LDLIBS += -lrt -pthread -lm # these are all "safe" tests that don't modify # system time or require escalated privilegestools/testing/selftests/vm/Makefile +1
-1@@ -31,6 +31,6 @@ TEST_FILES := test_vmalloc.sh KSFT_KHDR_INSTALL := 1 include ../lib.mk -$(OUTPUT)/userfaultfd: LDLIBS += -lpthread +$(OUTPUT)/userfaultfd: LDLIBS += -pthread $(OUTPUT)/mlock-random-test: LDLIBS += -lcap
Signature · 1 line
Masami Hiramatsu <[email protected]>