Author: akhaldi
Date: Sun Oct 12 22:59:32 2014
New Revision: 64704
URL:
http://svn.reactos.org/svn/reactos?rev=64704&view=rev
Log:
[CMAKE/MSVC]
* Introduce support for for MSVC native run-time checks. Set RUNTIME_CHECKS to TRUE to
enable it.
* Dedicated to Christoph von Wittich and all ReactOS devs that use MSVC builds ;)
CORE-8626
Modified:
trunk/reactos/cmake/CMakeMacros.cmake
trunk/reactos/cmake/msvc.cmake
trunk/reactos/dll/win32/kernel32/CMakeLists.txt
trunk/reactos/lib/pseh/i386/seh.s
trunk/reactos/lib/sdk/crt/except/i386/seh.s
trunk/reactos/lib/sdk/crt/startup/gs_support.c
trunk/reactos/lib/sdk/crt/startup/mscmain.c
Modified: trunk/reactos/cmake/CMakeMacros.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/CMakeMacros.cmake?re…
==============================================================================
--- trunk/reactos/cmake/CMakeMacros.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/CMakeMacros.cmake [iso-8859-1] Sun Oct 12 22:59:32 2014
@@ -502,6 +502,14 @@
if("${LIB}" MATCHES "msvcrt")
add_target_compile_definitions(${_module} _DLL __USE_CRTIMP)
target_link_libraries(${_module} msvcrtex)
+ if(MSVC)
+ if(RUNTIME_CHECKS)
+ if(NOT ${_module} STREQUAL "kernel32")
+ add_target_compile_flags(${_module} "/RTC1")
+ target_link_libraries(${_module} RunTmChk.lib)
+ endif()
+ endif()
+ endif()
endif()
target_link_libraries(${_module} lib${LIB})
add_dependencies(${_module} lib${LIB})
Modified: trunk/reactos/cmake/msvc.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/msvc.cmake?rev=64704…
==============================================================================
--- trunk/reactos/cmake/msvc.cmake [iso-8859-1] (original)
+++ trunk/reactos/cmake/msvc.cmake [iso-8859-1] Sun Oct 12 22:59:32 2014
@@ -80,6 +80,14 @@
if(NOT DEFINED USE_FOLDER_STRUCTURE)
set(USE_FOLDER_STRUCTURE FALSE)
endif()
+endif()
+
+if(NOT DEFINED RUNTIME_CHECKS)
+ set(RUNTIME_CHECKS FALSE)
+endif()
+
+if(RUNTIME_CHECKS)
+ add_definitions(-D__RUNTIME_CHECKS__)
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO
/SAFESEH:NO /NODEFAULTLIB /RELEASE")
Modified: trunk/reactos/dll/win32/kernel32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/CMakeLi…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/CMakeLists.txt [iso-8859-1] Sun Oct 12 22:59:32 2014
@@ -107,6 +107,10 @@
target_link_libraries(kernel32 wine chkstk ${PSEH_LIB})
+if(RUNTIME_CHECKS)
+ target_link_libraries(kernel32 RunTmChk.lib)
+endif()
+
add_importlibs(kernel32 ntdll)
add_pch(kernel32 k32.h SOURCE)
add_dependencies(kernel32 psdk errcodes asm)
Modified: trunk/reactos/lib/pseh/i386/seh.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/i386/seh.s?rev=64…
==============================================================================
--- trunk/reactos/lib/pseh/i386/seh.s [iso-8859-1] (original)
+++ trunk/reactos/lib/pseh/i386/seh.s [iso-8859-1] Sun Oct 12 22:59:32 2014
@@ -22,9 +22,12 @@
/* GLOBALS *******************************************************************/
+#ifndef __RUNTIME_CHECKS__
PUBLIC __global_unwind2
PUBLIC __local_unwind2
PUBLIC __abnormal_termination
+#endif
+
PUBLIC __except_handler2
PUBLIC __except_handler3
Modified: trunk/reactos/lib/sdk/crt/except/i386/seh.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/except/i386/se…
==============================================================================
--- trunk/reactos/lib/sdk/crt/except/i386/seh.s [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/except/i386/seh.s [iso-8859-1] Sun Oct 12 22:59:32 2014
@@ -25,8 +25,11 @@
PUBLIC __global_unwind2
PUBLIC __local_unwind2
PUBLIC __abnormal_termination
+
+#if !defined(__RUNTIME_CHECKS__) || (defined(__RUNTIME_CHECKS__) &&
!defined(_LIBCNT_))
PUBLIC __except_handler2
PUBLIC __except_handler3
+#endif
/* FUNCTIONS *****************************************************************/
Modified: trunk/reactos/lib/sdk/crt/startup/gs_support.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/startup/gs_sup…
==============================================================================
--- trunk/reactos/lib/sdk/crt/startup/gs_support.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/startup/gs_support.c [iso-8859-1] Sun Oct 12 22:59:32 2014
@@ -102,6 +102,7 @@
__declspec(noreturn) void __cdecl __report_gsfailure (ULONG_PTR);
+#ifndef _MSC_VER
__declspec(noreturn) void __cdecl
__report_gsfailure (ULONG_PTR StackCookie)
{
@@ -147,4 +148,4 @@
TerminateProcess (GetCurrentProcess (), STATUS_STACK_BUFFER_OVERRUN);
abort();
}
-
+#endif /* !_MSC_VER */
Modified: trunk/reactos/lib/sdk/crt/startup/mscmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/startup/mscmai…
==============================================================================
--- trunk/reactos/lib/sdk/crt/startup/mscmain.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/startup/mscmain.c [iso-8859-1] Sun Oct 12 22:59:32 2014
@@ -36,6 +36,18 @@
return TRUE;
}
+void Catch_RTC_Failure(int errType, const wchar_t *file, int line,
+ const wchar_t *module, const wchar_t *format, ...)
+{
+ /* FIXME: better failure routine */
+ __debugbreak();
+}
+
+void* __cdecl _CRT_RTC_INITW(void *res0, void **res1, int res2, int res3, int res4)
+{
+ return &Catch_RTC_Failure;
+}
+
static int initialized = 0;
void