mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-03-20 19:21:09 +01:00
THREADING autodetection: only check the crypto config
When running the preprocessor to determine whether pthread is enabled, only use TF-PSA-Crypto include paths. Don't use the rest of `LOCAL_CFLAGS`, including Mbed TLS include paths, which aren't really useful here. This will simplify later refactorings, because it simplifies a dependency chain [crypto paths] → `LOCAL_CFLAGS` → `THREADING` → `LOCAL_LDFLAGS` into just [crypto paths] → `THREADING` → `LOCAL_LDFLAGS`. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@@ -79,23 +79,23 @@ ifdef WINDOWS
|
|||||||
WINDOWS_BUILD=1
|
WINDOWS_BUILD=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## Usage: $(call remove_enabled_options,PREPROCESSOR_INPUT)
|
## Usage: $(call remove_enabled_options_crypto,PREPROCESSOR_INPUT)
|
||||||
## Remove the preprocessor symbols that are set in the current configuration
|
## Remove the preprocessor symbols that are set in the current configuration
|
||||||
## from PREPROCESSOR_INPUT. Also normalize whitespace.
|
## from PREPROCESSOR_INPUT. Also normalize whitespace.
|
||||||
## Example:
|
## Example:
|
||||||
## $(call remove_enabled_options,MBEDTLS_FOO MBEDTLS_BAR)
|
## $(call remove_enabled_options_crypto,MBEDTLS_FOO MBEDTLS_BAR)
|
||||||
## This expands to an empty string "" if MBEDTLS_FOO and MBEDTLS_BAR are both
|
## This expands to an empty string "" if MBEDTLS_FOO and MBEDTLS_BAR are both
|
||||||
## enabled, to "MBEDTLS_FOO" if MBEDTLS_BAR is enabled but MBEDTLS_FOO is
|
## enabled in the TF-PSA-Crypto configuration, to "MBEDTLS_FOO" if
|
||||||
## disabled, etc.
|
## MBEDTLS_BAR is enabled but MBEDTLS_FOO is disabled, etc.
|
||||||
##
|
##
|
||||||
## This only works with a Unix-like shell environment (Bourne/POSIX-style shell
|
## This only works with a Unix-like shell environment (Bourne/POSIX-style shell
|
||||||
## and standard commands) and a Unix-like compiler (supporting -E). In
|
## and standard commands) and a Unix-like compiler (supporting -E). In
|
||||||
## other environments, the output is likely to be empty.
|
## other environments, the output is likely to be empty.
|
||||||
define remove_enabled_options
|
define remove_enabled_options_crypto
|
||||||
$(strip $(shell
|
$(strip $(shell
|
||||||
exec 2>/dev/null;
|
exec 2>/dev/null;
|
||||||
{ echo '#include <mbedtls/build_info.h>'; echo $(1); } |
|
{ echo '#include <tf-psa-crypto/build_info.h>'; echo $(1); } |
|
||||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -E - |
|
$(CC) $(TF_PSA_CRYPTO_LIBRARY_PUBLIC_INCLUDE) $(CFLAGS) -E - |
|
||||||
tail -n 1
|
tail -n 1
|
||||||
))
|
))
|
||||||
endef
|
endef
|
||||||
@@ -117,21 +117,24 @@ ifdef WINDOWS_BUILD
|
|||||||
ifdef SHARED
|
ifdef SHARED
|
||||||
SHARED_SUFFIX=.$(DLEXT)
|
SHARED_SUFFIX=.$(DLEXT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
else # Not building for Windows
|
else # Not building for Windows
|
||||||
DLEXT ?= so
|
DLEXT ?= so
|
||||||
EXEXT=
|
EXEXT=
|
||||||
SHARED_SUFFIX=
|
SHARED_SUFFIX=
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef WINDOWS_BUILD
|
||||||
ifeq ($(THREADING),)
|
ifeq ($(THREADING),)
|
||||||
# Auto-detect configurations with pthread.
|
# Auto-detect configurations with pthread.
|
||||||
# If the call to remove_enabled_options returns "control", the symbols
|
# If the call to remove_enabled_options returns "control", the symbols
|
||||||
# are confirmed set and we link with pthread.
|
# are confirmed set and we link with pthread.
|
||||||
# If the auto-detection fails, the result of the call is empty and
|
# If the auto-detection fails, the result of the call is empty and
|
||||||
# we keep THREADING undefined.
|
# we keep THREADING undefined.
|
||||||
ifeq (control,$(call remove_enabled_options,control MBEDTLS_THREADING_C MBEDTLS_THREADING_PTHREAD))
|
ifeq (control,$(call remove_enabled_options_crypto,control MBEDTLS_THREADING_C MBEDTLS_THREADING_PTHREAD))
|
||||||
THREADING := pthread
|
THREADING := pthread
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
#$(info THREADING = $(THREADING))
|
||||||
|
|
||||||
ifeq ($(THREADING),pthread)
|
ifeq ($(THREADING),pthread)
|
||||||
LOCAL_LDFLAGS += -lpthread
|
LOCAL_LDFLAGS += -lpthread
|
||||||
|
|||||||
Reference in New Issue
Block a user