conan: [bug] [clang] Wrong the runtime flag for requirements

If you use -s compiler.runtime=MT or -s compiler.runtime=MTd with Clang on Windows, you will get the error:

lld-link: error: /failifmismatch: mismatch detected for 'RuntimeLibrary':
>>> src/CMakeFiles/reproduce-bugs.dir/main.cpp.obj has value MT_StaticRelease
>>> fmt.lib(format.cc.obj) has value MD_DynamicRelease
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Environment Details (include every applicable attribute)

  • Operating System+version: Windows Server 2019
  • Compiler+version: Clang 12.0.0 with GNU-like command-line
  • Conan version: 1.39
  • Python version: 3.9.6

Steps to reproduce (Include if Applicable)

I have prepared the branch with my changes.

Logs (Executed commands with output) (Include/Attach if Applicable)

lld-link: error: /failifmismatch: mismatch detected for 'RuntimeLibrary':
>>> src/CMakeFiles/reproduce-bugs.dir/main.cpp.obj has value MT_StaticRelease
>>> fmt.lib(format.cc.obj) has value MD_DynamicRelease
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
ERROR: conanfile.py (reproduce-bugs/0.0.0): Error in build() method, line 60
	cmake.build()
	ConanException: Error 1 while executing cmake --build D:\a\reproduce-bugs\reproduce-bugs\build -- -j2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

Hi @arttet

I have opened one issue to improve the Clang-runtime-flags management: https://github.com/conan-io/conan/issues/9895 I’ll keep you posted.

Hi @arttet

I just updated my open PR and it seems to be working now: https://github.com/arttet/reproduce-bugs/pull/3

I was able to dig deeper into the issue (I had to create a minimal test.cpp and make it run without Conan) and, finally, adding a simple -MT to the CXXFLAGS was enough to work around the issue. I would like to open a new issue about improving the Clang runtime management because it’s true that Conan is not doing enough to handle it.

Hi @franramirez688

It looks good to me. So, I merged your PR. Could you please give me a couple of days to check other receipts? I’ll rewrite my receipts and give feedback about them.

There is another bug related to argument unused during compilation: ‘-stdlib=libstdc++’

Hi @franramirez688

Unfortunately, I can reproduce the bug. It seems you need to use another branch such as bug/MD;