From 562677945bf12b8073c8677b3bfb83a0de8cb889 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 18 Dec 2025 20:23:45 +0100 Subject: [PATCH] Use intermediate variable for TF-PSA-Crypto's contribution to LOCAL_LDFLAGS Fix a bug whereby `crypto-common.make` was appending to `LOCAL_LDFLAGS` before `common.make` set the initial value. This broke the build with pthread enabled: `THREADING` was correctly getting autodetected, but the addition of `-lpthread` to `LOCAL_LDFLAGS` didn't work. Signed-off-by: Gilles Peskine --- scripts/common.make | 6 ++++-- scripts/crypto-common.make | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/common.make b/scripts/common.make index e88506b308..18dd29d2ed 100644 --- a/scripts/common.make +++ b/scripts/common.make @@ -46,13 +46,15 @@ LOCAL_LDFLAGS = ${MBEDTLS_TEST_OBJS} \ -lpsaclient \ -lmbedtls$(SHARED_SUFFIX) \ -lmbedx509$(SHARED_SUFFIX) \ - -lmbedcrypto$(SHARED_SUFFIX) + -lmbedcrypto$(SHARED_SUFFIX) \ + $(TF_PSA_CRYPTO_EXTRA_LDFLAGS) else LOCAL_LDFLAGS = ${MBEDTLS_TEST_OBJS} \ -L$(MBEDTLS_PATH)/library \ -lmbedtls$(SHARED_SUFFIX) \ -lmbedx509$(SHARED_SUFFIX) \ - -lmbedcrypto$(SHARED_SUFFIX) + -lmbedcrypto$(SHARED_SUFFIX) \ + $(TF_PSA_CRYPTO_EXTRA_LDFLAGS) endif ifdef PSASIM diff --git a/scripts/crypto-common.make b/scripts/crypto-common.make index 85da8d802a..c944cc528b 100644 --- a/scripts/crypto-common.make +++ b/scripts/crypto-common.make @@ -46,6 +46,9 @@ TF_PSA_CRYPTO_LIBRARY_PRIVATE_INCLUDE = \ -I$(TF_PSA_CRYPTO_PATH)/core \ -I$(TF_PSA_CRYPTO_PATH)/drivers/builtin/src +# Extra linker flags required by the crypto library or the platform +TF_PSA_CRYPTO_EXTRA_LDFLAGS = + ## Usage: $(call remove_enabled_options_crypto,PREPROCESSOR_INPUT) ## Remove the preprocessor symbols that are set in the current configuration ## from PREPROCESSOR_INPUT. Also normalize whitespace. @@ -91,6 +94,6 @@ ifndef WINDOWS_BUILD #$(info THREADING = $(THREADING)) ifeq ($(THREADING),pthread) - LOCAL_LDFLAGS += -lpthread + TF_PSA_CRYPTO_EXTRA_LDFLAGS += -lpthread endif endif