[PATCH] D155431: [CMake] Clean up old code for handling MSVC runtime setting the old way

Yury Bura via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 06:07:09 PDT 2023


yurybura added a comment.

In D155431#4651667 <https://reviews.llvm.org/D155431#4651667>, @mstorsjo wrote:

> In D155431#4651666 <https://reviews.llvm.org/D155431#4651666>, @yurybura wrote:
>
>>> That define should be set implicitly if `CMAKE_MSVC_RUNTIME_LIBRARY` is set to one of the debug choices, no?
>>
>> I think, no. At least I cannot find information about this in CMake documentation <https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html>.
>
> It's not set explicitly by CMake, but if you set `CMAKE_MSVC_RUNTIME_LIBRARY` to `MultiThreadedDebug` or `MultiThreadedDebugDLL`, it passes `-MTd` or `-MDd` to the compiler. When the compiler gets either of those, it implicitly sets `-D_DEBUG`. Example:
>
>   $ cat crtdefs.c 
>   #ifdef _DEBUG
>   #error _DEBUG
>   #endif
>   $ cl -c crtdefs.c -MDd
>   Microsoft (R) C/C++ Optimizing Compiler Version 19.30.30705 for x64
>   Copyright (C) Microsoft Corporation.  All rights reserved.
>   
>   crtdefs.c
>   crtdefs.c(2): fatal error C1189: #error:  _DEBUG

Once again, the default value for CMAKE_MSVC_RUNTIME_LIBRARY is `MultiThreaded$<$<CONFIG:Debug>:Debug>DLL` for the entire LLVM build, `/D_DEBUG` is added to CMAKE_CXX_FLAGS_DEBUG. The `compiler-rt` project overwrites CMAKE_MSVC_RUNTIME_LIBRARY, but does not change other compiler flags that conflict with the modified CRT version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155431/new/

https://reviews.llvm.org/D155431



More information about the llvm-commits mailing list