[CMAKE][CONFIGURE] Enable runtime checks on MSVC by default.

Remove RTC switch from configure.cmd, now MSVC runtime checks are
supposed to be enabled/disabled via CMake define (-DRUNTIME_CHECKS=1)
Prepare for adding more dynamic analysis options
This commit is contained in:
Victor Perevertkin 2020-04-09 04:40:17 +03:00
parent 2a6bccb4ce
commit 92dfec219d
No known key found for this signature in database
GPG key ID: C750B7222E9C7830
9 changed files with 32 additions and 21 deletions

View file

@ -103,9 +103,12 @@ set_entrypoint(bootmgfw EfiEntry)
target_link_libraries(bootmgfw bootlib cportlib cmlib rtl libcntpr)
# dynamic analysis switches
if(STACK_PROTECTOR)
target_link_libraries(bootmgfw gcc_ssp)
elseif(RUNTIME_CHECKS)
endif()
if(RUNTIME_CHECKS)
target_link_libraries(bootmgfw runtmchk)
endif()
@ -148,9 +151,12 @@ endif()
target_link_libraries(rosload bootlib cportlib cmlib rtl libcntpr)
# dynamic analysis switches
if(STACK_PROTECTOR)
target_link_libraries(rosload gcc_ssp)
elseif(RUNTIME_CHECKS)
endif()
if(RUNTIME_CHECKS)
target_link_libraries(rosload runtmchk)
endif()

View file

