Skip to content

Commit 7fb1023

Browse files
Andre-ARMshuahkh
authored andcommitted
selftests: cachestat: properly link in librt
Libraries should be listed last on the compiler's command line, so that the linker can look for and find still unresolved symbols. The librt library, required for the shm_* functions, was announced using CFLAGS, which puts the library *before* the source files, and fails compilation on my system: ====================== gcc -isystem /src/linux-selftests/usr/include -Wall -lrt test_cachestat.c -o /src/linux-selftests/kselftest/cachestat/test_cachestat /usr/bin/ld: /tmp/cceQWO3u.o: in function `test_cachestat_shmem': test_cachestat.c:(.text+0x890): undefined reference to `shm_open' /usr/bin/ld: test_cachestat.c:(.text+0x99c): undefined reference to `shm_unlink' collect2: error: ld returned 1 exit status make[4]: *** [../lib.mk:181: /src/linux-selftests/kselftest/cachestat/test_cachestat] Error 1 ====================== Announce the library using the LDLIBS variable, which ensures the proper ordering on the command line. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent fbf4dec commit 7fb1023

File tree

1 file changed

+1
-1
lines changed
  • tools/testing/selftests/cachestat

1 file changed

+1
-1
lines changed

tools/testing/selftests/cachestat/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ TEST_GEN_PROGS := test_cachestat
33

44
CFLAGS += $(KHDR_INCLUDES)
55
CFLAGS += -Wall
6-
CFLAGS += -lrt
6+
LDLIBS += -lrt
77

88
include ../lib.mk

0 commit comments

Comments
 (0)