mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: linux-kernel@vger.kernel.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Subject: [PATCH] selftests/vDSO: separate LDLIBS from CFLAGS for libsodium
Date: Tue, 27 Aug 2024 16:41:36 +0200	[thread overview]
Message-ID: <20240827144200.3315093-1-Jason@zx2c4.com> (raw)
In-Reply-To: <7d9c376c-10ae-40cc-8d8a-d614b8dd289f@linaro.org>

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>
---
 tools/testing/selftests/vDSO/Makefile | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile
index 180854eb9fec..834aa862ba2c 100644
--- a/tools/testing/selftests/vDSO/Makefile
+++ b/tools/testing/selftests/vDSO/Makefile
@@ -1,7 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 uname_M := $(shell uname -m 2>/dev/null || echo not)
 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
-SODIUM := $(shell pkg-config --libs --cflags libsodium 2>/dev/null)
+SODIUM_LIBS := $(shell pkg-config --libs libsodium 2>/dev/null)
+SODIUM_CFLAGS := $(shell pkg-config --cflags libsodium 2>/dev/null)
 
 TEST_GEN_PROGS := vdso_test_gettimeofday
 TEST_GEN_PROGS += vdso_test_getcpu
@@ -13,7 +14,7 @@ endif
 TEST_GEN_PROGS += vdso_test_correctness
 ifeq ($(uname_M),x86_64)
 TEST_GEN_PROGS += vdso_test_getrandom
-ifneq ($(SODIUM),)
+ifneq ($(SODIUM_LIBS),)
 TEST_GEN_PROGS += vdso_test_chacha
 endif
 endif
@@ -41,8 +42,9 @@ $(OUTPUT)/vdso_test_getrandom: CFLAGS += -isystem $(top_srcdir)/tools/include \
                                          -isystem $(top_srcdir)/include/uapi
 
 $(OUTPUT)/vdso_test_chacha: $(top_srcdir)/tools/arch/$(ARCH)/vdso/vgetrandom-chacha.S
+$(OUTPUT)/vdso_test_chacha: LDLIBS += $(SODIUM_LIBS)
 $(OUTPUT)/vdso_test_chacha: CFLAGS += -idirafter $(top_srcdir)/tools/include \
                                       -idirafter $(top_srcdir)/arch/$(ARCH)/include \
                                       -idirafter $(top_srcdir)/include \
                                       -D__ASSEMBLY__ -DBULID_VDSO -DCONFIG_FUNCTION_ALIGNMENT=0 \
-                                      -Wa,--noexecstack $(SODIUM)
+                                      -Wa,--noexecstack $(SODIUM_CFLAGS)
-- 
2.46.0


  reply	other threads:[~2024-08-27 14:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26 18:10 [PATCH] aarch64: vdso: Wire up getrandom() vDSO implementation Adhemerval Zanella
2024-08-26 20:27 ` Jason A. Donenfeld
2024-08-27 13:17   ` Adhemerval Zanella Netto
2024-08-27 13:34     ` Jason A. Donenfeld
2024-08-27 13:39       ` Adhemerval Zanella Netto
2024-08-27 14:00         ` Christophe Leroy
2024-08-27 14:01           ` Adhemerval Zanella Netto
2024-08-27 14:10             ` Christophe Leroy
2024-08-27 14:14               ` Adhemerval Zanella Netto
2024-08-27 14:28                 ` Jason A. Donenfeld
2024-08-27 14:30                   ` Adhemerval Zanella Netto
2024-08-27 14:32                     ` Jason A. Donenfeld
2024-08-27 14:35                       ` Adhemerval Zanella Netto
2024-08-27 14:41                         ` Jason A. Donenfeld [this message]
2024-08-27 14:45                           ` [PATCH] selftests/vDSO: separate LDLIBS from CFLAGS for libsodium Adhemerval Zanella Netto
2024-08-27 14:52                             ` Jason A. Donenfeld
2024-08-27 13:52     ` [PATCH] aarch64: vdso: Wire up getrandom() vDSO implementation Christophe Leroy
2024-08-26 20:55 ` Jason A. Donenfeld
2024-08-27  8:46 ` Christophe Leroy
2024-08-27  8:53   ` Jason A. Donenfeld
2024-08-27 15:16     ` Jason A. Donenfeld
2024-08-27 15:18       ` [PATCH] random: vDSO: move prototype of arch chacha function to vdso/getrandom.h Jason A. Donenfeld
2024-08-27 15:47         ` [PATCH v2] " Jason A. Donenfeld
2024-08-27 16:53           ` Christophe Leroy
2024-08-27 16:55             ` Jason A. Donenfeld
2024-08-27 14:07   ` [PATCH] aarch64: vdso: Wire up getrandom() vDSO implementation Adhemerval Zanella Netto
2024-08-27 13:51 ` Ard Biesheuvel
2024-08-27 14:00 ` Mark Rutland
2024-08-27 14:05   ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240827144200.3315093-1-Jason@zx2c4.com \
    --to=jason@zx2c4.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®