tests: build the SHA-256 crypto extensions with GCC and a fortified libc

Build sha256.c with -mcpu=cortex-a53 and _FORTIFY_SOURCE for both
MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY and _IF_PRESENT. Without
Mbed-TLS/TF-PSA-Crypto#937 this fails to inline the fortified memset().

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
This commit is contained in:
Julius Bairaktaris 2026-10-04 00:19:31 +02:00
parent 0d13af54a8
commit cbcee99db1

View File

@ -316,6 +316,26 @@ component_build_sha_armce () {
not grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s
}
support_build_sha_armce_gcc () {
# GCC >= 6 is required to build with SHA extensions
[ "$(gcc_version "${AARCH64_LINUX_GNU_GCC_PREFIX}gcc")" -ge 6 ]
}
component_build_sha_armce_gcc () {
# The SHA-256 crypto extensions must be added to the target of the build,
# not replace it: with -mcpu=cortex-a53 (which has CRC) GCC otherwise
# refuses to inline always_inline functions such as a fortified memset().
scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
for opt in MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT; do
scripts/config.py set $opt
msg "$opt ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc, -mcpu=cortex-a53 -D_FORTIFY_SOURCE=2"
$MAKE_COMMAND -B library/../${BUILTIN_SRC_PATH}/sha256.o library/../${BUILTIN_SRC_PATH}/sha256.s CC="${AARCH64_LINUX_GNU_GCC_PREFIX}gcc" CFLAGS="-std=c99 -Werror -O2 -mcpu=cortex-a53 -D_FORTIFY_SOURCE=2"
msg "$opt ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc, test aarch64 crypto instructions built"
grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s
scripts/config.py unset $opt
done
}
component_test_arm_linux_gnueabi_gcc_arm5vte () {
# Mimic Debian armel port
msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, default config" # ~4m