From 8ec790afb233daadb6a7b2072c22f0f1d84af05d Mon Sep 17 00:00:00 2001 From: Kieron Briggs Date: Mon, 31 Aug 2015 15:40:31 +1000 Subject: [PATCH 1/7] Bug #78282 - MySQL 5.6 fails to compile with Visual Studio 2015 VS2015 (finally) defines snprintf(), and throws an error if it is #define'd; set it as present in the cmake config for VS>=1900. --- cmake/os/WindowsCache.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index a1764ad..f54b148 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -231,7 +231,11 @@ SET(HAVE_SIZEOF_ULONG FALSE CACHE INTERNAL "") SET(HAVE_SIZEOF_U_INT32_T FALSE CACHE INTERNAL "") SET(HAVE_SIZE_OF_SSIZE_T FALSE CACHE INTERNAL "") SET(HAVE_SLEEP CACHE INTERNAL "") +IF(MSVC_VERSION LESS 1900) SET(HAVE_SNPRINTF CACHE INTERNAL "") +ELSE() +SET(HAVE_SNPRINTF CACHE 1 INTERNAL "") +ENDIF() SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "") SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "") SET(HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 CACHE INTERNAL "") From 403a83e4e126ed1947acd66e3c2b31f7b376213c Mon Sep 17 00:00:00 2001 From: Kieron Briggs Date: Mon, 31 Aug 2015 16:24:10 +1000 Subject: [PATCH 2/7] Bug #78282 - MySQL 5.6 fails to compile with Visual Studio 2015 VS2015 now has struct timespec, so we can use it instead of our own structure. --- include/my_pthread.h | 2 ++ mysys/my_wincond.c | 13 ++++++++++++- plugin/semisync/semisync_master.cc | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index 4e099c7..cbdbb15 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -90,6 +90,7 @@ typedef volatile LONG my_pthread_once_t; windows implementation of pthread_cond_timedwait */ +#if _MSC_VER < 1900 /* Declare a union to make sure FILETIME is properly aligned so it can be used directly as a 64 bit value. The value @@ -130,6 +131,7 @@ struct timespec { #define diff_timespec(TS1, TS2) \ ((TS1.tv.i64 - TS2.tv.i64) * 100) +#endif int win_pthread_mutex_trylock(pthread_mutex_t *mutex); int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *); diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 15131f8..a64a18d 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -89,11 +89,16 @@ static void check_native_cond_availability(void) static DWORD get_milliseconds(const struct timespec *abstime) { long long millis; +#if _MSC_VER < 1900 union ft64 now; +#else + struct timespec n; +#endif if (abstime == NULL) return INFINITE; +#if _MSC_VER < 1900 GetSystemTimeAsFileTime(&now.ft); /* @@ -102,17 +107,23 @@ static DWORD get_milliseconds(const struct timespec *abstime) - convert to millisec by dividing with 10000 */ millis= (abstime->tv.i64 - now.i64) / 10000; - +#else + set_timespec(n, 0); + millis= diff_timespec((*abstime), n) / 1000000; +#endif + /* Don't allow the timeout to be negative */ if (millis < 0) return 0; +#if _MSC_VER < 1900 /* Make sure the calculated timeout does not exceed original timeout value which could cause "wait for ever" if system time changes */ if (millis > abstime->max_timeout_msec) millis= abstime->max_timeout_msec; +#endif if (millis > UINT_MAX) millis= UINT_MAX; diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc index 76ea7f0..5d48c48 100644 --- a/plugin/semisync/semisync_master.cc +++ b/plugin/semisync/semisync_master.cc @@ -51,7 +51,7 @@ static int getWaitTime(const struct timespec& start_ts); static unsigned long long timespec_to_usec(const struct timespec *ts) { -#ifndef __WIN__ +#if (!defined(__WIN__) || _MSC_VER >= 1900) return (unsigned long long) ts->tv_sec * TIME_MILLION + ts->tv_nsec / TIME_THOUSAND; #else return ts->tv.i64 / 10; @@ -702,7 +702,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, } /* Calcuate the waiting period. */ -#ifdef __WIN__ +#if (defined(__WIN__) && _MSC_VER < 1900) abstime.tv.i64 = start_ts.tv.i64 + (__int64)wait_timeout_ * TIME_THOUSAND * 10; abstime.max_timeout_msec= (long)wait_timeout_; #else From 40aa8d114ff4aed4d5843c786fa2fe610e9e632b Mon Sep 17 00:00:00 2001 From: Kieron Briggs Date: Mon, 31 Aug 2015 16:26:08 +1000 Subject: [PATCH 3/7] Bug #78282 - MySQL 5.6 fails to compile with Visual Studio 2015 VS2015 defines lfind() and lsearch() in ; use nonconflicting names for the local functions in lf_hash.c. --- mysys/lf_hash.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index 64abbf7..120e8fa 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -45,7 +45,7 @@ const int LF_HASH_OVERHEAD= sizeof(LF_SLIST); /* a structure to pass the context (pointers two the three successive elements - in a list) from lfind to linsert/ldelete + in a list) from lf_lfind to linsert/ldelete */ typedef struct { intptr volatile *prev; @@ -72,7 +72,7 @@ typedef struct { cursor is positioned in either case pins[0..2] are used, they are NOT removed on return */ -static int lfind(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, +static int lf_lfind(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, const uchar *key, uint keylen, CURSOR *cursor, LF_PINS *pins) { uint32 cur_hashnr; @@ -140,7 +140,7 @@ static int lfind(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, /* DESCRIPTION insert a 'node' in the list that starts from 'head' in the correct - position (as found by lfind) + position (as found by lf_lfind) RETURN 0 - inserted @@ -158,7 +158,7 @@ static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs, for (;;) { - if (lfind(head, cs, node->hashnr, node->key, node->keylen, + if (lf_lfind(head, cs, node->hashnr, node->key, node->keylen, &cursor, pins) && (flags & LF_HASH_UNIQUE)) { @@ -209,7 +209,7 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, for (;;) { - if (!lfind(head, cs, hashnr, key, keylen, &cursor, pins)) + if (!lf_lfind(head, cs, hashnr, key, keylen, &cursor, pins)) { res= 1; /* not found */ break; @@ -233,7 +233,7 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, (to ensure the number of "set DELETED flag" actions is equal to the number of "remove from the list" actions) */ - lfind(head, cs, hashnr, key, keylen, &cursor, pins); + lf_lfind(head, cs, hashnr, key, keylen, &cursor, pins); } res= 0; break; @@ -259,12 +259,12 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, it uses pins[0..2], on return the pin[2] keeps the node found all other pins are removed. */ -static LF_SLIST *lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs, +static LF_SLIST *lf_lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr, const uchar *key, uint keylen, LF_PINS *pins) { CURSOR cursor; - int res= lfind(head, cs, hashnr, key, keylen, &cursor, pins); + int res= lf_lfind(head, cs, hashnr, key, keylen, &cursor, pins); if (res) _lf_pin(pins, 2, cursor.curr); _lf_unpin(pins, 0); @@ -445,7 +445,7 @@ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) MY_ERRPTR if OOM NOTE - see lsearch() for pin usage notes + see lf_lsearch() for pin usage notes */ void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) { @@ -459,7 +459,7 @@ void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen) return MY_ERRPTR; if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins))) return MY_ERRPTR; - found= lsearch(el, hash->charset, my_reverse_bits(hashnr) | 1, + found= lf_lsearch(el, hash->charset, my_reverse_bits(hashnr) | 1, (uchar *)key, keylen, pins); lf_rwunlock_by_pins(pins); return found ? found+1 : 0; @@ -520,7 +520,7 @@ static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node, @retval 1 - found */ -static int lfind_match(LF_SLIST * volatile *head, +static int lf_lfind_match(LF_SLIST * volatile *head, uint32 first_hashnr, uint32 last_hashnr, lf_hash_match_func *match, CURSOR *cursor, LF_PINS *pins) @@ -659,7 +659,7 @@ void *lf_hash_random_match(LF_HASH *hash, LF_PINS *pins, looking for elements with inversed hash value greater or equal than inversed value of our random hash. */ - res= lfind_match(el, rev_hashnr | 1, UINT_MAX32, match, &cursor, pins); + res= lf_lfind_match(el, rev_hashnr | 1, UINT_MAX32, match, &cursor, pins); if (! res && hashnr != 0) { @@ -676,7 +676,7 @@ void *lf_hash_random_match(LF_HASH *hash, LF_PINS *pins, el= lf_dynarray_lvalue(&hash->array, 0); if (unlikely(!el)) return MY_ERRPTR; - res= lfind_match(el, 1, rev_hashnr, match, &cursor, pins); + res= lf_lfind_match(el, 1, rev_hashnr, match, &cursor, pins); } if (res) From d1fdead8db6167322bf1dcc58ea9e2a7d7a81267 Mon Sep 17 00:00:00 2001 From: Kieron Briggs Date: Mon, 31 Aug 2015 16:42:54 +1000 Subject: [PATCH 4/7] Backport Fix compillation errors when using WITH_PERFSCHEMA_STORAGE_ENGINE=0 Backported from commit 255cafbe76bd2736cede1ec1991cc8d0deb420d5. --- storage/innobase/srv/srv0mon.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index 80c8f7f..e3239d0 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1232,8 +1232,10 @@ UNIV_INTERN ulint monitor_set_tbl[(NUM_MONITOR + NUM_BITS_ULINT built-in operations for atomic memory access */ ib_mutex_t monitor_mutex; +#ifdef HAVE_PSI_INTERFACE /** Key to register monitor_mutex with performance schema */ UNIV_INTERN mysql_pfs_key_t monitor_mutex_key; +#endif /****************************************************************//** Initialize the monitor subsystem. */ From fe2dcfe39b6007f6c6db2522dab5ba1320e4f38a Mon Sep 17 00:00:00 2001 From: Kieron Briggs Date: Mon, 31 Aug 2015 17:54:28 +1000 Subject: [PATCH 5/7] Bug #78282 - MySQL 5.6 fails to compile with Visual Studio 2015 VS2015 no longer defines tname, only _tzname. --- cmake/os/Windows.cmake | 1 + cmake/os/WindowsCache.cmake | 5 +++++ config.h.cmake | 1 + 3 files changed, 7 insertions(+) diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index d320bf3..4586879b 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -184,6 +184,7 @@ CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h) CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h) CHECK_SYMBOL_REPLACEMENT(isnan _isnan float.h) CHECK_SYMBOL_REPLACEMENT(finite _finite float.h) +CHECK_SYMBOL_REPLACEMENT(tzname _tzname time.h) CHECK_FUNCTION_REPLACEMENT(popen _popen) CHECK_FUNCTION_REPLACEMENT(pclose _pclose) CHECK_FUNCTION_REPLACEMENT(access _access) diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index f54b148..2b3320d 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -310,7 +310,11 @@ SET(HAVE_TIME 1 CACHE INTERNAL "") SET(HAVE_TIMES CACHE INTERNAL "") SET(HAVE_TIMESPEC_TS_SEC CACHE INTERNAL "") SET(HAVE_TIME_H 1 CACHE INTERNAL "") +IF(MSVC_VERSION LESS 1900) SET(HAVE_TZNAME 1 CACHE INTERNAL "") +ELSE() +SET(HAVE_TZNAME CACHE INTERNAL "") +ENDIF() SET(HAVE_UNISTD_H CACHE INTERNAL "") SET(HAVE_UTIME_H CACHE INTERNAL "") SET(HAVE_VALLOC CACHE INTERNAL "") @@ -337,6 +341,7 @@ SET(HAVE__strtoui64 1 CACHE INTERNAL "") IF(MSVC_VERSION GREATER 1310) SET(HAVE_strtok_s 1 CACHE INTERNAL "") ENDIF() +SET(HAVE__tzname 1 CACHE INTERNAL "") SET(STDC_HEADERS CACHE 1 INTERNAL "") SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "") SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "") diff --git a/config.h.cmake b/config.h.cmake index 987be27..c4c6202 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -517,6 +517,7 @@ #cmakedefine strtok_r @strtok_r@ #cmakedefine strtoll @strtoll@ #cmakedefine strtoull @strtoull@ +#cmakedefine tzname @tzname@ #cmakedefine vsnprintf @vsnprintf@ #if (_MSC_VER > 1310) # define HAVE_SETENV From b69bc34d017e46d065256cafec40f6e069afdfb1 Mon Sep 17 00:00:00 2001 From: Kieron Briggs Date: Tue, 1 Sep 2015 12:40:28 +1000 Subject: [PATCH 6/7] Bug #78282 - MySQL 5.6 fails to compile with Visual Studio 2015 Set /Zc:inline- on my_time.c. VS2015 sets /Zc:inline (do not emit symbols for inline function definitions, per C++11 standard) by default, even for C (not C++) files apparently. Since my_time.c defines some functions as inline, we need to switch off this behaviour for that file. --- libmysql/CMakeLists.txt | 7 +++++++ libmysqld/CMakeLists.txt | 7 +++++++ sql/CMakeLists.txt | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 16a6a5e..59676c2 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -163,6 +163,13 @@ IF (WIN32 AND OPENSSL_APPLINK_C) ) ENDIF() +IF (WIN32 AND MSVC_VERSION GREATER 1820) + SET_SOURCE_FILES_PROPERTIES( + ../sql-common/my_time.c + PROPERTIES COMPILE_FLAGS /Zc:inline- + ) +ENDIF() + ADD_CONVENIENCE_LIBRARY(clientlib ${CLIENT_SOURCES}) DTRACE_INSTRUMENT(clientlib) ADD_DEPENDENCIES(clientlib GenError) diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index a9244d9..6cef357 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -78,6 +78,13 @@ SET(SQL_EMBEDDED_SOURCES ${IMPORTED_SOURCES} ) +IF (WIN32 AND MSVC_VERSION GREATER 1820) + SET_SOURCE_FILES_PROPERTIES( + ../sql-common/my_time.c + PROPERTIES COMPILE_FLAGS /Zc:inline- + ) +ENDIF() + ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES}) DTRACE_INSTRUMENT(sql_embedded) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index e88c6c0..ff3080c 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -217,6 +217,13 @@ IF (WIN32 AND OPENSSL_APPLINK_C) ) ENDIF() +IF (WIN32 AND MSVC_VERSION GREATER 1820) + SET_SOURCE_FILES_PROPERTIES( + ../sql-common/my_time.c + PROPERTIES COMPILE_FLAGS /Zc:inline- + ) +ENDIF() + MYSQL_ADD_PLUGIN(partition ha_partition.cc STORAGE_ENGINE DEFAULT STATIC_ONLY RECOMPILE_FOR_EMBEDDED) From caa9331ae4d4c66a0a9936a3c169baed0b6ae14c Mon Sep 17 00:00:00 2001 From: Kieron Briggs Date: Thu, 24 Sep 2015 18:46:14 +1000 Subject: [PATCH 7/7] Bug #78282 - MySQL 5.6 fails to compile with Visual Studio 2015 Add newer Visual Studio versions to packaging/WiX/ca/CMakeLists.txt. --- packaging/WiX/ca/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packaging/WiX/ca/CMakeLists.txt b/packaging/WiX/ca/CMakeLists.txt index 81622a1..d3bb1f3 100644 --- a/packaging/WiX/ca/CMakeLists.txt +++ b/packaging/WiX/ca/CMakeLists.txt @@ -30,6 +30,12 @@ ELSEIF(MSVC_VERSION EQUAL 1500) SET(WIX35_MSVC_SUFFIX "_2008") ELSEIF(MSVC_VERSION EQUAL 1600) SET(WIX35_MSVC_SUFFIX "_2010") +ELSEIF(MSVC_VERSION EQUAL 1700) + SET(WIX35_MSVC_SUFFIX "_2012") +ELSEIF(MSVC_VERSION EQUAL 1800) + SET(WIX35_MSVC_SUFFIX "_2013") +ELSEIF(MSVC_VERSION EQUAL 1900) + SET(WIX35_MSVC_SUFFIX "_2015") ELSE() # When next VS is out, add the correct version here MESSAGE(FATAL_ERROR "Unknown VS version")