From 63e38c3a805ee605a2fde026c8e5a93f1c3e4bcd Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Mon, 9 Sep 2024 15:02:55 -0700 Subject: [PATCH 1/2] Always set -msse2 CFLAG when compiling for 32-bit x86 --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a61aff67b4..529fa7d9d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -824,6 +824,15 @@ else() set(ARCH "generic") endif() +# Require SSE2 when targetting 32-bit x86. +# SS2 is usually enabled by default for GCC and Clang, but not always. +# See: https://github.com/aws/aws-lc/commit/6fe8dcbe96e580ea85233fdb98a142e42951b70b +if(ARCH STREQUAL "x86" AND NOT OPENSSL_NO_SSE2_FOR_TESTING) + if(GCC OR CLANG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2") + endif() +endif() + if(ENABLE_DATA_INDEPENDENT_TIMING_AARCH64) add_definitions(-DMAKE_DIT_AVAILABLE) endif() From b8942d53b1ade5311ef38b898b4dc006ad5e417b Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Tue, 10 Sep 2024 11:46:37 -0700 Subject: [PATCH 2/2] Include instructions for disabling SSE2 --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 529fa7d9d1..6152e91bb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -824,10 +824,11 @@ else() set(ARCH "generic") endif() -# Require SSE2 when targetting 32-bit x86. -# SS2 is usually enabled by default for GCC and Clang, but not always. -# See: https://github.com/aws/aws-lc/commit/6fe8dcbe96e580ea85233fdb98a142e42951b70b +# If target ARCH is 32-bit x86, ensure SSE2 is enabled since it's used by the optimized assembly. +# To build for targets that do not support SSE2, use the `OPENSSL_NO_ASM` flag. if(ARCH STREQUAL "x86" AND NOT OPENSSL_NO_SSE2_FOR_TESTING) + # Most compilers enable SSE2 in 32-bit x86 by default, but in some cases GCC and Clang don't. + # See: https://github.com/aws/aws-lc/commit/6fe8dcbe96e580ea85233fdb98a142e42951b70b if(GCC OR CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2") endif()