When building this repo on Windows using MSVC, is /EHsc enabled by default?
- User
When building this repo on Windows using MSVC, is /EHsc enabled by default?
- User
User steering update: <user_input> You may read
setup.pyand undrstand the default flags, and what flags are set in cmake explicitly and implicitly. </user_input> Internal instruction: Re-evaluate the active plan using this user steering update. Classify it as ADD_TASK, MODIFY_TASK, CANCEL_TASK, or EXTRA_CONTEXT. Apply minimal-diff changes only to affected tasks and keep unaffected tasks active. Do not cancel/skip tasks unless the user explicitly cancels them. Acknowledge the steering briefly and state the course correction. Assistant
Yes,
/EHsc(which enables C++ exception handling) is enabled by default when building the Triton repository on Windows with MSVC.Here is why:
- Implicit CMake Default: CMake automatically injects
/EHscinto the defaultCMAKE_CXX_FLAGSfor MSVC builds. - Explicit Codebase Configuration (
CMakeLists.txt): The repository disables exception handling and RTTI for non-MSVC compilers (like GCC/Clang) using-fno-exceptions;-fno-rtti, but this behavior is explicitly omitted for MSVC:Instead, the MSVC-specific flags added are justcmakeif(NOT MSVC) set(TRITON_DISABLE_EH_RTTI_FLAGS "$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions;-fno-rtti>") else() # No disabling of exceptions or RTTI for MSVC endif()/nologo /bigobj /Zc:__STDC__ /Zc:preprocessor /permissive- /utf-8 /WX /wd4244 /wd4293 /wd4624. These append to the CMake defaults without clearing .
- Implicit CMake Default: CMake automatically injects
- User
Is there any cmake doc confirming that /EHsc is added by default?
- User
You're running in PowerShell. Don't use bash syntax. You may check the implementation in C:\Python312\Lib\site-packages\cmake\ .
Assistant
Yes, we can confirm this by looking directly at the CMake implementation that comes with the Python package.
CMake configures compiler defaults for the Windows-MSVC platform via the module
Windows-MSVC.cmake. If you check your local CMake package path:C:\Python312\Lib\site-packages\cmake\data\share\cmake-4.2\Modules\Platform\Windows-MSVC.cmakeYou will see how CMake dynamically constructs the default
CMAKE_CXX_FLAGS. Around line 257 (for a standard Windows build with an MSVC version newer than Visual Studio 2003):cmakeif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") # ... set(_FLAGS_CXX " -frtti -fexceptions") else() set(_RTC1 "-RTC1") set(_RTCc "-RTCc") set(_RTCs "-RTCs") set(_RTCu "-RTCu") set(_FLAGS_CXX "${_GR} /EHsc") # <--- Here is the default flag endif()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.