mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2025-12-06 07:12:32 +01:00
Merge pull request #8339 from lpy4105/issue/support-cpuid-for-win32
Support cpuid for win32
This commit is contained in:
commit
235e361b6c
4
ChangeLog.d/fix-mingw32-build.txt
Normal file
4
ChangeLog.d/fix-mingw32-build.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Bugfix
|
||||
* Fix an inconsistency between implementations and usages of `__cpuid`,
|
||||
which mainly causes failures when building Windows target using
|
||||
mingw or clang. Fixes #8334 & #8332.
|
||||
|
|
@ -33,10 +33,12 @@
|
|||
#if defined(MBEDTLS_AESNI_HAVE_CODE)
|
||||
|
||||
#if MBEDTLS_AESNI_HAVE_CODE == 2
|
||||
#if !defined(_WIN32)
|
||||
#if defined(__GNUC__)
|
||||
#include <cpuid.h>
|
||||
#else
|
||||
#elif defined(_MSC_VER)
|
||||
#include <intrin.h>
|
||||
#else
|
||||
#error "`__cpuid` required by MBEDTLS_AESNI_C is not supported by the compiler"
|
||||
#endif
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
|
|
@ -52,7 +54,7 @@ int mbedtls_aesni_has_support(unsigned int what)
|
|||
|
||||
if (!done) {
|
||||
#if MBEDTLS_AESNI_HAVE_CODE == 2
|
||||
static unsigned info[4] = { 0, 0, 0, 0 };
|
||||
static int info[4] = { 0, 0, 0, 0 };
|
||||
#if defined(_MSC_VER)
|
||||
__cpuid(info, 1);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -4689,7 +4689,7 @@ component_test_m32_o0 () {
|
|||
# build) and not the i386-specific inline assembly.
|
||||
msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI depends on cpu modifiers
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS"
|
||||
|
||||
msg "test: i386, make, gcc -O0 (ASan build)"
|
||||
|
|
@ -4707,7 +4707,7 @@ component_test_m32_o2 () {
|
|||
# and go faster for tests.
|
||||
msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI depends on cpu modifiers
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
|
||||
|
||||
msg "test: i386, make, gcc -O2 (ASan build)"
|
||||
|
|
@ -4723,7 +4723,7 @@ support_test_m32_o2 () {
|
|||
component_test_m32_everest () {
|
||||
msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
|
||||
scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI depends on cpu modifiers
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32
|
||||
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
|
||||
|
||||
msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
|
||||
|
|
@ -5177,16 +5177,20 @@ component_test_tls13_only_record_size_limit () {
|
|||
|
||||
component_build_mingw () {
|
||||
msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
|
||||
scripts/config.py unset MBEDTLS_AESNI_C # AESNI depends on cpu modifiers
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra -maes -msse2 -mpclmul' WINDOWS_BUILD=1 lib programs
|
||||
|
||||
# note Make tests only builds the tests, but doesn't run them
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -maes -msse2 -mpclmul' WINDOWS_BUILD=1 tests
|
||||
make WINDOWS_BUILD=1 clean
|
||||
|
||||
msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra -maes -msse2 -mpclmul' WINDOWS_BUILD=1 SHARED=1 lib programs
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra -maes -msse2 -mpclmul' WINDOWS_BUILD=1 SHARED=1 tests
|
||||
make WINDOWS_BUILD=1 clean
|
||||
|
||||
msg "build: Windows cross build - mingw64, make (Library only, default config without MBEDTLS_AESNI_C)" # ~ 30s
|
||||
./scripts/config.py unset MBEDTLS_AESNI_C #
|
||||
make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib
|
||||
make WINDOWS_BUILD=1 clean
|
||||
}
|
||||
support_build_mingw() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue