From 6fa69864a2a8285bf6a42c9bc3ed9b8eb1ba6307 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 5 Oct 2021 09:36:03 +0200 Subject: [PATCH 1/6] Build with -O2 when running ssl-opt SSL testing benefits from faster executables, so use -O2 rather than -O1. Some builds use -O1, but that's intended for jobs that only run unit tests, where the build takes longer than the tests. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 07503a2cc..0cad8bd57 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -954,7 +954,7 @@ component_test_psa_crypto_client () { component_test_zlib_make() { msg "build: zlib enabled, make" scripts/config.py set MBEDTLS_ZLIB_SUPPORT - make ZLIB=1 CFLAGS='-Werror -O1' + make ZLIB=1 CFLAGS='-Werror -O2' msg "test: main suites (zlib, make)" make test @@ -2468,7 +2468,7 @@ component_build_mbedtls_config_file () { } component_test_m32_o0 () { - # Build once with -O0, to compile out the i386 specific inline assembly + # Build without optimization, to not use the i386 specific inline assembly. msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s scripts/config.py full make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS" @@ -2483,16 +2483,17 @@ support_test_m32_o0 () { esac } -component_test_m32_o1 () { - # Build again with -O1, to compile in the i386 specific inline assembly - msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s +component_test_m32_o2 () { + # Build with optimization, to use the i386 specific inline assembly + # and go faster for tests. + msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s scripts/config.py full - make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O1" LDFLAGS="-m32 $ASAN_CFLAGS" + make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS" - msg "test: i386, make, gcc -O1 (ASan build)" + msg "test: i386, make, gcc -O2 (ASan build)" make test - msg "test ssl-opt.sh, i386, make, gcc-O1" + msg "test ssl-opt.sh, i386, make, gcc-O2" tests/ssl-opt.sh } support_test_m32_o1 () { From 3daa83e99a368a15b554ff0c76fd3559dfa32e91 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 7 Oct 2021 19:25:29 +0200 Subject: [PATCH 2/6] Correct support function name Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 0cad8bd57..ee8460eee 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2496,7 +2496,7 @@ component_test_m32_o2 () { msg "test ssl-opt.sh, i386, make, gcc-O2" tests/ssl-opt.sh } -support_test_m32_o1 () { +support_test_m32_o2 () { support_test_m32_o0 "$@" } From a0c51fb53ec288dd8272c035d3ef2db4c0e05942 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 7 Oct 2021 19:27:16 +0200 Subject: [PATCH 3/6] Clarify a comment Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index ee8460eee..b2f32fd84 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2468,7 +2468,8 @@ component_build_mbedtls_config_file () { } component_test_m32_o0 () { - # Build without optimization, to not use the i386 specific inline assembly. + # Build without optimization, so as to use portable C code (in a 32-bit + # build) and not the i386-specific inline assembly. msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s scripts/config.py full make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS" From 2531970772e3a1dfddd70f9305eff0130e1d34c7 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 7 Oct 2021 19:34:57 +0200 Subject: [PATCH 4/6] Switch cmake -O2 builds around to where we test a lot Use Release mode (-O2) for component_test_full_cmake_clang which runs SSL tests. To have some coverage with Check mode (which enables more compiler warnings but compiles with -Os), change a few other builds that only run unit tests at most to Check mode. Don't add any new builds, to keep the total build volume down. We don't need extensive coverage of all combinations, just a reasonable set. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index b2f32fd84..adad56d2a 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -977,7 +977,7 @@ EOF component_test_zlib_cmake() { msg "build: zlib enabled, cmake" scripts/config.py set MBEDTLS_ZLIB_SUPPORT - cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Check . + cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Release . make msg "test: main suites (zlib, cmake)" @@ -1375,7 +1375,7 @@ component_test_psa_collect_statuses () { component_test_full_cmake_clang () { msg "build: cmake, full config, clang" # ~ 50s scripts/config.py full - CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . + CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release -D ENABLE_TESTING=On . make msg "test: main suites (full config, clang)" # ~ 5s @@ -2085,7 +2085,8 @@ component_build_no_std_function () { scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT - make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check + make } component_build_no_ssl_srv () { @@ -2287,7 +2288,7 @@ component_test_null_entropy () { component_test_no_date_time () { msg "build: default config without MBEDTLS_HAVE_TIME_DATE" scripts/config.py unset MBEDTLS_HAVE_TIME_DATE - CC=gcc cmake + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check make msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites" @@ -2779,7 +2780,7 @@ component_test_cmake_out_of_source () { MBEDTLS_ROOT_DIR="$PWD" mkdir "$OUT_OF_SOURCE_DIR" cd "$OUT_OF_SOURCE_DIR" - cmake "$MBEDTLS_ROOT_DIR" + cmake -D CMAKE_BUILD_TYPE:String=Check "$MBEDTLS_ROOT_DIR" make msg "test: cmake 'out-of-source' build" From 31fdda12624c2f449c7cdeb23a28c06f5624123d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 8 Oct 2021 11:45:47 +0200 Subject: [PATCH 5/6] Fix cmake invocation syntax Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index adad56d2a..e5d03b74b 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2085,7 +2085,7 @@ component_build_no_std_function () { scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT - CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . make } @@ -2288,7 +2288,7 @@ component_test_null_entropy () { component_test_no_date_time () { msg "build: default config without MBEDTLS_HAVE_TIME_DATE" scripts/config.py unset MBEDTLS_HAVE_TIME_DATE - CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . make msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites" From ff30bd01117ef8d0d9e3273f3671b1cfa8954f6e Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 19 Oct 2021 21:33:32 +0200 Subject: [PATCH 6/6] Always set a build type for cmake when building for testing Set the build type to Release (-O2) when running CPU-intensive tests (ssl-opt, or unit tests with debug features). A build type of Check (-Os) would be best when the main objective of the build is to check for build errors or warnings and there aren't many tests to run; in this commit there are no such test cases to change. Only use cmake with no build type (which results in not passing a -O option, and thus missing some GCC warnings) when exercising cmake features. Signed-off-by: Gilles Peskine --- tests/scripts/all.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index e5d03b74b..aefe0295f 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -2119,7 +2119,7 @@ component_test_memory_buffer_allocator_backtrace () { scripts/config.py set MBEDTLS_PLATFORM_MEMORY scripts/config.py set MBEDTLS_MEMORY_BACKTRACE scripts/config.py set MBEDTLS_MEMORY_DEBUG - CC=gcc cmake . + CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . make msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" @@ -2130,7 +2130,7 @@ component_test_memory_buffer_allocator () { msg "build: default config with memory buffer allocator" scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C scripts/config.py set MBEDTLS_PLATFORM_MEMORY - CC=gcc cmake . + CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . make msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" @@ -2245,7 +2245,7 @@ component_test_ssl_alloc_buffer_and_mfl () { scripts/config.py set MBEDTLS_MEMORY_DEBUG scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH - CC=gcc cmake . + CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . make msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"