From df43f0f0a045808d58aa855e755fac9b05df8229 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 18 Oct 2014 14:22:09 +0000 Subject: [PATCH] [CMAKE/MSVC] * Use the runtime checks globally in ReactOS now, not just for user mode modules. * We no longer need the MS support lib, as Timo kindly implemented one for ReactOS. * Rename the lib to runtmchk. [PSEH][CRT] * Remove some constrictions to seh.s source files, we no longer need them. [KERNEL32] * We no longer need to explicitly link to the runtime checks lib. [FREELDR][KEYBOARD][NTOS][SETUPLDR] * Link to the runtime checks lib when this mode is enabled. CORE-8626 svn path=/trunk/; revision=64807 --- reactos/boot/freeldr/freeldr/CMakeLists.txt | 6 ++++++ reactos/cmake/CMakeMacros.cmake | 8 -------- reactos/cmake/msvc.cmake | 6 ++++++ reactos/dll/keyboard/CMakeLists.txt | 4 ++++ reactos/dll/win32/kernel32/CMakeLists.txt | 5 ----- reactos/lib/pseh/i386/seh.s | 3 --- reactos/lib/sdk/crt/except/i386/seh.s | 3 --- reactos/ntoskrnl/CMakeLists.txt | 14 +++----------- reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt | 15 ++++----------- 9 files changed, 23 insertions(+), 41 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/CMakeLists.txt b/reactos/boot/freeldr/freeldr/CMakeLists.txt index b25d7f95340..1eac9b09303 100644 --- a/reactos/boot/freeldr/freeldr/CMakeLists.txt +++ b/reactos/boot/freeldr/freeldr/CMakeLists.txt @@ -213,6 +213,9 @@ target_link_libraries(freeldr_pe_dbg freeldr_common cportlib cmlib rtl libcntpr) if(STACK_PROTECTOR) target_link_libraries(freeldr_pe gcc_ssp) target_link_libraries(freeldr_pe_dbg gcc_ssp) +elseif(RUNTIME_CHECKS) + target_link_libraries(freeldr_pe runtmchk) + target_link_libraries(freeldr_pe_dbg runtmchk) endif() add_dependencies(freeldr_pe asm) @@ -273,6 +276,9 @@ target_link_libraries(setupldr_pe_dbg freeldr_common cportlib cmlib rtl libcntpr if(STACK_PROTECTOR) target_link_libraries(setupldr_pe gcc_ssp) target_link_libraries(setupldr_pe_dbg gcc_ssp) +elseif(RUNTIME_CHECKS) + target_link_libraries(setupldr_pe runtmchk) + target_link_libraries(setupldr_pe_dbg runtmchk) endif() add_dependencies(setupldr_pe asm) diff --git a/reactos/cmake/CMakeMacros.cmake b/reactos/cmake/CMakeMacros.cmake index b21cc87750e..85eff72da34 100644 --- a/reactos/cmake/CMakeMacros.cmake +++ b/reactos/cmake/CMakeMacros.cmake @@ -502,14 +502,6 @@ function(add_importlibs _module) 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}) diff --git a/reactos/cmake/msvc.cmake b/reactos/cmake/msvc.cmake index 3b57f793e5c..05cf755315a 100644 --- a/reactos/cmake/msvc.cmake +++ b/reactos/cmake/msvc.cmake @@ -88,6 +88,7 @@ endif() if(RUNTIME_CHECKS) add_definitions(-D__RUNTIME_CHECKS__) + add_compile_flags("/RTC1") endif() set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE") @@ -232,6 +233,11 @@ function(set_module_type_toolchain MODULE TYPE) elseif(${TYPE} STREQUAL "wdmdriver") add_target_link_flags(${MODULE} "/DRIVER:WDM") endif() + + if(RUNTIME_CHECKS) + target_link_libraries(${MODULE} runtmchk) + endif() + endfunction() # Define those for having real libraries diff --git a/reactos/dll/keyboard/CMakeLists.txt b/reactos/dll/keyboard/CMakeLists.txt index 78e8622b6cc..9190fd8f4b5 100644 --- a/reactos/dll/keyboard/CMakeLists.txt +++ b/reactos/dll/keyboard/CMakeLists.txt @@ -102,6 +102,10 @@ foreach(_keyboard_layout ${_keyboard_layouts}) add_target_link_flags(${_keyboard_layout} "-Wl,-T,${CMAKE_SOURCE_DIR}/kbdlayout.lds") endif() + if(RUNTIME_CHECKS) + target_link_libraries(${_keyboard_layout} runtmchk) + endif() + add_dependencies(${_keyboard_layout} psdk) add_cd_file(TARGET ${_keyboard_layout} DESTINATION reactos/system32 FOR all) endforeach() diff --git a/reactos/dll/win32/kernel32/CMakeLists.txt b/reactos/dll/win32/kernel32/CMakeLists.txt index d4720e30ae8..711182a6685 100644 --- a/reactos/dll/win32/kernel32/CMakeLists.txt +++ b/reactos/dll/win32/kernel32/CMakeLists.txt @@ -106,11 +106,6 @@ set_subsystem(kernel32 console) ################# END HACK ################# 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) diff --git a/reactos/lib/pseh/i386/seh.s b/reactos/lib/pseh/i386/seh.s index 7c2da45b340..6fde1e181f7 100644 --- a/reactos/lib/pseh/i386/seh.s +++ b/reactos/lib/pseh/i386/seh.s @@ -22,12 +22,9 @@ EXTERN _RtlUnwind@16:PROC /* GLOBALS *******************************************************************/ -#ifndef __RUNTIME_CHECKS__ PUBLIC __global_unwind2 PUBLIC __local_unwind2 PUBLIC __abnormal_termination -#endif - PUBLIC __except_handler2 PUBLIC __except_handler3 diff --git a/reactos/lib/sdk/crt/except/i386/seh.s b/reactos/lib/sdk/crt/except/i386/seh.s index 98f4b704322..6fde1e181f7 100644 --- a/reactos/lib/sdk/crt/except/i386/seh.s +++ b/reactos/lib/sdk/crt/except/i386/seh.s @@ -25,11 +25,8 @@ EXTERN _RtlUnwind@16:PROC 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 *****************************************************************/ diff --git a/reactos/ntoskrnl/CMakeLists.txt b/reactos/ntoskrnl/CMakeLists.txt index 86d62e7cc89..c2ba5f202c7 100644 --- a/reactos/ntoskrnl/CMakeLists.txt +++ b/reactos/ntoskrnl/CMakeLists.txt @@ -10,7 +10,6 @@ set(NTKRNLMP_SOURCE ${SOURCE}) set(NTKRNLMP_ASM_SOURCE ${ASM_SOURCE}) spec2def(ntoskrnl.exe ntoskrnl.spec ADD_IMPORTLIB) - add_asm_files(ntoskrnl_asm ${NTOSKRNL_ASM_SOURCE}) add_executable(ntoskrnl @@ -37,19 +36,12 @@ else() endif() endif() -target_link_libraries(ntoskrnl - cportlib - csq - ${PSEH_LIB} - cmlib - rtl - ${ROSSYM_LIB} - libcntpr - wdmguid - ioevent) +target_link_libraries(ntoskrnl cportlib csq ${PSEH_LIB} cmlib rtl ${ROSSYM_LIB} libcntpr wdmguid ioevent) if(STACK_PROTECTOR) target_link_libraries(ntoskrnl gcc_ssp) +elseif(RUNTIME_CHECKS) + target_link_libraries(ntoskrnl runtmchk) endif() add_importlibs(ntoskrnl hal kdcom bootvid) diff --git a/reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt b/reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt index 350019d6f00..2ff3e3d5314 100644 --- a/reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt +++ b/reactos/ntoskrnl/ntkrnlmp/CMakeLists.txt @@ -1,3 +1,4 @@ + include(../ntos.cmake) spec2def(ntkrnlmp.exe ../ntoskrnl.spec) @@ -32,19 +33,11 @@ endif() if(STACK_PROTECTOR) target_link_libraries(ntkrnlmp gcc_ssp) +elseif(RUNTIME_CHECKS) + target_link_libraries(ntkrnlmp runtmchk) endif() -target_link_libraries(ntkrnlmp - cportlib - csq - ${PSEH_LIB} - cmlib - rtl - ${ROSSYM_LIB} - libcntpr - wdmguid - ioevent) - +target_link_libraries(ntkrnlmp cportlib csq ${PSEH_LIB} cmlib rtl ${ROSSYM_LIB} libcntpr wdmguid ioevent) add_importlibs(ntkrnlmp hal kdcom bootvid) add_pch(ntkrnlmp ${REACTOS_SOURCE_DIR}/ntoskrnl/include/ntoskrnl.h NTKRNLMP_SOURCE) add_dependencies(ntkrnlmp psdk bugcodes asm)