mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-20 15:47:57 +00:00
Merge pull request #8339 from lpy4105/issue/support-cpuid-for-win32
Support cpuid for win32
This commit is contained in:
@@ -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.
|
||||||
+5
-3
@@ -33,10 +33,12 @@
|
|||||||
#if defined(MBEDTLS_AESNI_HAVE_CODE)
|
#if defined(MBEDTLS_AESNI_HAVE_CODE)
|
||||||
|
|
||||||
#if MBEDTLS_AESNI_HAVE_CODE == 2
|
#if MBEDTLS_AESNI_HAVE_CODE == 2
|
||||||
#if !defined(_WIN32)
|
#if defined(__GNUC__)
|
||||||
#include <cpuid.h>
|
#include <cpuid.h>
|
||||||
#else
|
#elif defined(_MSC_VER)
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
#else
|
||||||
|
#error "`__cpuid` required by MBEDTLS_AESNI_C is not supported by the compiler"
|
||||||
#endif
|
#endif
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -52,7 +54,7 @@ int mbedtls_aesni_has_support(unsigned int what)
|
|||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
#if MBEDTLS_AESNI_HAVE_CODE == 2
|
#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)
|
#if defined(_MSC_VER)
|
||||||
__cpuid(info, 1);
|
__cpuid(info, 1);
|
||||||
#else
|
#else
|
||||||
|
|||||||
+12
-8
@@ -4689,7 +4689,7 @@ component_test_m32_o0 () {
|
|||||||
# build) and not the i386-specific inline assembly.
|
# build) and not the i386-specific inline assembly.
|
||||||
msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
|
msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
|
||||||
scripts/config.py full
|
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"
|
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS"
|
||||||
|
|
||||||
msg "test: i386, make, gcc -O0 (ASan build)"
|
msg "test: i386, make, gcc -O0 (ASan build)"
|
||||||
@@ -4707,7 +4707,7 @@ component_test_m32_o2 () {
|
|||||||
# and go faster for tests.
|
# and go faster for tests.
|
||||||
msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
|
msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
|
||||||
scripts/config.py full
|
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"
|
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
|
||||||
|
|
||||||
msg "test: i386, make, gcc -O2 (ASan build)"
|
msg "test: i386, make, gcc -O2 (ASan build)"
|
||||||
@@ -4723,7 +4723,7 @@ support_test_m32_o2 () {
|
|||||||
component_test_m32_everest () {
|
component_test_m32_everest () {
|
||||||
msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
|
msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
|
||||||
scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
|
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"
|
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
|
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 () {
|
component_build_mingw () {
|
||||||
msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
|
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 -maes -msse2 -mpclmul' 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' WINDOWS_BUILD=1 lib programs
|
|
||||||
|
|
||||||
# note Make tests only builds the tests, but doesn't run them
|
# 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
|
make WINDOWS_BUILD=1 clean
|
||||||
|
|
||||||
msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
|
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 -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' 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 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
|
make WINDOWS_BUILD=1 clean
|
||||||
}
|
}
|
||||||
support_build_mingw() {
|
support_build_mingw() {
|
||||||
|
|||||||
Reference in New Issue
Block a user