@ -265,7 +265,7 @@ endif()
add_executable(freeldr_pe ${FREELDR_BASE_SOURCE})
add_executable(freeldr_pe_dbg EXCLUDE_FROM_ALL ${FREELDR_BASE_SOURCE})
set_target_properties(freeldr_pe freeldr_pe_dbg
set_target_properties(freeldr_pe freeldr_pe_dbg
PROPERTIES
ENABLE_EXPORTS TRUE
DEFINE_SYMBOL "")
@ -308,10 +308,13 @@ endif()
target_link_libraries(freeldr_pe freeldr_common cportlib cmlib rtl libcntpr)
target_link_libraries(freeldr_pe_dbg freeldr_common cportlib cmlib rtl libcntpr)
# dynamic analysis switches
if(STACK_PROTECTOR)
target_link_libraries(freeldr_pe gcc_ssp)
target_link_libraries(freeldr_pe_dbg gcc_ssp)
elseif(RUNTIME_CHECKS)
endif()
if(RUNTIME_CHECKS)
target_link_libraries(freeldr_pe runtmchk)
target_link_libraries(freeldr_pe_dbg runtmchk)
add_target_link_flags(freeldr_pe "/MERGE:.rtc=.text")

View file

@ -13,7 +13,7 @@ if /I "%1" == "/?" (
:help
echo Help for configure script
echo Syntax: path\to\source\configure.cmd [script-options] [Cmake-options]
echo Available script-options: Codeblocks, Eclipse, Makefiles, clang, VSSolution, RTC
echo Available script-options: Codeblocks, Eclipse, Makefiles, clang, VSSolution
echo Cmake-options: -DVARIABLE:TYPE=VALUE
goto quit
)
@ -62,7 +62,6 @@ if defined ROS_ARCH (
)
set BUILD_ENVIRONMENT=VS
set VS_SOLUTION=0
set VS_RUNTIME_CHECKS=0
echo Detected Visual Studio Environment !BUILD_ENVIRONMENT!!VS_VERSION!-!ARCH!
) else (
echo Error: Unable to detect build environment. Configure script failure.
@ -90,8 +89,6 @@ REM Parse command line parameters
echo. && echo Error: Creation of VS Solution files is not supported in a MinGW environment.
echo Please run this command in a [Developer] Command Prompt for Visual Studio.
goto quit
) else if /I "%1" == "RTC" (
echo. && echo Warning: RTC switch is ignored outside of a Visual Studio environment. && echo.
) else if /I "%1" NEQ "" (
echo %1| find /I "-D" > NUL
if %ERRORLEVEL% == 0 (
@ -128,9 +125,6 @@ REM Parse command line parameters
) else if "!ARCH!" == "arm" (
set CMAKE_ARCH=-A ARM
)
) else if /I "%1" == "RTC" (
echo Runtime checks enabled
set VS_RUNTIME_CHECKS=1
) else if /I "%1" NEQ "" (
echo %1| find /I "-D" > NUL
if %ERRORLEVEL% == 0 (
@ -197,9 +191,9 @@ if EXIST CMakeCache.txt (
if "%BUILD_ENVIRONMENT%" == "MinGW" (
cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%MINGW_TOOCHAIN_FILE% -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% %* "%REACTOS_SOURCE_DIR%"
) else if %USE_CLANG_CL% == 1 (
cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DUSE_CLANG_CL:BOOL=1 -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DUSE_CLANG_CL:BOOL=1 %* "%REACTOS_SOURCE_DIR%"
) else (
cmake -G %CMAKE_GENERATOR% %CMAKE_ARCH% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
cmake -G %CMAKE_GENERATOR% %CMAKE_ARCH% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% %* "%REACTOS_SOURCE_DIR%"
)
if %ERRORLEVEL% NEQ 0 (

View file

@ -107,6 +107,7 @@ foreach(_keyboard_layout ${_keyboard_layouts})
set_property(TARGET ${_keyboard_layout} PROPERTY C_STANDARD 99)
endif()
# dynamic analysis switches
if (STACK_PROTECTOR)
target_link_libraries(${_keyboard_layout} gcc_ssp)
endif()

View file

@ -34,9 +34,12 @@ else()
set_image_base(ntkrnlmp 0x80800000)
endif()
# dynamic analysis switches
if(STACK_PROTECTOR)
target_link_libraries(ntkrnlmp gcc_ssp)
elseif(RUNTIME_CHECKS)
endif()
if(RUNTIME_CHECKS)
target_link_libraries(ntkrnlmp runtmchk)
endif()

View file

@ -44,4 +44,5 @@ set(USERMODE TRUE CACHE BOOL
if(MSVC)
set(_PREFAST_ FALSE CACHE BOOL
"Whether to enable PREFAST while compiling.")
option(RUNTIME_CHECKS "Whether to enable runtime checks on MSVC" ON)
endif()

View file

@ -43,3 +43,7 @@ set(BUILD_MP TRUE CACHE BOOL
set(NEWSPRINTF FALSE CACHE BOOL
"Whether to compile the new sprintf.")
if(MSVC)
option(RUNTIME_CHECKS "Whether to enable runtime checks on MSVC" ON)
endif()

View file

@ -83,9 +83,12 @@ set(_PREFAST_ FALSE CACHE BOOL
"Whether to enable PREFAST while compiling.")
set(_VS_ANALYZE_ FALSE CACHE BOOL
"Whether to enable static analysis while compiling.")
else()
set(STACK_PROTECTOR FALSE CACHE BOOL
"Whether to enbable the GCC stack checker while compiling")
option(RUNTIME_CHECKS "Whether to enable runtime checks on MSVC" ON)
endif()
if(GCC)
option(STACK_PROTECTOR "Whether to enable the GCC stack checker while compiling" OFF)
endif()
set(USE_DUMMY_PSEH FALSE CACHE BOOL

View file

@ -151,10 +151,6 @@ if(MSVC_IDE AND (NOT DEFINED USE_FOLDER_STRUCTURE))
set(USE_FOLDER_STRUCTURE TRUE)
endif()
if(NOT DEFINED RUNTIME_CHECKS)
set(RUNTIME_CHECKS FALSE)
endif()
if(RUNTIME_CHECKS)
add_definitions(-D__RUNTIME_CHECKS__)
add_compile_flags("/RTC1")