@@ -128,6 +128,9 @@ pre_initialize_variables () {
128
128
# Include more verbose output for failing tests run by CMake
129
129
export CTEST_OUTPUT_ON_FAILURE=1
130
130
131
+ # CFLAGS and LDFLAGS for Asan builds that don't use CMake
132
+ ASAN_CFLAGS=' -Werror -Wall -Wextra -fsanitize=address,undefined -fno-sanitize-recover=all'
133
+
131
134
# Gather the list of available components. These are the functions
132
135
# defined in this script whose name starts with "component_".
133
136
# Parse the script with sed, because in sh there is no way to list
@@ -826,7 +829,7 @@ component_test_malloc_0_null () {
826
829
msg " build: malloc(0) returns NULL (ASan+UBSan build)"
827
830
scripts/config.pl full
828
831
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
829
- make CC=gcc CFLAGS=" '-DMBEDTLS_CONFIG_FILE=\" $PWD /tests/configs/config-wrapper-malloc-0-null.h\" ' -O -Werror -Wall -Wextra -fsanitize=address,undefined " LDFLAGS=' -fsanitize=address,undefined '
832
+ make CC=gcc CFLAGS=" '-DMBEDTLS_CONFIG_FILE=\" $PWD /tests/configs/config-wrapper-malloc-0-null.h\" ' $ASAN_CFLAGS -O " LDFLAGS=" $ASAN_CFLAGS "
830
833
831
834
msg " test: malloc(0) returns NULL (ASan+UBSan build)"
832
835
make test
@@ -868,7 +871,7 @@ component_test_aes_fewer_tables_and_rom_tables () {
868
871
component_test_se_default () {
869
872
msg " build: default config + MBEDTLS_PSA_CRYPTO_SE_C"
870
873
scripts/config.pl set MBEDTLS_PSA_CRYPTO_SE_C
871
- make CC=clang CFLAGS=' -Werror -Wall -Wextra -Wno-unused-function -Os -fsanitize=address ' LDFLAGS=' -fsanitize=address '
874
+ make CC=clang CFLAGS=" $ASAN_CFLAGS -Os " LDFLAGS=" $ASAN_CFLAGS "
872
875
873
876
msg " test: default config + MBEDTLS_PSA_CRYPTO_SE_C"
874
877
make test
@@ -877,7 +880,7 @@ component_test_se_default () {
877
880
component_test_se_full () {
878
881
msg " build: full config + MBEDTLS_PSA_CRYPTO_SE_C"
879
882
scripts/config.pl set MBEDTLS_PSA_CRYPTO_SE_C
880
- make CC=gcc CFLAGS=' -Werror -Wall -Wextra -O2 -fsanitize=address ' LDFLAGS=' -fsanitize=address '
883
+ make CC=gcc CFLAGS=" $ASAN_CFLAGS -O2 " LDFLAGS=" $ASAN_CFLAGS "
881
884
882
885
msg " test: full config + MBEDTLS_PSA_CRYPTO_SE_C"
883
886
make test
@@ -912,7 +915,7 @@ component_test_m32_o0 () {
912
915
# Build once with -O0, to compile out the i386 specific inline assembly
913
916
msg " build: i386, make, gcc -O0 (ASan build)" # ~ 30s
914
917
scripts/config.pl full
915
- make CC=gcc CFLAGS=' -O0 -Werror -Wall -Wextra - m32 -fsanitize=address ' LDFLAGS=' -m32 -fsanitize=address '
918
+ make CC=gcc CFLAGS=" $ASAN_CFLAGS - m32 -O0 " LDFLAGS=" -m32 $ASAN_CFLAGS "
916
919
917
920
msg " test: i386, make, gcc -O0 (ASan build)"
918
921
make test
@@ -931,7 +934,7 @@ component_test_m32_o1 () {
931
934
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE
932
935
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
933
936
scripts/config.pl unset MBEDTLS_MEMORY_DEBUG
934
- make CC=gcc CFLAGS=' -O1 -Werror -Wall -Wextra - m32 -fsanitize=address ' LDFLAGS=' -m32 -fsanitize=address '
937
+ make CC=gcc CFLAGS=" $ASAN_CFLAGS - m32 -O1 " LDFLAGS=" -m32 $ASAN_CFLAGS "
935
938
936
939
msg " test: i386, make, gcc -O1 (ASan build)"
937
940
make test
@@ -944,7 +947,7 @@ component_test_m32_everest () {
944
947
msg " build: i386, Everest ECDH context (ASan build)" # ~ 6 min
945
948
scripts/config.pl unset MBEDTLS_ECDH_LEGACY_CONTEXT
946
949
scripts/config.pl set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
947
- make CC=gcc CFLAGS=' -O2 -Werror -Wall -Wextra - m32 -fsanitize=address '
950
+ make CC=gcc CFLAGS=" $ASAN_CFLAGS -m32 -O2 " LDFLAGS= " - m32 $ASAN_CFLAGS "
948
951
949
952
msg " test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
950
953
make test
0 commit comments