Skip to content

Commit

Permalink
Change the flag name to end with "512AVX"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nebeid committed Apr 12, 2023
1 parent 051e1da commit ff7eeb0
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/modes/asm/aesni-gcm-avx512.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/modes/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() &&
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/modes/gcm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crypto/impl_dispatch_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ci/run_posix_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ff7eeb0

Please sign in to comment.