diff options
40 files changed, 309 insertions, 130 deletions
diff --git a/mono/eglib/glib.h b/mono/eglib/glib.h index 2dddff7724d..cb21d9b8f7d 100644 --- a/mono/eglib/glib.h +++ b/mono/eglib/glib.h @@ -407,8 +407,8 @@ gboolean g_utf16_asciiz_equal (const gunichar2 *utf16, const char *ascii); /* FIXME: g_strcasecmp supports utf8 unicode stuff */ #ifdef _MSC_VER -#define g_strcasecmp stricmp -#define g_strncasecmp strnicmp +#define g_strcasecmp _stricmp +#define g_strncasecmp _strnicmp #define g_strstrip(a) g_strchug (g_strchomp (a)) #else #define g_strcasecmp strcasecmp diff --git a/mono/eglib/gmisc-unix.c b/mono/eglib/gmisc-unix.c index 8fabbd2dd55..2a3afc00259 100644 --- a/mono/eglib/gmisc-unix.c +++ b/mono/eglib/gmisc-unix.c @@ -169,7 +169,7 @@ g_get_home_dir (void) return home_dir; } -const char * +const gchar * g_get_user_name (void) { get_pw_data (); diff --git a/mono/eglib/gmisc-win32.c b/mono/eglib/gmisc-win32.c index 4d0d3ec2cee..591c13a324f 100644 --- a/mono/eglib/gmisc-win32.c +++ b/mono/eglib/gmisc-win32.c @@ -182,7 +182,7 @@ g_get_home_dir (void) return home_dir; } -const char * +const gchar * g_get_user_name (void) { const char * retName = g_getenv ("USER"); diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index 70149a305dc..0a938e9b7f7 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -1911,13 +1911,13 @@ static AssemblyPreLoadHook *assembly_preload_hook = NULL; static AssemblyPreLoadHook *assembly_refonly_preload_hook = NULL; static MonoAssembly * -invoke_assembly_preload_hook (MonoAssemblyName *aname, gchar **assemblies_path) +invoke_assembly_preload_hook (MonoAssemblyName *aname, gchar **apath) { AssemblyPreLoadHook *hook; MonoAssembly *assembly; for (hook = assembly_preload_hook; hook; hook = hook->next) { - assembly = hook->func (aname, assemblies_path, hook->user_data); + assembly = hook->func (aname, apath, hook->user_data); if (assembly != NULL) return assembly; } @@ -1926,13 +1926,13 @@ invoke_assembly_preload_hook (MonoAssemblyName *aname, gchar **assemblies_path) } static MonoAssembly * -invoke_assembly_refonly_preload_hook (MonoAssemblyName *aname, gchar **assemblies_path) +invoke_assembly_refonly_preload_hook (MonoAssemblyName *aname, gchar **apath) { AssemblyPreLoadHook *hook; MonoAssembly *assembly; for (hook = assembly_refonly_preload_hook; hook; hook = hook->next) { - assembly = hook->func (aname, assemblies_path, hook->user_data); + assembly = hook->func (aname, apath, hook->user_data); if (assembly != NULL) return assembly; } diff --git a/mono/metadata/custom-attrs.c b/mono/metadata/custom-attrs.c index 70a9bc040e6..09dc98a009c 100644 --- a/mono/metadata/custom-attrs.c +++ b/mono/metadata/custom-attrs.c @@ -26,7 +26,6 @@ #include "mono/metadata/verify-internals.h" #include "mono/utils/checked-build.h" - #define CHECK_ADD4_OVERFLOW_UN(a, b) ((guint32)(0xFFFFFFFFU) - (guint32)(b) < (guint32)(a)) #define CHECK_ADD8_OVERFLOW_UN(a, b) ((guint64)(0xFFFFFFFFFFFFFFFFUL) - (guint64)(b) < (guint64)(a)) @@ -242,10 +241,12 @@ load_cattr_type (MonoImage *image, MonoType *t, gboolean header, const char *p, if (header) { if (!bcheck_blob (p, 0, boundp, error)) return NULL; +MONO_DISABLE_WARNING(4310) // cast truncates constant value if (*p == (char)0xFF) { *end = p + 1; return NULL; } +MONO_RESTORE_WARNING } if (!decode_blob_value_checked (p, boundp, slen, &p, error)) @@ -381,10 +382,12 @@ handle_enum: case MONO_TYPE_STRING: if (!bcheck_blob (p, 0, boundp, error)) return NULL; +MONO_DISABLE_WARNING (4310) // cast truncates constant value if (*p == (char)0xFF) { *end = p + 1; return NULL; } +MONO_RESTORE_WARNING if (!decode_blob_value_checked (p, boundp, &slen, &p, error)) return NULL; if (slen > 0 && !bcheck_blob (p, slen - 1, boundp, error)) diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index d1edb6835ce..69370784b9e 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -1872,14 +1872,14 @@ get_runtime_by_version (const char *version) } static void -get_runtimes_from_exe (const char *exe_file, MonoImage **exe_image, const MonoRuntimeInfo** runtimes) +get_runtimes_from_exe (const char *file, MonoImage **out_image, const MonoRuntimeInfo** runtimes) { AppConfigInfo* app_config; char *version; const MonoRuntimeInfo* runtime = NULL; MonoImage *image = NULL; - app_config = app_config_parse (exe_file); + app_config = app_config_parse (file); if (app_config != NULL) { /* Check supportedRuntime elements, if none is supported, fail. @@ -1911,10 +1911,10 @@ get_runtimes_from_exe (const char *exe_file, MonoImage **exe_image, const MonoRu } /* Look for a runtime with the exact version */ - image = mono_assembly_open_from_bundle (exe_file, NULL, FALSE); + image = mono_assembly_open_from_bundle (file, NULL, FALSE); if (image == NULL) - image = mono_image_open (exe_file, NULL); + image = mono_image_open (file, NULL); if (image == NULL) { /* The image is wrong or the file was not found. In this case return @@ -1926,7 +1926,7 @@ get_runtimes_from_exe (const char *exe_file, MonoImage **exe_image, const MonoRu return; } - *exe_image = image; + *out_image = image; runtimes [0] = get_runtime_by_version (image->version); runtimes [1] = NULL; diff --git a/mono/metadata/handle.c b/mono/metadata/handle.c index 80baa6daba5..bce1308ad9e 100644 --- a/mono/metadata/handle.c +++ b/mono/metadata/handle.c @@ -159,7 +159,7 @@ mono_handle_chunk_leak_check (HandleStack *handles) { #ifdef __cplusplus extern MonoThreadInfo * const mono_thread_info_current_var = NULL; #else -MonoThreadInfo * const mono_thread_info_current_var; +MonoThreadInfo * const mono_thread_info_current_var = NULL; #endif /* Actual handles implementation */ diff --git a/mono/metadata/handle.h b/mono/metadata/handle.h index b1aa95094bd..02e7a342f38 100644 --- a/mono/metadata/handle.h +++ b/mono/metadata/handle.h @@ -178,9 +178,11 @@ Icall macros */ #define SETUP_ICALL_COMMON \ do { \ + MONO_DISABLE_WARNING(4459) /* declaration of 'identifier' hides global declaration */ \ ERROR_DECL (error); \ /* There are deliberately locals and a constant NULL global with this same name. */ \ MonoThreadInfo *mono_thread_info_current_var = mono_thread_info_current (); \ + MONO_RESTORE_WARNING \ #define CLEAR_ICALL_COMMON \ mono_error_set_pending_exception (error); @@ -198,15 +200,21 @@ Icall macros (RESULT) = g_cast (mono_stack_mark_pop_value (mono_thread_info_current_var, &__mark, (HANDLE))); #define HANDLE_FUNCTION_ENTER() do { \ + MONO_DISABLE_WARNING(4459) /* declaration of 'identifier' hides global declaration */ \ /* There are deliberately locals and a constant NULL global with this same name. */ \ MonoThreadInfo *mono_thread_info_current_var = mono_thread_info_current (); \ + MONO_RESTORE_WARNING \ SETUP_ICALL_FRAME \ #define HANDLE_FUNCTION_RETURN() \ CLEAR_ICALL_FRAME; \ } while (0) -#define HANDLE_LOOP_PREPARE MonoThreadInfo *mono_thread_info_current_var = mono_thread_info_current () +#define HANDLE_LOOP_PREPARE \ + MONO_DISABLE_WARNING(4459) /* declaration of 'identifier' hides global declaration */ \ + /* There are deliberately locals and a constant NULL global with this same name. */ \ + MonoThreadInfo *mono_thread_info_current_var = mono_thread_info_current () \ + MONO_RESTORE_WARNING // Return a non-pointer or non-managed pointer, e.g. gboolean. #define HANDLE_FUNCTION_RETURN_VAL(VAL) \ diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 1c23d98d210..932a1e98c24 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -6742,7 +6742,11 @@ ves_icall_System_Environment_get_UserName (MonoError *error) { error_init (error); /* using glib is more portable */ - return mono_string_new_handle (mono_domain_get (), g_get_user_name (), error); + const gchar *user_name = g_get_user_name (); + if (user_name != NULL) + return mono_string_new_handle (mono_domain_get (), user_name, error); + else + return NULL_HANDLE_STRING; } #ifndef HOST_WIN32 @@ -7110,7 +7114,11 @@ ves_icall_System_IO_DriveInfo_GetDriveFormat (const gunichar2 *path, gint32 path MonoStringHandle ves_icall_System_Environment_InternalGetHome (MonoError *error) { - return mono_string_new_handle (mono_domain_get (), g_get_home_dir (), error); + const gchar *home_dir = g_get_home_dir (); + if (home_dir != NULL) + return mono_string_new_handle (mono_domain_get (), home_dir, error); + else + return NULL_HANDLE_STRING; } static const char * const encodings [] = { diff --git a/mono/metadata/metadata-verify.c b/mono/metadata/metadata-verify.c index 89a90409dc3..33fd435e147 100644 --- a/mono/metadata/metadata-verify.c +++ b/mono/metadata/metadata-verify.c @@ -1760,11 +1760,13 @@ is_valid_ser_string_full (VerifyContext *ctx, const char **str_start, guint32 *s if (ptr >= end) FAIL (ctx, g_strdup ("CustomAttribute: Not enough room for string size")); +MONO_DISABLE_WARNING (4310) // cast truncates constant value /*NULL string*/ if (*ptr == (char)0xFF) { *_ptr = ptr + 1; return TRUE; } +MONO_RESTORE_WARNING if (!safe_read_cint (size, ptr, end)) FAIL (ctx, g_strdup ("CustomAttribute: Not enough room for string size")); diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 6487531847c..53a88d9e78b 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -557,21 +557,21 @@ inverse of this mapping. #define rtsize(meta,s,b) (((s) < (1 << (b)) ? 2 : 4)) static inline int -idx_size (MonoImage *meta, int tableidx) +idx_size (MonoImage *meta, int idx) { - if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << tableidx))) - return meta->referenced_table_rows [tableidx] < 65536 ? 2 : 4; + if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << idx))) + return meta->referenced_table_rows [idx] < 65536 ? 2 : 4; else - return meta->tables [tableidx].rows < 65536 ? 2 : 4; + return meta->tables [idx].rows < 65536 ? 2 : 4; } static inline int -get_nrows (MonoImage *meta, int tableidx) +get_nrows (MonoImage *meta, int idx) { - if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << tableidx))) - return meta->referenced_table_rows [tableidx]; + if (meta->referenced_tables && (meta->referenced_tables & ((guint64)1 << idx))) + return meta->referenced_table_rows [idx]; else - return meta->tables [tableidx].rows; + return meta->tables [idx].rows; } /* Reference: Partition II - 23.2.6 */ diff --git a/mono/metadata/mono-security-windows-internals.h b/mono/metadata/mono-security-windows-internals.h index addfef17a80..94df8c73ca9 100644 --- a/mono/metadata/mono-security-windows-internals.h +++ b/mono/metadata/mono-security-windows-internals.h @@ -17,7 +17,7 @@ #include "mono/metadata/metadata-internals.h" gint32 -mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname); +mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname, MonoError *error); gboolean mono_security_win_is_machine_protected (const gunichar2 *path, MonoError *error); diff --git a/mono/metadata/mono-security-windows-uwp.c b/mono/metadata/mono-security-windows-uwp.c index 850196cd4b6..6a37cadd7dc 100644 --- a/mono/metadata/mono-security-windows-uwp.c +++ b/mono/metadata/mono-security-windows-uwp.c @@ -62,14 +62,14 @@ ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken } MonoBoolean -ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (MonoError *error)) +ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (MonoError *error) { mono_security_win_not_supported ("RevertToSelf", error); return FALSE; } gint32 -mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname, MonoError *error) +mono_security_win_get_token_name (gpointer token, gunichar2 **uniname, MonoError *error) { // FIXME This is now supported by UWP. mono_security_win_not_supported ("GetTokenInformation", error); diff --git a/mono/metadata/mono-security-windows.c b/mono/metadata/mono-security-windows.c index 7efa7b57125..4c01c2d7b64 100644 --- a/mono/metadata/mono-security-windows.c +++ b/mono/metadata/mono-security-windows.c @@ -94,7 +94,7 @@ ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken (MonoError * } gint32 -mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname) +mono_security_win_get_token_name (gpointer token, gunichar2 ** uniname, MonoError *error) { gint32 size = 0; @@ -120,7 +120,7 @@ ves_icall_System_Security_Principal_WindowsIdentity_GetTokenName (gpointer token error_init (error); - size = mono_security_win_get_token_name (token, &uniname); + size = mono_security_win_get_token_name (token, &uniname, error); if (size > 0) { result = mono_string_new_utf16_handle (mono_domain_get (), uniname, size, error); diff --git a/mono/metadata/object.c b/mono/metadata/object.c index bb75834725a..67981a7c60e 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -4953,13 +4953,13 @@ mono_unhandled_exception_checked (MonoObjectHandle exc, MonoError *error) */ void mono_runtime_exec_managed_code (MonoDomain *domain, - MonoMainThreadFunc main_func, - gpointer main_args) + MonoMainThreadFunc mfunc, + gpointer margs) { // This function is external_only. ERROR_DECL (error); - mono_thread_create_checked (domain, main_func, main_args, error); + mono_thread_create_checked (domain, mfunc, margs, error); mono_error_assert_ok (error); mono_thread_manage (); diff --git a/mono/metadata/security.h b/mono/metadata/security.h index c1121f44859..3204fec2a50 100644 --- a/mono/metadata/security.h +++ b/mono/metadata/security.h @@ -29,8 +29,4 @@ ICALL_EXPORT MonoArray* ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token); -ICALL_EXPORT -MonoArray* -ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token); - #endif /* _MONO_METADATA_SECURITY_H_ */ diff --git a/mono/metadata/threadpool-io-poll.c b/mono/metadata/threadpool-io-poll.c index b3236b78de9..2563e6d4f5c 100644 --- a/mono/metadata/threadpool-io-poll.c +++ b/mono/metadata/threadpool-io-poll.c @@ -107,22 +107,22 @@ poll_remove_fd (gint fd) } static inline gint -poll_mark_bad_fds (mono_pollfd *poll_fds, gint poll_fds_size) +poll_mark_bad_fds (mono_pollfd *fds, gint size) { gint i, ready = 0; - for (i = 0; i < poll_fds_size; i++) { - if (poll_fds [i].fd == -1) + for (i = 0; i < size; i++) { + if (fds [i].fd == -1) continue; - switch (mono_poll (&poll_fds [i], 1, 0)) { + switch (mono_poll (&fds [i], 1, 0)) { case 1: ready++; break; case -1: if (errno == EBADF) { - poll_fds [i].revents |= MONO_POLLNVAL; + fds [i].revents |= MONO_POLLNVAL; ready++; } break; diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 12ddca68e3b..0fd94b97fa2 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -56,6 +56,7 @@ #include <mono/utils/mono-os-wait.h> #include <mono/metadata/exception-internals.h> #include <mono/utils/mono-state.h> +#include <mono/metadata/w32subset.h> #ifdef HAVE_SYS_WAIT_H #include <sys/wait.h> @@ -2199,8 +2200,7 @@ ves_icall_System_Threading_WaitHandle_Wait_internal (gpointer *handles, gint32 n return map_native_wait_result_to_managed (ret, numhandles); } -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) - +#if HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT gint32 ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (gpointer toSignal, gpointer toWait, gint32 ms, MonoError *error) { diff --git a/mono/metadata/w32file-win32.c b/mono/metadata/w32file-win32.c index 3c08112ec35..f8abe342c3b 100644 --- a/mono/metadata/w32file-win32.c +++ b/mono/metadata/w32file-win32.c @@ -515,6 +515,8 @@ mono_w32file_get_console_error (void) } #endif // HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE +#if HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX + gint64 mono_w32file_get_file_size (HANDLE handle, gint32 *error) { @@ -531,6 +533,8 @@ mono_w32file_get_file_size (HANDLE handle, gint32 *error) return length.QuadPart; } +#endif // HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX + // Support older UWP SDK. WINBASEAPI UINT diff --git a/mono/metadata/w32process-win32-internals.h b/mono/metadata/w32process-win32-internals.h index 14792024826..6736d0baf17 100644 --- a/mono/metadata/w32process-win32-internals.h +++ b/mono/metadata/w32process-win32-internals.h @@ -20,10 +20,6 @@ void mono_process_init_startup_info (HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle,STARTUPINFO *startinfo); -gboolean -mono_process_create_process (MonoW32ProcessInfo *mono_process_info, MonoString *cmd, guint32 creation_flags, - gunichar2 *env_vars, gunichar2 *dir, STARTUPINFO *start_info, PROCESS_INFORMATION *process_info); - MonoBoolean mono_icall_get_process_working_set_size (gpointer handle, gsize *min, gsize *max); diff --git a/mono/metadata/w32subset.h b/mono/metadata/w32subset.h index f4ccd471734..d66b5ce5778 100644 --- a/mono/metadata/w32subset.h +++ b/mono/metadata/w32subset.h @@ -14,95 +14,167 @@ #ifndef HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME 1 +#else +#define HAVE_API_SUPPORT_WIN32_GET_COMPUTER_NAME 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE 1 +#else +#define HAVE_API_SUPPORT_WIN32_GET_DRIVE_TYPE 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_REPLACE_FILE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_REPLACE_FILE 1 +#else +#define HAVE_API_SUPPORT_WIN32_REPLACE_FILE 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_COPY_FILE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_COPY_FILE 1 +#else +#define HAVE_API_SUPPORT_WIN32_COPY_FILE 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_COPY_FILE2 // not on Windows7 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_COPY_FILE2 1 +#else +#define HAVE_API_SUPPORT_WIN32_COPY_FILE2 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_LOCK_FILE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_LOCK_FILE 1 +#else +#define HAVE_API_SUPPORT_WIN32_LOCK_FILE 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_UNLOCK_FILE #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_UNLOCK_FILE 1 +#else +#define HAVE_API_SUPPORT_WIN32_UNLOCK_FILE 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_MOVE_FILE -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) -#define HAVE_API_SUPPORT_WIN32_MOVE_FILE 0 -#elif G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_MOVE_FILE 1 +#else +#define HAVE_API_SUPPORT_WIN32_MOVE_FILE 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX 1 +#else +#define HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) -#define HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE 0 -#elif G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE 1 +#else +#define HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE 0 +#endif +#endif + +#ifndef HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) || G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) +#define HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX 1 +#else +#define HAVE_API_SUPPORT_WIN32_GET_FILE_SIZE_EX 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) -#define HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS 0 -#elif G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS 1 +#else +#define HAVE_API_SUPPORT_WIN32_GET_LOGICAL_DRIVE_STRINGS 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) -#define HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH 0 -#elif G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH 1 +#else +#define HAVE_API_SUPPORT_WIN32_SH_GET_FOLDER_PATH 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) -#define HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT 0 -#elif G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT 1 +#else +#define HAVE_API_SUPPORT_WIN32_SEND_MESSAGE_TIMEOUT 0 #endif #endif #ifndef HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) -#define HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE 0 -#elif G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) #define HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE 1 +#else +#define HAVE_API_SUPPORT_WIN32_WAIT_FOR_INPUT_IDLE 0 +#endif +#endif + +#ifndef HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#define HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT 1 +#else +#define HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT 0 +#endif +#endif + +#ifndef HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#define HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS 1 +#else +#define HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS 0 +#endif +#endif + +#ifndef HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#define HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE 1 +#else +#define HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE 0 +#endif +#endif + +#ifndef HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#define HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY 1 +#else +#define HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY 0 +#endif +#endif + +#ifndef HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY +#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) +#define HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY 1 +#else +#define HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY 0 +#endif +#endif + +#ifndef HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#define HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE 1 +#else +#define HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE 0 #endif #endif diff --git a/mono/mini/calls.c b/mono/mini/calls.c index f0ee452d40b..5be48e0d9f9 100644 --- a/mono/mini/calls.c +++ b/mono/mini/calls.c @@ -908,5 +908,6 @@ mini_emit_llvmonly_calli (MonoCompile *cfg, MonoMethodSignature *fsig, MonoInst return mini_emit_extra_arg_calli (cfg, fsig, args, arg_reg, call_target); } - +#else +MONO_EMPTY_SOURCE_FILE (calls); #endif diff --git a/mono/mini/driver.c b/mono/mini/driver.c index 9d543a71e10..a98af082e63 100644 --- a/mono/mini/driver.c +++ b/mono/mini/driver.c @@ -1675,7 +1675,7 @@ mono_jit_parse_options (int argc, char * argv[]) { int i; char *trace_options = NULL; - int mini_verbose = 0; + int mini_verbose_level = 0; guint32 opt; /* @@ -1711,7 +1711,7 @@ mono_jit_parse_options (int argc, char * argv[]) } else if (strncmp (argv [i], "--trace=", 8) == 0) { trace_options = &argv [i][8]; } else if (strcmp (argv [i], "--verbose") == 0 || strcmp (argv [i], "-v") == 0) { - mini_verbose++; + mini_verbose_level++; } else if (strcmp (argv [i], "--breakonex") == 0) { MonoDebugOptions *opt = mini_get_debug_options (); @@ -1757,8 +1757,8 @@ mono_jit_parse_options (int argc, char * argv[]) exit (1); } - if (mini_verbose) - mono_set_verbose_level (mini_verbose); + if (mini_verbose_level) + mono_set_verbose_level (mini_verbose_level); } static void @@ -1945,7 +1945,7 @@ mono_main (int argc, char* argv[]) int i, count = 1; guint32 opt, action = DO_EXEC, recompilation_times = 1; MonoGraphOptions mono_graph_options = (MonoGraphOptions)0; - int mini_verbose = 0; + int mini_verbose_level = 0; char *trace_options = NULL; char *aot_options = NULL; char *forced_version = NULL; @@ -2007,7 +2007,7 @@ mono_main (int argc, char* argv[]) mono_single_method_regression_opt = parse_optimizations (opt, full_opts, TRUE); g_free (full_opts); } else if (strcmp (argv [i], "--verbose") == 0 || strcmp (argv [i], "-v") == 0) { - mini_verbose++; + mini_verbose_level++; } else if (strcmp (argv [i], "--version") == 0 || strcmp (argv [i], "-V") == 0) { char *build = mono_get_runtime_build_info (); char *gc_descr; @@ -2443,7 +2443,7 @@ mono_main (int argc, char* argv[]) mono_config_parse (config_file); } - mono_set_defaults (mini_verbose, opt); + mono_set_defaults (mini_verbose_level, opt); domain = mini_init (argv [i], forced_version); mono_gc_set_stack_end (&domain); @@ -2466,7 +2466,7 @@ mono_main (int argc, char* argv[]) switch (action) { case DO_SINGLE_METHOD_REGRESSION: case DO_REGRESSION: - return mono_exec_regression_internal (mini_verbose, argc -i, argv + i, action == DO_SINGLE_METHOD_REGRESSION); + return mono_exec_regression_internal (mini_verbose_level, argc -i, argv + i, action == DO_SINGLE_METHOD_REGRESSION); case DO_BENCH: if (argc - i != 1 || mname == NULL) { @@ -2557,7 +2557,7 @@ mono_main (int argc, char* argv[]) i = mono_environment_exitcode_get (); return i; } else if (action == DO_COMPILE) { - compile_all_methods (assembly, mini_verbose, opt, recompilation_times); + compile_all_methods (assembly, mini_verbose_level, opt, recompilation_times); mini_cleanup (domain); return 0; } else if (action == DO_DEBUGGER) { @@ -2726,6 +2726,7 @@ void mono_jit_set_aot_only (gboolean val) { mono_aot_only = val; + mono_ee_features.use_aot_trampolines = val; } static void diff --git a/mono/mini/interp/transform.c b/mono/mini/interp/transform.c index 958d6794ad2..e3e586b7f4c 100644 --- a/mono/mini/interp/transform.c +++ b/mono/mini/interp/transform.c @@ -470,13 +470,13 @@ shift_op(TransformData *td, int mint_op) } static int -can_store (int stack_type, int var_type) +can_store (int st_value, int vt_value) { - if (stack_type == STACK_TYPE_O || stack_type == STACK_TYPE_MP) - stack_type = STACK_TYPE_I; - if (var_type == STACK_TYPE_O || var_type == STACK_TYPE_MP) - var_type = STACK_TYPE_I; - return stack_type == var_type; + if (st_value == STACK_TYPE_O || st_value == STACK_TYPE_MP) + st_value = STACK_TYPE_I; + if (vt_value == STACK_TYPE_O || vt_value == STACK_TYPE_MP) + vt_value = STACK_TYPE_I; + return st_value == vt_value; } #define SET_SIMPLE_TYPE(s, ty) \ diff --git a/mono/mini/intrinsics.c b/mono/mini/intrinsics.c index 9444b444c88..087723f6e6f 100644 --- a/mono/mini/intrinsics.c +++ b/mono/mini/intrinsics.c @@ -1418,5 +1418,6 @@ mini_emit_inst_for_field_load (MonoCompile *cfg, MonoClassField *field) } return NULL; } - +#else +MONO_EMPTY_SOURCE_FILE (intrinsics); #endif diff --git a/mono/mini/mini-runtime.c b/mono/mini/mini-runtime.c index 04d84104ffc..dfa086f50c7 100644 --- a/mono/mini/mini-runtime.c +++ b/mono/mini/mini-runtime.c @@ -2798,7 +2798,7 @@ GSList *mono_single_method_list; GHashTable *mono_single_method_hash; guint32 -mono_get_optimizations_for_method (MonoMethod *method, guint32 default_opt) +mono_get_optimizations_for_method (MonoMethod *method, guint32 opt) { g_assert (method); @@ -2807,10 +2807,10 @@ mono_get_optimizations_for_method (MonoMethod *method, guint32 default_opt) void *res = g_hash_table_lookup (bisect_methods_hash, name); g_free (name); if (res) - return default_opt | bisect_opt; + return opt | bisect_opt; } if (!mono_do_single_method_regression) - return default_opt; + return opt; if (!mono_current_single_method) { if (!mono_single_method_hash) mono_single_method_hash = g_hash_table_new (g_direct_hash, g_direct_equal); @@ -2818,11 +2818,11 @@ mono_get_optimizations_for_method (MonoMethod *method, guint32 default_opt) g_hash_table_insert (mono_single_method_hash, method, method); mono_single_method_list = g_slist_prepend (mono_single_method_list, method); } - return default_opt; + return opt; } if (method == mono_current_single_method) return mono_single_method_regression_opt; - return default_opt; + return opt; } gpointer diff --git a/mono/mini/tramp-amd64.c b/mono/mini/tramp-amd64.c index 99cc3ee9560..367111a1dfe 100644 --- a/mono/mini/tramp-amd64.c +++ b/mono/mini/tramp-amd64.c @@ -121,6 +121,7 @@ mono_arch_get_static_rgctx_trampoline (gpointer arg, gpointer addr) #ifdef _WIN64 // Workaround lack of Valgrind support for 64-bit Windows +#undef VALGRIND_DISCARD_TRANSLATIONS #define VALGRIND_DISCARD_TRANSLATIONS(...) #endif diff --git a/mono/utils/mono-compiler.h b/mono/utils/mono-compiler.h index 344042b8643..2c507776c54 100644 --- a/mono/utils/mono-compiler.h +++ b/mono/utils/mono-compiler.h @@ -61,10 +61,19 @@ typedef ptrdiff_t ssize_t; #define MONO_PRAGMA_WARNING_PUSH() __pragma(warning (push)) #define MONO_PRAGMA_WARNING_DISABLE(x) __pragma(warning (disable:x)) #define MONO_PRAGMA_WARNING_POP() __pragma(warning (pop)) + +#define MONO_DISABLE_WARNING(x) \ + MONO_PRAGMA_WARNING_PUSH() \ + MONO_PRAGMA_WARNING_DISABLE(x) + +#define MONO_RESTORE_WARNING \ + MONO_PRAGMA_WARNING_POP() #else #define MONO_PRAGMA_WARNING_PUSH() #define MONO_PRAGMA_WARNING_DISABLE(x) #define MONO_PRAGMA_WARNING_POP() +#define MONO_DISABLE_WARNING(x) +#define MONO_RESTORE_WARNING #endif #if !defined(_MSC_VER) && !defined(HOST_SOLARIS) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MONOTOUCH) && HAVE_VISIBILITY_HIDDEN diff --git a/mono/utils/mono-context.h b/mono/utils/mono-context.h index d521b61de1c..ad0b2970c9c 100644 --- a/mono/utils/mono-context.h +++ b/mono/utils/mono-context.h @@ -271,6 +271,8 @@ struct sigcontext { #undef MONO_SIGNAL_USE_UCONTEXT_T #endif +MONO_DISABLE_WARNING(4324) // 'struct_name' : structure was padded due to __declspec(align()) + typedef struct { host_mgreg_t gregs [AMD64_NREG]; #if defined(MONO_HAVE_SIMD_REG) @@ -280,6 +282,8 @@ typedef struct { #endif } MonoContext; +MONO_RESTORE_WARNING + #define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->gregs [AMD64_RIP] = (host_mgreg_t)(gsize)(ip); } while (0); #define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->gregs [AMD64_RBP] = (host_mgreg_t)(gsize)(bp); } while (0); #define MONO_CONTEXT_SET_SP(ctx,esp) do { (ctx)->gregs [AMD64_RSP] = (host_mgreg_t)(gsize)(esp); } while (0); diff --git a/mono/utils/mono-dl-windows.c b/mono/utils/mono-dl-windows.c index 0332a61cee0..5193eb1f7d5 100644 --- a/mono/utils/mono-dl-windows.c +++ b/mono/utils/mono-dl-windows.c @@ -17,6 +17,7 @@ #include "mono/utils/mono-dl-windows-internals.h" #include "mono/utils/mono-embed.h" #include "mono/utils/mono-path.h" +#include "mono/metadata/w32subset.h" #include <stdlib.h> #include <stdio.h> @@ -50,20 +51,22 @@ mono_dl_open_file (const char *file, int flags) if (file) { gunichar2* file_utf16 = g_utf8_to_utf16 (file, strlen (file), NULL, NULL, NULL); -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE guint last_sem = SetErrorMode (SEM_FAILCRITICALERRORS); #endif guint32 last_error = 0; -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) - hModule = LoadLibrary (file_utf16); -#else +#if HAVE_API_SUPPORT_WIN32_LOAD_LIBRARY + hModule = LoadLibraryW (file_utf16); +#elif HAVE_API_SUPPORT_WIN32_LOAD_PACKAGED_LIBRARY hModule = LoadPackagedLibrary (file_utf16, NULL); +#else + g_assert_not_reached (); #endif if (!hModule) last_error = GetLastError (); -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if HAVE_API_SUPPORT_WIN32_SET_ERROR_MODE SetErrorMode (last_sem); #endif @@ -72,10 +75,10 @@ mono_dl_open_file (const char *file, int flags) if (!hModule) SetLastError (last_error); } else { -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) - hModule = GetModuleHandle (NULL); +#if HAVE_API_SUPPORT_WIN32_GET_MODULE_HANDLE + hModule = GetModuleHandleW (NULL); #else - g_error("Not supported"); + g_assert_not_reached (); #endif } return hModule; diff --git a/mono/utils/mono-os-wait-win32.c b/mono/utils/mono-os-wait-win32.c index 04e5d4b28b9..98ec6aa6049 100644 --- a/mono/utils/mono-os-wait-win32.c +++ b/mono/utils/mono-os-wait-win32.c @@ -13,6 +13,7 @@ #include "mono-threads-debug.h" #include "mono-logger-internals.h" #include "mono-error-internals.h" +#include <mono/metadata/w32subset.h> enum ThreadWaitInfo { THREAD_WAIT_INFO_CLEARED = 0, @@ -168,8 +169,7 @@ mono_win32_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, BOO return result; } -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) - +#if HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT DWORD mono_win32_signal_object_and_wait (HANDLE toSignal, HANDLE toWait, DWORD timeout, BOOL alertable) { @@ -189,9 +189,9 @@ mono_win32_signal_object_and_wait (HANDLE toSignal, HANDLE toWait, DWORD timeout return result; } -#endif +#endif /* HAVE_API_SUPPORT_WIN32_SIGNAL_OBJECT_AND_WAIT */ -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS DWORD mono_win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, DWORD timeout, DWORD wakeMask, DWORD flags) { @@ -211,7 +211,7 @@ mono_win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, return result; } -#endif +#endif /* HAVE_API_SUPPORT_WIN32_MSG_WAIT_FOR_MULTIPLE_OBJECTS */ DWORD mono_win32_wsa_wait_for_multiple_events (DWORD count, const WSAEVENT FAR *handles, BOOL waitAll, DWORD timeout, BOOL alertable) diff --git a/msvc/build-external-btls.bat b/msvc/build-external-btls.bat index 8b16219faec..d4de955a5a0 100644 --- a/msvc/build-external-btls.bat +++ b/msvc/build-external-btls.bat @@ -13,6 +13,7 @@ :: %7 VS configuration (Debug/Release)
:: %8 VS target
:: %9 MsBuild bin path, if used.
+:: %10 Force MSBuild (true/false), if used.
:: --------------------------------------------------
@echo off
@@ -30,14 +31,24 @@ set PERL_BIN_NAME=perl.exe set YASM_BIN_NAME=yasm.exe
set MONO_BTLS_DIR=%~1
-set BTLS_DIR=%~2
-set BTLS_BUILD_DIR=%~3
-set MONO_DIST_DIR=%~4
-set VS_CFLAGS=%~5
-set VS_PLATFORM=%~6
-set VS_CONFIGURATION=%~7
-set VS_TARGET=%~8
-set MSBUILD_BIN_PATH=%~9
+shift
+set BTLS_DIR=%~1
+shift
+set BTLS_BUILD_DIR=%~1
+shift
+set MONO_DIST_DIR=%~1
+shift
+set VS_CFLAGS=%~1
+shift
+set VS_PLATFORM=%~1
+shift
+set VS_CONFIGURATION=%~1
+shift
+set VS_TARGET=%~1
+shift
+set MSBUILD_BIN_PATH=%~1
+shift
+set FORCE_MSBUILD=%~1
:: Setup toolchain.
:: set GIT=
@@ -82,6 +93,10 @@ if "%VS_TARGET%" == "" ( set VS_TARGET=Build
)
+if "%FORCE_MSBUILD%" == "" (
+ set FORCE_MSBUILD=false
+)
+
if not exist "%MONO_BTLS_DIR%" (
echo Could not find "%MONO_BTLS_DIR%".
goto ON_ERROR
@@ -326,7 +341,11 @@ if "%CMAKE%" == "" ( )
if /i "%VS_TARGET%" == "build" (
- echo Found CMake: %CMAKE%
+ echo Found CMake: "%CMAKE%"
+)
+
+if /i "%FORCE_MSBUILD%" == "true" (
+ goto _SETUP_CMAKE_ENVIRONMENT_VS_GENERATOR
)
:: Check for optional cmake generate and build tools for full BTLS assembler supported build. NOTE, currently BTLS assembler build
@@ -362,7 +381,7 @@ goto _SETUP_CMAKE_ENVIRONMENT_EXIT :_SETUP_CMAKE_ENVIRONMENT_NINJA_GENERATOR
if /i "%VS_TARGET%" == "build" (
- echo Found Ninja: %NINJA%
+ echo Found Ninja: "%NINJA%"
echo Using Ninja build generator, enabling full assembler build.
)
diff --git a/msvc/build-external-btls.vcxproj b/msvc/build-external-btls.vcxproj index b3eddb01ed3..a07b4bb6d60 100644 --- a/msvc/build-external-btls.vcxproj +++ b/msvc/build-external-btls.vcxproj @@ -18,6 +18,11 @@ <Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="build-init.vcxproj">
+ <Project>{92ae7622-5f58-4234-9a26-9ec71876b3f4}</Project>
+ </ProjectReference>
+ </ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E41DDF41-0916-454B-A7C2-6E410E45CAFD}</ProjectGuid>
<RootNamespace>buildexternalbtls</RootNamespace>
@@ -155,12 +160,12 @@ <_BtlsBuildCommand>build-external-btls.bat "$(_MonoBtlsSourceDir)" "$(_BtlsSourceDir)" "$(_BtlsBuildDir)" "$(_MonoOutputDir)" "$(_BtlsCFlags)" "$(Platform)" "$(Configuration)"</_BtlsBuildCommand>
</PropertyGroup>
<Target Name="_AfterBuildExternalBtls" Condition="'$(MONO_ENABLE_BTLS)' == 'true'">
- <Exec Command="$(_BtlsBuildCommand) "Build" "$(MSBuildBinPath)\"">
+ <Exec Command="$(_BtlsBuildCommand) "Build" "$(MSBuildBinPath)\" "$(_MonoExternalBuildForceMSBuild)"">
<Output TaskParameter="ExitCode" PropertyName="_BuildExternalBtlsExitCode" />
</Exec>
</Target>
<Target Name="_AfterCleanExternalBtls" Condition="'$(MONO_ENABLE_BTLS)' == 'true'">
- <Exec Command="$(_BtlsBuildCommand) "Clean" "$(MSBuildBinPath)\"">
+ <Exec Command="$(_BtlsBuildCommand) "Clean" "$(MSBuildBinPath)\" "$(_MonoExternalBuildForceMSBuild)"">
<Output TaskParameter="ExitCode" PropertyName="_CleanExternalBtlsExitCode" />
</Exec>
</Target>
diff --git a/msvc/build-external-llvm.bat b/msvc/build-external-llvm.bat index 4982a64c42d..22a0ad50938 100644 --- a/msvc/build-external-llvm.bat +++ b/msvc/build-external-llvm.bat @@ -14,6 +14,7 @@ :: %8 VS configuration (Debug/Release).
:: %9 VS target.
:: %10 MsBuild bin path, if used.
+:: %11 Force MSBuild (true/false), if used.
:: --------------------------------------------------
@echo off
@@ -30,15 +31,26 @@ set NINJA_BIN_NAME=ninja.exe set PYTHON_BIN_NAME=python.exe
set LLVM_DIR=%~1
-set LLVM_BUILD_DIR=%~2
-set LLVM_INSTALL_DIR=%~3
-set MONO_DIST_DIR=%~4
-set VS_CFLAGS=%~5
-set LLVM_ADDITIONAL_CMAKE_ARGS=%~6
-set VS_PLATFORM=%~7
-set VS_CONFIGURATION=%~8
-set VS_TARGET=%~9
-set MSBUILD_BIN_PATH=%~10
+shift
+set LLVM_BUILD_DIR=%~1
+shift
+set LLVM_INSTALL_DIR=%~1
+shift
+set MONO_DIST_DIR=%~1
+shift
+set VS_CFLAGS=%~1
+shift
+set LLVM_ADDITIONAL_CMAKE_ARGS=%~1
+shift
+set VS_PLATFORM=%~1
+shift
+set VS_CONFIGURATION=%~1
+shift
+set VS_TARGET=%~1
+shift
+set MSBUILD_BIN_PATH=%~1
+shift
+set FORCE_MSBUILD=%~1
:: Setup toolchain.
:: set GIT=
@@ -83,6 +95,10 @@ if "%VS_TARGET%" == "" ( set VS_TARGET=Build
)
+if "%FORCE_MSBUILD%" == "" (
+ set FORCE_MSBUILD=false
+)
+
if not exist "%LLVM_DIR%" (
echo Could not find "%LLVM_DIR%".
goto ON_ERROR
@@ -362,7 +378,11 @@ if "%CMAKE%" == "" ( )
if /i "%VS_TARGET%" == "build" (
- echo Found CMake: %CMAKE%
+ echo Found CMake: "%CMAKE%"
+)
+
+if /i "%FORCE_MSBUILD%" == "true" (
+ goto _SETUP_CMAKE_ENVIRONMENT_VS_GENERATOR
)
:: Check for optional cmake generate and build tools.
@@ -395,7 +415,7 @@ goto _SETUP_CMAKE_ENVIRONMENT_EXIT :_SETUP_CMAKE_ENVIRONMENT_NINJA_GENERATOR
if /i "%VS_TARGET%" == "build" (
- echo Found Ninja: %NINJA%
+ echo Found Ninja: "%NINJA%"
echo Using Ninja build generator.
)
diff --git a/msvc/build-external-llvm.vcxproj b/msvc/build-external-llvm.vcxproj index e74168261aa..92ccd49fe19 100644 --- a/msvc/build-external-llvm.vcxproj +++ b/msvc/build-external-llvm.vcxproj @@ -18,6 +18,11 @@ <Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="build-init.vcxproj">
+ <Project>{92ae7622-5f58-4234-9a26-9ec71876b3f4}</Project>
+ </ProjectReference>
+ </ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C3D4C623-55F8-4653-980D-61AA629B4E1D}</ProjectGuid>
<RootNamespace>buildexternalllvm</RootNamespace>
@@ -153,20 +158,27 @@ <_LLVMCFlags>$(_LLVMCFlags.Trim())</_LLVMCFlags>
<_LLVMCFlags Condition="'$(_LLVMCFlags)' != ''">-D$(_LLVMCFlags.Replace(" "," -D"))</_LLVMCFlags>
<_LLVMEnableAsserts>-DLLVM_ENABLE_ASSERTIONS=Off</_LLVMEnableAsserts>
- <_LLVMEnableAsserts Condition="'$(MONO_ENABLE_LLVM_ASSERTS)' == 'true'" >-DLLVM_ENABLE_ASSERTIONS=On</_LLVMEnableAsserts>
+ <_LLVMEnableAsserts Condition="'$(MONO_ENABLE_LLVM_ASSERTS)' == 'true'">-DLLVM_ENABLE_ASSERTIONS=On</_LLVMEnableAsserts>
<_LLVMAdditionalCMakeArgs>$(_LLVMEnableAsserts)</_LLVMAdditionalCMakeArgs>
<_LLVMBuildCommand>build-external-llvm.bat "$(_LLVMSourceDir)" "$(_LLVMBuildDir)" "$(_LLVMInstallDir)" "$(_MonoOutputDir)" "$(_LLVMCFlags)" "$(_LLVMAdditionalCMakeArgs)" "$(Platform)" "$(Configuration)"</_LLVMBuildCommand>
</PropertyGroup>
<Target Name="_AfterBuildExternalLLVM" Condition="'$(MONO_ENABLE_LLVM)' == 'true' and '$(_MonoEnableInternalLLVM)' == 'true'">
- <Exec Command="$(_LLVMBuildCommand) "Build" "$(MSBuildBinPath)\"">
+ <Exec Command="$(_LLVMBuildCommand) "Build" "$(MSBuildBinPath)\" "$(_MonoExternalBuildForceMSBuild)"">
<Output TaskParameter="ExitCode" PropertyName="_BuildExternalLLVMExitCode" />
</Exec>
</Target>
<Target Name="_AfterCleanExternalLLVM" Condition="'$(MONO_ENABLE_LLVM)' == 'true' and '$(_MonoEnableInternalLLVM)' == 'true'">
- <Exec Command="$(_LLVMBuildCommand) "Clean" "$(MSBuildBinPath)\"">
+ <Exec Command="$(_LLVMBuildCommand) "Clean" "$(MSBuildBinPath)\" "$(_MonoExternalBuildForceMSBuild)"">
<Output TaskParameter="ExitCode" PropertyName="_CleanExternalLLVMExitCode" />
</Exec>
</Target>
<Target Name="AfterBuild" DependsOnTargets="_ConfigureExternalMonoLLVMBuildEnvironment;_AfterBuildExternalLLVM" />
<Target Name="AfterClean" DependsOnTargets="_ConfigureExternalMonoLLVMBuildEnvironment;_AfterCleanExternalLLVM" />
+
+ <Target Name="_GetLLVMConfig" DependsOnTargets="_ConfigureExternalMonoLLVMBuildEnvironment" Returns="@(_GetLLVMConfigOutputItems)">
+ <ItemGroup>
+ <_GetLLVMConfigOutputItems Include="$(_MonoLLVMConfig)" />
+ </ItemGroup>
+ </Target>
+
</Project>
\ No newline at end of file diff --git a/msvc/build-init.vcxproj b/msvc/build-init.vcxproj index 2a6ba7c6df2..2b6f883483c 100644 --- a/msvc/build-init.vcxproj +++ b/msvc/build-init.vcxproj @@ -167,7 +167,7 @@ <Target Name="AfterBuild" DependsOnTargets="AfterBuildWinSetup" />
- <Target Name="_BackupConfigFile" Condition="'$(_MonoConfigFileBackupExists)' != 'true'">
+ <Target Name="_BackupConfigFile" Condition="'$(_MonoConfigFileBackupExists)' != 'true' and Exists('$(MONO_DIR)/config.h')">
<Copy SourceFiles="$(MONO_DIR)/config.h" DestinationFiles="$(MONO_DIR)/cygconfig.h" />
</Target>
diff --git a/msvc/libgc.vcxproj b/msvc/libgc.vcxproj index 9d4116721e9..abfef90a3a1 100644 --- a/msvc/libgc.vcxproj +++ b/msvc/libgc.vcxproj @@ -18,6 +18,11 @@ <Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="build-init.vcxproj">
+ <Project>{92ae7622-5f58-4234-9a26-9ec71876b3f4}</Project>
+ </ProjectReference>
+ </ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EB56000B-C80B-4E8B-908D-D84D31B517D3}</ProjectGuid>
<RootNamespace>libgc</RootNamespace>
diff --git a/msvc/libgcmonosgen.vcxproj b/msvc/libgcmonosgen.vcxproj index 3db4e154d23..0266b75c656 100644 --- a/msvc/libgcmonosgen.vcxproj +++ b/msvc/libgcmonosgen.vcxproj @@ -18,6 +18,11 @@ <Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="build-init.vcxproj">
+ <Project>{92ae7622-5f58-4234-9a26-9ec71876b3f4}</Project>
+ </ProjectReference>
+ </ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C36612BD-22D3-4B95-85E2-7FDC4FC5D740}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
diff --git a/msvc/mono.external.targets b/msvc/mono.external.targets index e6c998118a4..022246be92d 100644 --- a/msvc/mono.external.targets +++ b/msvc/mono.external.targets @@ -106,6 +106,8 @@ <PropertyGroup> <_MonoSourceDir>$([System.IO.Path]::GetFullPath('$(MONO_DIR)').TrimEnd('\'))</_MonoSourceDir> <_MonoOutputDir>$([System.IO.Path]::GetFullPath('$(OutDir)'))</_MonoOutputDir> + <_MonoExternalBuildForceMSBuild Condition="'$(MONO_EXTERNAL_BUILD_FORCE_MSBUILD)' == 'true'">true</_MonoExternalBuildForceMSBuild> + <_MonoExternalBuildForceMSBuild Condition="'$(MONO_EXTERNAL_BUILD_FORCE_MSBUILD)' != 'true'">false</_MonoExternalBuildForceMSBuild> </PropertyGroup> <PropertyGroup> diff --git a/msvc/winsetup.bat b/msvc/winsetup.bat index a7b1c6290a7..44442f06d8c 100755 --- a/msvc/winsetup.bat +++ b/msvc/winsetup.bat @@ -32,7 +32,9 @@ mkdir "%CONFIG_H_TEMP%\.." 2>nul set CONFIG_H_TEMP="%CONFIG_H_TEMP%" REM Backup existing config.h into cygconfig.h if its not already replaced. -findstr /i /r /c:"#include *\"cygconfig.h\"" %CONFIG_H% >nul || copy /y %CONFIG_h% %CYG_CONFIG_H% +if exist %CONFIG_H% ( + findstr /i /r /c:"#include *\"cygconfig.h\"" %CONFIG_H% >nul || copy /y %CONFIG_h% %CYG_CONFIG_H% +) :: Extract MONO_VERSION from configure.ac. for /f "delims=[] tokens=2" %%a in ('findstr /b /c:"AC_INIT(mono, [" %CONFIGURE_AC%') do ( |