diff --git a/CMakeLists.txt b/CMakeLists.txt index 3babb3846d..1b83cbf6b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,16 +221,19 @@ endmacro() option(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX "Exclude AVX code from the build" OFF) if(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) add_definitions(-DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) - add_definitions(-DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512) + add_definitions(-DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) message(STATUS "MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX selected, removing AVX optimisations") endif() # Some assemblers know about AVX but not AVX512 instructions, e.g. gcc 4.8.2. # This flag can be set to handle such cases. -option(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512 "Exclude AVX512 code from the build" OFF) -if(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512) - add_definitions(-DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512) - message(STATUS "MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512 selected, removing AVX512 optimisations") +# Note that the flag's name has "512AVX" instead of "AVX512" so that it doesn't +# include the entire flag -DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX and match it +# in the Perl files checks. +option(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX "Exclude AVX512 code from the build" OFF) +if(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + add_definitions(-DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + message(STATUS "MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX selected, removing AVX512 optimisations") endif() # Detect if memcmp is wrongly stripped like strcmp. diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 83ba16f700..1c64967d71 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -79,8 +79,8 @@ if(PERL_EXECUTABLE) set(PERLASM_FLAGS "${PERLASM_FLAGS} -DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX") endif() - if(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512) - set(PERLASM_FLAGS "${PERLASM_FLAGS} -DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512") + if(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + set(PERLASM_FLAGS "${PERLASM_FLAGS} -DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX") endif() add_custom_command( diff --git a/crypto/fipsmodule/modes/asm/aesni-gcm-avx512.pl b/crypto/fipsmodule/modes/asm/aesni-gcm-avx512.pl index 47f54e9c7a..ba69fb6081 100644 --- a/crypto/fipsmodule/modes/asm/aesni-gcm-avx512.pl +++ b/crypto/fipsmodule/modes/asm/aesni-gcm-avx512.pl @@ -49,7 +49,7 @@ $avx512vaes = 1; for (@ARGV) { $avx512vaes = 0 if - (/-DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512/); } + (/-DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX/); } # TODO(awslc, CryptoAlg-1701): fix the script to generate assembly that # can be handled by MSVC2015 linker. Currently, the linker chokes on diff --git a/crypto/fipsmodule/modes/gcm.c b/crypto/fipsmodule/modes/gcm.c index 5e3d4e03d1..e454859a3c 100644 --- a/crypto/fipsmodule/modes/gcm.c +++ b/crypto/fipsmodule/modes/gcm.c @@ -797,7 +797,7 @@ int crypto_gcm_clmul_enabled(void) { int crypto_gcm_avx512_enabled(void) { #if defined(GHASH_ASM_X86_64) && \ !defined(OPENSSL_WINDOWS) && \ - !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512) + !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) // TODO(awslc): remove the Windows guard once CryptoAlg-1701 is resolved. return (CRYPTO_is_VAES_capable() && CRYPTO_is_AVX512_capable() && diff --git a/crypto/fipsmodule/modes/gcm_test.cc b/crypto/fipsmodule/modes/gcm_test.cc index d0ffbd2ec0..2e82abfeea 100644 --- a/crypto/fipsmodule/modes/gcm_test.cc +++ b/crypto/fipsmodule/modes/gcm_test.cc @@ -189,7 +189,7 @@ TEST(GCMTest, ABI) { } } } -#if !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512) +#if !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) if (crypto_gcm_avx512_enabled()) { CHECK_ABI_SEH(gcm_init_avx512, Htable, kH); CHECK_ABI_SEH(gcm_gmult_avx512, X, Htable); @@ -224,7 +224,7 @@ TEST(GCMTest, ABI) { } } } -#endif // !MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512) +#endif // !MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) #endif // GHASH_ASM_X86_64 } #endif // GHASH_ASM_X86 || GHASH_ASM_X86_64 diff --git a/crypto/impl_dispatch_test.cc b/crypto/impl_dispatch_test.cc index ef4cfb8b47..e7d1365308 100644 --- a/crypto/impl_dispatch_test.cc +++ b/crypto/impl_dispatch_test.cc @@ -56,11 +56,11 @@ class ImplDispatchTest : public ::testing::Test { false; #endif // MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX is_assembler_too_old_avx512 = -#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512) +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) true; #else false; -#endif // MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512 +#endif // MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX #endif // X86 || X86_64 } diff --git a/tests/ci/run_posix_tests.sh b/tests/ci/run_posix_tests.sh index ac5bcbc535..0ac68291f9 100755 --- a/tests/ci/run_posix_tests.sh +++ b/tests/ci/run_posix_tests.sh @@ -47,7 +47,7 @@ for build_option in "${build_options_to_test[@]}"; do run_build ${build_option} -DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX=ON done -## Build option: MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512 +## Build option: MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX for build_option in "${build_options_to_test[@]}"; do - run_build ${build_option} -DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX512=ON + run_build ${build_option} -DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX=ON done