Commit 5ba4c420 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-25870 Windows - fix ARM64 cross-compilation

parent 233590a4
......@@ -24,6 +24,14 @@ INCLUDE (CheckCSourceRuns)
INCLUDE (CheckSymbolExists)
INCLUDE (CheckTypeSize)
IF(MSVC)
IF(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL ARM64)
SET(MSVC_ARM64 1)
SET(MSVC_INTEL 0)
ELSE()
SET(MSVC_INTEL 1)
ENDIF()
ENDIF()
# avoid running system checks by using pre-cached check results
# system checks are expensive on VS since every tiny program is to be compiled in
......
......@@ -38,7 +38,10 @@ IF(NOT VERSION)
SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0)
SET(DEFAULT_PLATFORM "win")
IF(64BIT)
SET(DEFAULT_MACHINE "x64")
STRING(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" DEFAULT_MACHINE)
IF(NOT DEFAULT_MACHINE)
SET(DEFAULT_MACHINE "x64")
ENDIF()
ELSE()
SET(DEFAULT_MACHINE "32")
ENDIF()
......
IF(MSVC)
IF(MSVC_INTEL)
PROJECT(wolfssl C ASM_MASM)
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
PROJECT(wolfssl C ASM)
......@@ -7,7 +7,7 @@ ELSE()
ENDIF()
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
IF(MSVC)
IF(MSVC_INTEL)
SET(WOLFSSL_INTELASM ON)
SET(WOLFSSL_X86_64_BUILD 1)
SET(HAVE_INTEL_RDSEED 1)
......
......@@ -31,10 +31,10 @@
format (low byte first). There are 'korr' (assume 'corrector') variants
for integer types, but 'get' (assume 'getter') for floating point types.
*/
#if (defined(__i386__) || defined(_WIN32)) && !defined(WITH_UBSAN)
#if (defined(__i386__) || defined(_M_IX86)) && !defined(WITH_UBSAN)
#define MY_BYTE_ORDER_ARCH_OPTIMIZED
#include "byte_order_generic_x86.h"
#elif defined(__x86_64__) && !defined(WITH_UBSAN)
#elif (defined(__x86_64__) || defined (_M_X64)) && !defined(WITH_UBSAN)
#include "byte_order_generic_x86_64.h"
#else
#include "byte_order_generic.h"
......
......@@ -130,8 +130,10 @@ static inline ulonglong my_timer_cycles(void)
{
# if __has_builtin(__builtin_readcyclecounter) && !defined (__aarch64__)
return __builtin_readcyclecounter();
# elif defined _WIN32 || defined __i386__ || defined __x86_64__
# elif defined _M_IX86 || defined _M_X64 || defined __i386__ || defined __x86_64__
return __rdtsc();
#elif defined _M_ARM64
return _ReadStatusReg(ARM64_CNTVCT);
# elif defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H)
return (ulonglong) __getReg(_IA64_REG_AR_ITC); /* (3116) */
#elif defined(__GNUC__) && defined(__ia64__)
......
......@@ -58,7 +58,7 @@ IF (WIN32)
my_win_popen.cc)
ENDIF()
IF(MSVC)
IF(MSVC_INTEL)
SET(MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32_x86.c)
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET (MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32c_amd64.cc)
......
......@@ -80,7 +80,8 @@ int my_delete(const char *name, myf MyFlags)
a file to unique name.
Symbolic link are deleted without renaming. Directories are not deleted.
*/
*/
#include <my_rdtsc.h>
static int my_win_unlink(const char *name)
{
HANDLE handle= INVALID_HANDLE_VALUE;
......@@ -166,7 +167,7 @@ static int my_win_unlink(const char *name)
goto error;
}
tsc= __rdtsc();
tsc= my_timer_cycles();
my_snprintf(unique_filename,sizeof(unique_filename),"%s.%llx.deleted",
name, tsc);
if (!MoveFile(name, unique_filename))
......
......@@ -587,8 +587,12 @@ void my_print_stacktrace(uchar* unused1, ulong unused2, my_bool silent)
frame.AddrFrame.Offset= context.Rbp;
frame.AddrPC.Offset= context.Rip;
frame.AddrStack.Offset= context.Rsp;
#elif defined(_M_ARM64)
machine= IMAGE_FILE_MACHINE_ARM64;
frame.AddrFrame.Offset= context.Fp;
frame.AddrPC.Offset= context.Pc;
frame.AddrStack.Offset= context.Sp;
#else
/*There is currently no need to support IA64*/
#pragma error ("unsupported architecture")
#endif
......
......@@ -2475,7 +2475,7 @@ __forceinline unsigned int nlz (ulonglong x)
return (unsigned int) n ^ m;
#endif
#elif defined(_M_ARM64)
return _CountLeadingZeros(x);
return _CountLeadingZeros64(x);
#endif
}
#else
......
......@@ -487,14 +487,21 @@ it is read or written. */
# define UNIV_PREFETCH_RW(addr) ((void) 0)
# endif /* COMPILER_HINTS */
# elif defined _WIN32 && defined COMPILER_HINTS
# include <xmmintrin.h>
# elif defined _MSC_VER && defined COMPILER_HINTS
# define UNIV_EXPECT(expr,value) (expr)
# define UNIV_LIKELY_NULL(expr) (expr)
// __MM_HINT_T0 - (temporal data)
// prefetch data into all levels of the cache hierarchy.
# define UNIV_PREFETCH_R(addr) _mm_prefetch((char *) addr, _MM_HINT_T0)
# define UNIV_PREFETCH_RW(addr) _mm_prefetch((char *) addr, _MM_HINT_T0)
# if defined _M_IX86 || defined _M_X64
// __MM_HINT_T0 - (temporal data)
// prefetch data into all levels of the cache hierarchy.
# define UNIV_PREFETCH_R(addr) _mm_prefetch((char *) addr, _MM_HINT_T0)
# define UNIV_PREFETCH_RW(addr) _mm_prefetch((char *) addr, _MM_HINT_T0)
# elif defined _M_ARM64
# define UNIV_PREFETCH_R(addr) __prefetch(addr)
# define UNIV_PREFETCH_RW(addr) __prefetch(addr)
# else
# define UNIV_PREFETCH_R ((void) 0)
# define UNIV_PREFETCH_RW(addr) ((void) 0)
# endif
#else
/* Dummy versions of the macros */
# define UNIV_EXPECT(expr,value) (expr)
......
......@@ -42,6 +42,9 @@ endif()
IF (WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
SKIP_ROCKSDB_PLUGIN("32-Bit Windows are temporarily disabled")
ENDIF()
IF(MSVC_ARM64)
SKIP_ROCKSDB_PLUGIN("Windows ARM64 not supported")
ENDIF()
# This plugin needs recent C++ compilers (it is using C++11 features)
# Skip build for the old compilers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment