WSL2-Linux-Kernel/tools/testing/selftests/timens
Dmitry Safonov 3e8393630e selftests: use LDLIBS for libraries instead of LDFLAGS
While building selftests, the following errors were observed:
> tools/testing/selftests/timens'
> gcc -Wall -Werror -pthread  -lrt -ldl  timens.c  -o tools/testing/selftests/timens/timens
> /usr/bin/ld: /tmp/ccGy5CST.o: in function `check_config_posix_timers':
> timens.c:(.text+0x65a): undefined reference to `timer_create'
> collect2: error: ld returned 1 exit status

Quoting commit 870f193d48 ("selftests: net: use LDLIBS instead of
LDFLAGS"):

The default Makefile rule looks like:

$(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS)

When linking is done by gcc itself, no issue, but when it needs to be passed
to proper ld, only LDLIBS follows and then ld cannot know what libs to link
with.

More detail:
https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

LDFLAGS
Extra flags to give to compilers when they are supposed to invoke the linker,
‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
instead.

LDLIBS
Library flags or names given to compilers when they are supposed to invoke the
linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to
LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS
variable.

While at here, correct other selftests, not only timens ones.

Reported-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Tested-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2020-02-13 13:14:34 -07:00
..
.gitignore selftests/timens: Check for right timens offsets after fork and exec 2020-01-14 12:21:02 +01:00
Makefile selftests: use LDLIBS for libraries instead of LDFLAGS 2020-02-13 13:14:34 -07:00
clock_nanosleep.c selftests/timens: Add a test for clock_nanosleep() 2020-01-14 12:21:01 +01:00
config
exec.c selftests/timens: Check for right timens offsets after fork and exec 2020-01-14 12:21:02 +01:00
gettime_perf.c selftests/timens: Add a simple perf test for clock_gettime() 2020-01-14 12:21:02 +01:00
log.h
procfs.c selftests/timens: Add procfs selftest 2020-01-14 12:21:01 +01:00
timens.c
timens.h
timer.c selftests/timens: Add timer offsets test 2020-01-14 12:21:01 +01:00
timerfd.c selftests/timens: Add a test for timerfd 2020-01-14 12:21:00 +01:00