Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: vDSO: separate LDLIBS from CFLAGS for libsodium

On systems that set -Wl,--as-needed, putting the -lsodium in the wrong
place on the command line means we get a linker error:

CC vdso_test_chacha
/usr/bin/ld: /tmp/ccKpjnSM.o: in function `main':
vdso_test_chacha.c:(.text+0x276): undefined reference to `crypto_stream_chacha20'
collect2: error: ld returned 1 exit status

Fix this by passing pkg-config's --libs output to the LDFLAGS field
instead of the CFLAGS field, as is customary.

Reported-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>

+5 -3
+5 -3
tools/testing/selftests/vDSO/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 uname_M := $(shell uname -m 2>/dev/null || echo not) 3 3 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) 4 - SODIUM := $(shell pkg-config --libs --cflags libsodium 2>/dev/null) 4 + SODIUM_LIBS := $(shell pkg-config --libs libsodium 2>/dev/null) 5 + SODIUM_CFLAGS := $(shell pkg-config --cflags libsodium 2>/dev/null) 5 6 6 7 TEST_GEN_PROGS := vdso_test_gettimeofday 7 8 TEST_GEN_PROGS += vdso_test_getcpu ··· 14 13 TEST_GEN_PROGS += vdso_test_correctness 15 14 ifeq ($(uname_M),x86_64) 16 15 TEST_GEN_PROGS += vdso_test_getrandom 17 - ifneq ($(SODIUM),) 16 + ifneq ($(SODIUM_LIBS),) 18 17 TEST_GEN_PROGS += vdso_test_chacha 19 18 endif 20 19 endif ··· 42 41 -isystem $(top_srcdir)/include/uapi 43 42 44 43 $(OUTPUT)/vdso_test_chacha: $(top_srcdir)/tools/arch/$(ARCH)/vdso/vgetrandom-chacha.S 44 + $(OUTPUT)/vdso_test_chacha: LDLIBS += $(SODIUM_LIBS) 45 45 $(OUTPUT)/vdso_test_chacha: CFLAGS += -idirafter $(top_srcdir)/tools/include \ 46 46 -idirafter $(top_srcdir)/arch/$(ARCH)/include \ 47 47 -idirafter $(top_srcdir)/include \ 48 48 -D__ASSEMBLY__ -DBULID_VDSO -DCONFIG_FUNCTION_ALIGNMENT=0 \ 49 - -Wa,--noexecstack $(SODIUM) 49 + -Wa,--noexecstack $(SODIUM_CFLAGS)