Minos Galanakis | 6aab5b7 | 2024-07-25 14:24:37 +0100 | [diff] [blame] | 1 | # components-platform.sh |
| 2 | # |
| 3 | # Copyright The Mbed TLS Contributors |
| 4 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 5 | |
Minos Galanakis | 609f749 | 2024-07-31 16:39:28 +0100 | [diff] [blame] | 6 | # This file contains test components that are executed by all.sh |
Minos Galanakis | 6aab5b7 | 2024-07-25 14:24:37 +0100 | [diff] [blame] | 7 | |
| 8 | ################################################################ |
| 9 | #### Platform Testing |
| 10 | ################################################################ |
| 11 | |
Minos Galanakis | 8a98090 | 2024-07-26 17:41:03 +0100 | [diff] [blame] | 12 | component_test_m32_no_asm () { |
| 13 | # Build without assembly, so as to use portable C code (in a 32-bit |
| 14 | # build) and not the i386-specific inline assembly. |
| 15 | # |
| 16 | # Note that we require gcc, because clang Asan builds fail to link for |
| 17 | # this target (cannot find libclang_rt.lsan-i386.a - this is a known clang issue). |
| 18 | msg "build: i386, make, gcc, no asm (ASan build)" # ~ 30s |
| 19 | scripts/config.py full |
| 20 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 21 | scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32 |
| 22 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS" |
| 23 | |
| 24 | msg "test: i386, make, gcc, no asm (ASan build)" |
| 25 | make test |
| 26 | } |
| 27 | |
| 28 | support_test_m32_no_asm () { |
| 29 | case $(uname -m) in |
| 30 | amd64|x86_64) true;; |
| 31 | *) false;; |
| 32 | esac |
| 33 | } |
| 34 | |
| 35 | component_test_m32_o2 () { |
| 36 | # Build with optimization, to use the i386 specific inline assembly |
| 37 | # and go faster for tests. |
| 38 | msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s |
| 39 | scripts/config.py full |
| 40 | scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32 |
| 41 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS" |
| 42 | |
| 43 | msg "test: i386, make, gcc -O2 (ASan build)" |
| 44 | make test |
| 45 | |
| 46 | msg "test ssl-opt.sh, i386, make, gcc-O2" |
| 47 | tests/ssl-opt.sh |
| 48 | } |
| 49 | |
| 50 | support_test_m32_o2 () { |
| 51 | support_test_m32_no_asm "$@" |
| 52 | } |
| 53 | |
| 54 | component_test_m32_everest () { |
| 55 | msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min |
| 56 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 57 | scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32 |
| 58 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS" |
| 59 | |
| 60 | msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 61 | make test |
| 62 | |
| 63 | msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 64 | tests/ssl-opt.sh -f ECDH |
| 65 | |
| 66 | msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 67 | # Exclude some symmetric ciphers that are redundant here to gain time. |
| 68 | tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA' |
| 69 | } |
| 70 | |
| 71 | support_test_m32_everest () { |
| 72 | support_test_m32_no_asm "$@" |
| 73 | } |
| 74 | |
| 75 | component_test_mx32 () { |
| 76 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
| 77 | scripts/config.py full |
| 78 | make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
| 79 | |
| 80 | msg "test: 64-bit ILP32, make, gcc" |
| 81 | make test |
| 82 | } |
| 83 | |
| 84 | support_test_mx32 () { |
| 85 | case $(uname -m) in |
| 86 | amd64|x86_64) true;; |
| 87 | *) false;; |
| 88 | esac |
| 89 | } |
| 90 | |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 91 | support_test_aesni () { |
| 92 | # Check that gcc targets x86_64 (we can build AESNI), and check for |
| 93 | # AESNI support on the host (we can run AESNI). |
| 94 | # |
| 95 | # The name of this function is possibly slightly misleading, but needs to align |
| 96 | # with the name of the corresponding test, component_test_aesni. |
| 97 | # |
| 98 | # In principle 32-bit x86 can support AESNI, but our implementation does not |
| 99 | # support 32-bit x86, so we check for x86-64. |
| 100 | # We can only grep /proc/cpuinfo on Linux, so this also checks for Linux |
| 101 | (gcc -v 2>&1 | grep Target | grep -q x86_64) && |
| 102 | [[ "$HOSTTYPE" == "x86_64" && "$OSTYPE" == "linux-gnu" ]] && |
| 103 | (lscpu | grep -qw aes) |
| 104 | } |
| 105 | |
| 106 | component_test_aesni () { # ~ 60s |
| 107 | # This tests the two AESNI implementations (intrinsics and assembly), and also the plain C |
| 108 | # fallback. It also tests the logic that is used to select which implementation(s) to build. |
| 109 | # |
| 110 | # This test does not require the host to have support for AESNI (if it doesn't, the run-time |
| 111 | # AESNI detection will fallback to the plain C implementation, so the tests will instead |
| 112 | # exercise the plain C impl). |
| 113 | |
| 114 | msg "build: default config with different AES implementations" |
| 115 | scripts/config.py set MBEDTLS_AESNI_C |
| 116 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 117 | scripts/config.py set MBEDTLS_HAVE_ASM |
| 118 | |
| 119 | # test the intrinsics implementation |
| 120 | msg "AES tests, test intrinsics" |
| 121 | make clean |
| 122 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mpclmul -msse2 -maes' |
| 123 | # check that we built intrinsics - this should be used by default when supported by the compiler |
| 124 | ./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics" |
| 125 | |
| 126 | # test the asm implementation |
| 127 | msg "AES tests, test assembly" |
| 128 | make clean |
| 129 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mno-pclmul -mno-sse2 -mno-aes' |
| 130 | # check that we built assembly - this should be built if the compiler does not support intrinsics |
| 131 | ./programs/test/selftest aes | grep "AESNI code" | grep -q "assembly" |
| 132 | |
| 133 | # test the plain C implementation |
| 134 | scripts/config.py unset MBEDTLS_AESNI_C |
| 135 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 136 | msg "AES tests, plain C" |
| 137 | make clean |
| 138 | make CC=gcc CFLAGS='-O2 -Werror' |
| 139 | # check that there is no AESNI code present |
| 140 | ./programs/test/selftest aes | not grep -q "AESNI code" |
| 141 | not grep -q "AES note: using AESNI" ./programs/test/selftest |
| 142 | grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 143 | |
| 144 | # test the intrinsics implementation |
| 145 | scripts/config.py set MBEDTLS_AESNI_C |
| 146 | scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY |
| 147 | msg "AES tests, test AESNI only" |
| 148 | make clean |
| 149 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mpclmul -msse2 -maes' |
| 150 | ./programs/test/selftest aes | grep -q "AES note: using AESNI" |
| 151 | ./programs/test/selftest aes | not grep -q "AES note: built-in implementation." |
| 152 | grep -q "AES note: using AESNI" ./programs/test/selftest |
| 153 | not grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 154 | } |
| 155 | |
| 156 | support_test_aesni_m32 () { |
| 157 | support_test_m32_no_asm && (lscpu | grep -qw aes) |
| 158 | } |
| 159 | |
| 160 | component_test_aesni_m32 () { # ~ 60s |
| 161 | # This tests are duplicated from component_test_aesni for i386 target |
| 162 | # |
| 163 | # AESNI intrinsic code supports i386 and assembly code does not support it. |
| 164 | |
| 165 | msg "build: default config with different AES implementations" |
| 166 | scripts/config.py set MBEDTLS_AESNI_C |
| 167 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 168 | scripts/config.py set MBEDTLS_HAVE_ASM |
| 169 | |
| 170 | # test the intrinsics implementation with gcc |
| 171 | msg "AES tests, test intrinsics (gcc)" |
| 172 | make clean |
| 173 | make CC=gcc CFLAGS='-m32 -Werror -Wall -Wextra' LDFLAGS='-m32' |
| 174 | # check that we built intrinsics - this should be used by default when supported by the compiler |
| 175 | ./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics" |
| 176 | grep -q "AES note: using AESNI" ./programs/test/selftest |
| 177 | grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 178 | grep -q mbedtls_aesni_has_support ./programs/test/selftest |
| 179 | |
| 180 | scripts/config.py set MBEDTLS_AESNI_C |
| 181 | scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY |
| 182 | msg "AES tests, test AESNI only" |
| 183 | make clean |
| 184 | make CC=gcc CFLAGS='-m32 -Werror -Wall -Wextra -mpclmul -msse2 -maes' LDFLAGS='-m32' |
| 185 | ./programs/test/selftest aes | grep -q "AES note: using AESNI" |
| 186 | ./programs/test/selftest aes | not grep -q "AES note: built-in implementation." |
| 187 | grep -q "AES note: using AESNI" ./programs/test/selftest |
| 188 | not grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 189 | not grep -q mbedtls_aesni_has_support ./programs/test/selftest |
| 190 | } |
| 191 | |
Minos Galanakis | 1ef3a66 | 2024-08-01 11:47:49 +0100 | [diff] [blame] | 192 | support_test_aesni_m32_clang () { |
| 193 | # clang >= 4 is required to build with target attributes |
| 194 | support_test_aesni_m32 && [[ $(clang_version) -ge 4 ]] |
| 195 | } |
| 196 | |
| 197 | component_test_aesni_m32_clang () { |
| 198 | |
| 199 | scripts/config.py set MBEDTLS_AESNI_C |
| 200 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 201 | scripts/config.py set MBEDTLS_HAVE_ASM |
| 202 | |
| 203 | # test the intrinsics implementation with clang |
| 204 | msg "AES tests, test intrinsics (clang)" |
| 205 | make clean |
| 206 | make CC=clang CFLAGS='-m32 -Werror -Wall -Wextra' LDFLAGS='-m32' |
| 207 | # check that we built intrinsics - this should be used by default when supported by the compiler |
| 208 | ./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics" |
| 209 | grep -q "AES note: using AESNI" ./programs/test/selftest |
| 210 | grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 211 | grep -q mbedtls_aesni_has_support ./programs/test/selftest |
| 212 | } |
| 213 | |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 214 | support_build_aes_armce () { |
| 215 | # clang >= 11 is required to build with AES extensions |
| 216 | [[ $(clang_version) -ge 11 ]] |
| 217 | } |
| 218 | |
| 219 | component_build_aes_armce () { |
| 220 | # Test variations of AES with Armv8 crypto extensions |
| 221 | scripts/config.py set MBEDTLS_AESCE_C |
| 222 | scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY |
| 223 | |
| 224 | msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, aarch64" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 225 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto" |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 226 | msg "clang, test aarch64 crypto instructions built" |
Gilles Peskine | 8bea95d | 2024-06-19 14:16:05 +0200 | [diff] [blame] | 227 | grep -E 'aes[a-z]+\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 228 | |
| 229 | msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, arm" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 230 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm" |
| 231 | msg "clang, test A32 crypto instructions built" |
| 232 | grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 233 | |
| 234 | msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, thumb" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 235 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb" |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 236 | msg "clang, test T32 crypto instructions built" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 237 | grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 238 | |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 239 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 240 | |
| 241 | msg "MBEDTLS_AES_USE_both, clang, aarch64" |
| 242 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto" |
| 243 | msg "clang, test aarch64 crypto instructions built" |
| 244 | grep -E 'aes[a-z]+\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
| 245 | |
| 246 | msg "MBEDTLS_AES_USE_both, clang, arm" |
| 247 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm" |
| 248 | msg "clang, test A32 crypto instructions built" |
| 249 | grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
| 250 | |
| 251 | msg "MBEDTLS_AES_USE_both, clang, thumb" |
| 252 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb" |
| 253 | msg "clang, test T32 crypto instructions built" |
| 254 | grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
| 255 | |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 256 | scripts/config.py unset MBEDTLS_AESCE_C |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 257 | |
| 258 | msg "no MBEDTLS_AESCE_C, clang, aarch64" |
| 259 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a" |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 260 | msg "clang, test aarch64 crypto instructions not built" |
Gilles Peskine | 8bea95d | 2024-06-19 14:16:05 +0200 | [diff] [blame] | 261 | not grep -E 'aes[a-z]+\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 262 | |
| 263 | msg "no MBEDTLS_AESCE_C, clang, arm" |
| 264 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72 -marm" |
| 265 | msg "clang, test A32 crypto instructions not built" |
| 266 | not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
| 267 | |
| 268 | msg "no MBEDTLS_AESCE_C, clang, thumb" |
| 269 | make -B library/../${BUILTIN_SRC_PATH}/aesce.o library/../${BUILTIN_SRC_PATH}/aesce.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32 -mthumb" |
| 270 | msg "clang, test T32 crypto instructions not built" |
| 271 | not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | support_build_sha_armce () { |
| 275 | # clang >= 4 is required to build with SHA extensions |
| 276 | [[ $(clang_version) -ge 4 ]] |
| 277 | } |
| 278 | |
| 279 | component_build_sha_armce () { |
| 280 | scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT |
| 281 | |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 282 | # Test variations of SHA256 Armv8 crypto extensions |
| 283 | scripts/config.py set MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY |
| 284 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, aarch64" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 285 | make -B library/../${BUILTIN_SRC_PATH}/sha256.o library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto" |
| 286 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, test aarch64 crypto instructions built" |
| 287 | grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s |
| 288 | |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 289 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, arm" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 290 | make -B library/../${BUILTIN_SRC_PATH}/sha256.o library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm" |
| 291 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, test A32 crypto instructions built" |
| 292 | grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 293 | scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY |
| 294 | |
| 295 | |
| 296 | # test the deprecated form of the config option |
| 297 | scripts/config.py set MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY |
| 298 | msg "MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY clang, thumb" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 299 | make -B library/../${BUILTIN_SRC_PATH}/sha256.o library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb" |
| 300 | msg "MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY clang, test T32 crypto instructions built" |
| 301 | grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 302 | scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY |
| 303 | |
| 304 | scripts/config.py set MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT |
| 305 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT clang, aarch64" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 306 | make -B library/../${BUILTIN_SRC_PATH}/sha256.o library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto" |
| 307 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT clang, test aarch64 crypto instructions built" |
| 308 | grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 309 | scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT |
| 310 | |
| 311 | |
| 312 | # test the deprecated form of the config option |
| 313 | scripts/config.py set MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT |
| 314 | msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, arm" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 315 | make -B library/../${BUILTIN_SRC_PATH}/sha256.o library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -std=c99" |
| 316 | |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 317 | msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, thumb" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 318 | make -B library/../${BUILTIN_SRC_PATH}/sha256.o library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb" |
| 319 | msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, test T32 crypto instructions built" |
| 320 | grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 321 | scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT |
| 322 | |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 323 | # examine the disassembly for absence of SHA instructions |
| 324 | msg "clang, test A32 crypto instructions not built" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 325 | make -B library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72 -marm" |
Gilles Peskine | 8bea95d | 2024-06-19 14:16:05 +0200 | [diff] [blame] | 326 | not grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 327 | |
| 328 | msg "clang, test T32 crypto instructions not built" |
Gilles Peskine | 59aea4e | 2024-06-19 19:58:38 +0200 | [diff] [blame] | 329 | make -B library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32 -mthumb" |
Gilles Peskine | 8bea95d | 2024-06-19 14:16:05 +0200 | [diff] [blame] | 330 | not grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 331 | |
| 332 | msg "clang, test aarch64 crypto instructions not built" |
Gilles Peskine | 8bea95d | 2024-06-19 14:16:05 +0200 | [diff] [blame] | 333 | make -B library/../${BUILTIN_SRC_PATH}/sha256.s CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a" |
| 334 | not grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.s |
Minos Galanakis | b5891d5 | 2024-08-01 11:55:33 +0100 | [diff] [blame] | 335 | } |
| 336 | |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 337 | component_test_arm_linux_gnueabi_gcc_arm5vte () { |
| 338 | # Mimic Debian armel port |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 339 | msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, default config" # ~4m |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 340 | make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' |
| 341 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 342 | msg "test: main suites make, default config (out-of-box)" # ~7m 40s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 343 | make test |
| 344 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 345 | msg "selftest: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 346 | programs/test/selftest |
| 347 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 348 | msg "program demos: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 349 | tests/scripts/run_demos.py |
| 350 | } |
| 351 | |
| 352 | support_test_arm_linux_gnueabi_gcc_arm5vte () { |
| 353 | can_run_arm_linux_gnueabi |
| 354 | } |
| 355 | |
Bence Szépkúti | 479eb52 | 2024-07-18 16:08:22 +0200 | [diff] [blame^] | 356 | # The hard float ABI is not implemented for Thumb 1, so use gnueabi |
| 357 | # Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os |
| 358 | component_test_arm_linux_gnueabi_gcc_thumb_1_opt_0 () { |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 359 | msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -O0, thumb 1, default config" # ~2m 10s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 360 | make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O0 -mcpu=arm1136j-s -mthumb' |
| 361 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 362 | msg "test: main suites make, default config (out-of-box)" # ~36m |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 363 | make test |
| 364 | |
| 365 | msg "selftest: make, default config (out-of-box)" # ~10s |
| 366 | programs/test/selftest |
| 367 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 368 | msg "program demos: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 369 | tests/scripts/run_demos.py |
Bence Szépkúti | 479eb52 | 2024-07-18 16:08:22 +0200 | [diff] [blame^] | 370 | } |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 371 | |
Bence Szépkúti | 479eb52 | 2024-07-18 16:08:22 +0200 | [diff] [blame^] | 372 | support_test_arm_linux_gnueabi_gcc_thumb_1_opt_0 () { |
| 373 | can_run_arm_linux_gnueabi |
| 374 | } |
| 375 | |
| 376 | component_test_arm_linux_gnueabi_gcc_thumb_1_opt_s () { |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 377 | msg "test: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -Os, thumb 1, default config" # ~3m 10s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 378 | make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -Os -mcpu=arm1136j-s -mthumb' |
| 379 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 380 | msg "test: main suites make, default config (out-of-box)" # ~21m 10s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 381 | make test |
| 382 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 383 | msg "selftest: make, default config (out-of-box)" # ~2s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 384 | programs/test/selftest |
| 385 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 386 | msg "program demos: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 387 | tests/scripts/run_demos.py |
| 388 | } |
| 389 | |
Bence Szépkúti | 479eb52 | 2024-07-18 16:08:22 +0200 | [diff] [blame^] | 390 | support_test_arm_linux_gnueabi_gcc_thumb_1_opt_s () { |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 391 | can_run_arm_linux_gnueabi |
| 392 | } |
| 393 | |
| 394 | component_test_arm_linux_gnueabihf_gcc_armv7 () { |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 395 | msg "test: ${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc -O2, A32, default config" # ~4m 30s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 396 | make CC="${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O2 -march=armv7-a -marm' |
| 397 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 398 | msg "test: main suites make, default config (out-of-box)" # ~3m 30s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 399 | make test |
| 400 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 401 | msg "selftest: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 402 | programs/test/selftest |
| 403 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 404 | msg "program demos: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 405 | tests/scripts/run_demos.py |
| 406 | } |
| 407 | |
| 408 | support_test_arm_linux_gnueabihf_gcc_armv7 () { |
| 409 | can_run_arm_linux_gnueabihf |
| 410 | } |
| 411 | |
| 412 | component_test_arm_linux_gnueabihf_gcc_thumb_2 () { |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 413 | msg "test: ${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc -Os, thumb 2, default config" # ~4m |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 414 | make CC="${ARM_LINUX_GNUEABIHF_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -Os -march=armv7-a -mthumb' |
| 415 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 416 | msg "test: main suites make, default config (out-of-box)" # ~3m 40s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 417 | make test |
| 418 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 419 | msg "selftest: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 420 | programs/test/selftest |
| 421 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 422 | msg "program demos: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | 1524b9c | 2024-07-11 09:50:45 +0100 | [diff] [blame] | 423 | tests/scripts/run_demos.py |
| 424 | } |
| 425 | |
| 426 | support_test_arm_linux_gnueabihf_gcc_thumb_2 () { |
| 427 | can_run_arm_linux_gnueabihf |
| 428 | } |
| 429 | |
Bence Szépkúti | d1d2613 | 2024-07-11 15:52:07 +0100 | [diff] [blame] | 430 | component_test_aarch64_linux_gnu_gcc () { |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 431 | msg "test: ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc -O2, default config" # ~3m 50s |
Bence Szépkúti | d1d2613 | 2024-07-11 15:52:07 +0100 | [diff] [blame] | 432 | make CC="${AARCH64_LINUX_GNU_GCC_PREFIX}gcc" CFLAGS='-std=c99 -Werror -Wextra -O2' |
| 433 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 434 | msg "test: main suites make, default config (out-of-box)" # ~1m 50s |
Bence Szépkúti | d1d2613 | 2024-07-11 15:52:07 +0100 | [diff] [blame] | 435 | make test |
| 436 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 437 | msg "selftest: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | d1d2613 | 2024-07-11 15:52:07 +0100 | [diff] [blame] | 438 | programs/test/selftest |
| 439 | |
Bence Szépkúti | de146a1 | 2024-07-18 15:56:15 +0200 | [diff] [blame] | 440 | msg "program demos: make, default config (out-of-box)" # ~0s |
Bence Szépkúti | d1d2613 | 2024-07-11 15:52:07 +0100 | [diff] [blame] | 441 | tests/scripts/run_demos.py |
| 442 | } |
| 443 | |
| 444 | support_test_aarch64_linux_gnu_gcc () { |
| 445 | [ "$(gcc_version "${AARCH64_LINUX_GNU_GCC_PREFIX}gcc")" -ge 6 ] && can_run_aarch64_linux_gnu |
| 446 | } |
| 447 | |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 448 | component_build_arm_none_eabi_gcc () { |
| 449 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" # ~ 10s |
| 450 | scripts/config.py baremetal |
| 451 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -O1' lib |
| 452 | |
| 453 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" |
| 454 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
| 455 | ${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o |
| 456 | ${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o |
| 457 | } |
| 458 | |
| 459 | component_build_arm_linux_gnueabi_gcc_arm5vte () { |
| 460 | msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s |
| 461 | scripts/config.py baremetal |
| 462 | # Build for a target platform that's close to what Debian uses |
| 463 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
| 464 | # See https://github.com/Mbed-TLS/mbedtls/pull/2169 and comments. |
| 465 | # Build everything including programs, see for example |
| 466 | # https://github.com/Mbed-TLS/mbedtls/pull/3449#issuecomment-675313720 |
| 467 | make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' |
| 468 | |
| 469 | msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug" |
| 470 | ${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t library/*.o |
| 471 | ${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o |
| 472 | ${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o |
| 473 | } |
| 474 | |
| 475 | support_build_arm_linux_gnueabi_gcc_arm5vte () { |
| 476 | type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1 |
| 477 | } |
| 478 | |
| 479 | component_build_arm_none_eabi_gcc_arm5vte () { |
| 480 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s |
| 481 | scripts/config.py baremetal |
| 482 | # This is an imperfect substitute for |
| 483 | # component_build_arm_linux_gnueabi_gcc_arm5vte |
| 484 | # in case the gcc-arm-linux-gnueabi toolchain is not available |
| 485 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-std=c99 -Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib |
| 486 | |
| 487 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug" |
| 488 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
| 489 | ${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o |
| 490 | ${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o |
| 491 | } |
| 492 | |
| 493 | component_build_arm_none_eabi_gcc_m0plus () { |
| 494 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus, baremetal_size" # ~ 10s |
| 495 | scripts/config.py baremetal_size |
| 496 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib |
| 497 | |
| 498 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size" |
| 499 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
| 500 | ${ARM_NONE_EABI_GCC_PREFIX}size -t ${PSA_CORE_PATH}/*.o |
| 501 | ${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o |
| 502 | for lib in library/*.a; do |
| 503 | echo "$lib:" |
| 504 | ${ARM_NONE_EABI_GCC_PREFIX}size -t $lib | grep TOTALS |
| 505 | done |
| 506 | } |
| 507 | |
| 508 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
| 509 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
| 510 | scripts/config.py baremetal |
| 511 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
| 512 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra' lib |
| 513 | echo "Checking that software 64-bit division is not required" |
| 514 | not grep __aeabi_uldiv library/*.o |
| 515 | not grep __aeabi_uldiv ${PSA_CORE_PATH}/*.o |
| 516 | not grep __aeabi_uldiv ${BUILTIN_SRC_PATH}/*.o |
| 517 | } |
| 518 | |
| 519 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
| 520 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
| 521 | scripts/config.py baremetal |
| 522 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
| 523 | make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -O1 -march=armv6-m -mthumb' lib |
| 524 | echo "Checking that software 64-bit multiplication is not required" |
| 525 | not grep __aeabi_lmul library/*.o |
| 526 | not grep __aeabi_lmul ${PSA_CORE_PATH}/*.o |
| 527 | not grep __aeabi_lmul ${BUILTIN_SRC_PATH}/*.o |
| 528 | } |
| 529 | |
| 530 | component_build_arm_clang_thumb () { |
| 531 | # ~ 30s |
| 532 | |
| 533 | scripts/config.py baremetal |
| 534 | |
| 535 | msg "build: clang thumb 2, make" |
| 536 | make clean |
| 537 | make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -march=armv7-m -mthumb' lib |
| 538 | |
| 539 | # Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os |
| 540 | msg "build: clang thumb 1 -O0, make" |
| 541 | make clean |
| 542 | make CC="clang" CFLAGS='-std=c99 -Werror -O0 --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib |
| 543 | |
| 544 | msg "build: clang thumb 1 -Os, make" |
| 545 | make clean |
| 546 | make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib |
| 547 | } |
| 548 | |
| 549 | component_build_armcc () { |
| 550 | msg "build: ARM Compiler 5" |
| 551 | scripts/config.py baremetal |
| 552 | # armc[56] don't support SHA-512 intrinsics |
| 553 | scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT |
| 554 | |
| 555 | # older versions of armcc/armclang don't support AESCE_C on 32-bit Arm |
| 556 | scripts/config.py unset MBEDTLS_AESCE_C |
| 557 | |
| 558 | # Stop armclang warning about feature detection for A64_CRYPTO. |
| 559 | # With this enabled, the library does build correctly under armclang, |
| 560 | # but in baremetal builds (as tested here), feature detection is |
| 561 | # unavailable, and the user is notified via a #warning. So enabling |
| 562 | # this feature would prevent us from building with -Werror on |
| 563 | # armclang. Tracked in #7198. |
| 564 | scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT |
| 565 | |
| 566 | scripts/config.py set MBEDTLS_HAVE_ASM |
| 567 | |
| 568 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
| 569 | |
| 570 | msg "size: ARM Compiler 5" |
| 571 | "$ARMC5_FROMELF" -z library/*.o |
| 572 | "$ARMC5_FROMELF" -z ${PSA_CORE_PATH}/*.o |
| 573 | "$ARMC5_FROMELF" -z ${BUILTIN_SRC_PATH}/*.o |
| 574 | |
| 575 | # Compile mostly with -O1 since some Arm inline assembly is disabled for -O0. |
| 576 | |
| 577 | # ARM Compiler 6 - Target ARMv7-A |
Manuel Pégourié-Gonnard | 8f08bcd | 2024-10-01 13:01:54 +0200 | [diff] [blame] | 578 | helper_armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-a" |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 579 | |
| 580 | # ARM Compiler 6 - Target ARMv7-M |
Manuel Pégourié-Gonnard | 8f08bcd | 2024-10-01 13:01:54 +0200 | [diff] [blame] | 581 | helper_armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m" |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 582 | |
| 583 | # ARM Compiler 6 - Target ARMv7-M+DSP |
Manuel Pégourié-Gonnard | 8f08bcd | 2024-10-01 13:01:54 +0200 | [diff] [blame] | 584 | helper_armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m+dsp" |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 585 | |
| 586 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
Manuel Pégourié-Gonnard | 8f08bcd | 2024-10-01 13:01:54 +0200 | [diff] [blame] | 587 | helper_armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8.2-a" |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 588 | |
| 589 | # ARM Compiler 6 - Target ARMv8-M |
Manuel Pégourié-Gonnard | 8f08bcd | 2024-10-01 13:01:54 +0200 | [diff] [blame] | 590 | helper_armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8-m.main" |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 591 | |
| 592 | # ARM Compiler 6 - Target Cortex-M0 - no optimisation |
Manuel Pégourié-Gonnard | 8f08bcd | 2024-10-01 13:01:54 +0200 | [diff] [blame] | 593 | helper_armc6_build_test "-O0 --target=arm-arm-none-eabi -mcpu=cortex-m0" |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 594 | |
| 595 | # ARM Compiler 6 - Target Cortex-M0 |
Manuel Pégourié-Gonnard | 8f08bcd | 2024-10-01 13:01:54 +0200 | [diff] [blame] | 596 | helper_armc6_build_test "-Os --target=arm-arm-none-eabi -mcpu=cortex-m0" |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 597 | |
| 598 | # ARM Compiler 6 - Target ARMv8.2-A - AArch64 |
| 599 | # |
| 600 | # Re-enable MBEDTLS_AESCE_C as this should be supported by the version of armclang |
| 601 | # that we have in our CI |
| 602 | scripts/config.py set MBEDTLS_AESCE_C |
Manuel Pégourié-Gonnard | 8f08bcd | 2024-10-01 13:01:54 +0200 | [diff] [blame] | 603 | helper_armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8.2-a+crypto" |
Minos Galanakis | 07404d2 | 2024-08-01 11:44:57 +0100 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | support_build_armcc () { |
| 607 | armc5_cc="$ARMC5_BIN_DIR/armcc" |
| 608 | armc6_cc="$ARMC6_BIN_DIR/armclang" |
| 609 | (check_tools "$armc5_cc" "$armc6_cc" > /dev/null 2>&1) |
Minos Galanakis | bf47cf7 | 2024-08-01 12:35:25 +0100 | [diff] [blame] | 610 | } |