[PATCH 1/3] selftests/{net,memfd}: fix undefined references to external libraries
From: Marcin Nowakowski
Date: Fri Jun 23 2017 - 06:37:43 EST
net test fails to link properly due to a missing reference to -lnuma and
fails with:
reuseport_bpf_numa.c:138: undefined reference to `numa_run_on_node'
reuseport_bpf_numa.c:230: undefined reference to `numa_available'
reuseport_bpf_numa.c:233: undefined reference to `numa_max_node'
collect2: error: ld returned 1 exit status
running make -p shows that this is due to a wrong LDFLAGS variable
definition which doesn't include the output prefix location:
# makefile (from 'Makefile', line 6)
reuseport_bpf_numa: LDFLAGS += -lnuma
# Not a target:
reuseport_bpf_numa:
The same issue has been observed in memfd with its references to
libfuse.
Resolve this by adding a pattern-matching to allow the binary name to be
prefixed with an output location.
For memfd also replace LDFLAGS with LDLIBS definition to ensure correct
ordering of arguments in the make's implicit rules.
Fixes: a8ba798bc8ec ('selftests: enable O and KBUILD_OUTPUT')
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@xxxxxxxxxx>
---
tools/testing/selftests/memfd/Makefile | 4 ++--
tools/testing/selftests/net/Makefile | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 79891d0..754e92f 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -6,8 +6,8 @@ CFLAGS += -I../../../../usr/include/
TEST_PROGS := run_fuse_test.sh
TEST_GEN_FILES := memfd_test fuse_mnt fuse_test
-fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
-fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs)
+%/fuse_mnt: CFLAGS += $(shell pkg-config fuse --cflags)
+%/fuse_mnt: LDLIBS += $(shell pkg-config fuse --libs)
include ../lib.mk
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 35cbb4c..d7abe8b 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -3,7 +3,7 @@
CFLAGS = -Wall -Wl,--no-as-needed -O2 -g
CFLAGS += -I../../../../usr/include/
-reuseport_bpf_numa: LDFLAGS += -lnuma
+%/reuseport_bpf_numa: LDFLAGS += -lnuma
TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh
TEST_GEN_FILES = socket
--
2.7.4