Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove MSVC warning D9025 overriding '/MD' with '/MT' #443

Closed
andreasfertig opened this issue Feb 5, 2022 · 5 comments
Closed

Remove MSVC warning D9025 overriding '/MD' with '/MT' #443

andreasfertig opened this issue Feb 5, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@andreasfertig
Copy link
Owner

The Windows builds using cl.exe, for example "MSVC 2022 / LLVM 13 @ Windows Release" produce the warning D9025:

[1/12 0.1/sec] Building CXX object CMakeFiles\insights.dir\DPrint.cpp.obj
cl : Command line warning D9025 : overriding '/MD' with '/MT'
cl : Command line warning D9025 : overriding '/EHs' with '/EHs-'
cl : Command line warning D9025 : overriding '/EHc' with '/EHc-'
cl : Command line warning D9025 : overriding '/GR' with '/GR-'

The full output can be found here github.com/andreasfertig/cppinsights/runs/5076959142

The values MT, EHs-, ... are obtained from llvm-config github.com/andreasfertig/cppinsights/runs/5076959142:

-- llvm_config(LLVM_CXXFLAGS)=>/external:I D:\a\cppinsights\cppinsights\current\include    /EHs-c- /GR- -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS;

It looks likes cmake sets some kind of default (MD) which is not correctly overridden.

The values from llvm_config should be used for the build, other defaults should be removed.

Andreas

@andreasfertig andreasfertig added the enhancement New feature or request label Feb 5, 2022
@jcelerier
Copy link

I think that for CMake you should use https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html to set it to match what llvm gives.

@andreasfertig
Copy link
Owner Author

Hello @jcelerier,

thanks! How do I use these generator expressions? Like that:

set_property(TARGET insights PROPERTY
  MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

set_property(TARGET insights PROPERTY
  MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Releae>:Release>")

Setting both properties and cmake decides which one to use? Does this property also control EHs?

Andreas

@jcelerier
Copy link

The flags are

 MultiThreaded -> MT
 MultiThreadedDebug -> MTd

so

MultiThreaded$<$<CONFIG:Debug>:Debug>

will evaluate to MultiThreadedDebug if CMAKE_BUILD_TYPE=Debug and MultiThreaded in all the other cases. But I think that you should just set it to whatever llvm-config gives you because it's the one which is imposing it (you need to link with a CMAKE_BUILD_TYPE=Debug llvm if your own app is on debug mode and a CMAKE_BUILD_TYPE=Release llvm on release mode because the ABI of std:: and of some LLVM types do change anyways)

@jcelerier
Copy link

(my personal solution to sidestep this madness is to not use MSVC at all but Clang+libc++ on Windows which does not have these issues - a debug libc++ can be used by programs built in Release and conversely)

@andreasfertig
Copy link
Owner Author

Thanks!

C++ Insights uses both, Clang+libc++ on Windows and cl.exe + libc++. Mainly to get all errors and warnings and ensure that this setup works as well.

I see how to approach this. Thank you for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants