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 5 years ago
- Comments: 18 (10 by maintainers)
Hi @arttet
After a long time, I have been figuring out a bit more about this case because I realized that
clangdoes not manage runtime flags likeclang-clso the question is how did it solve the issue to put-MT -fsanitize=address? the answer is simple, it didn’t. Here, we go:-MT <arg> -> Specify name of main file output in depfile(doc here): it’s not related to runtime at all. Then, we were passing-fsanitize=addressas the argument so we were not linking against the ASan library for sure.-fsanitize=address -shared-libsaninstead. Now, we’re correctly linking with it (doc here).I thought it was important to share with you the results of this investigation. I have also gathered other interesting links related to this issue:
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.cppand make it run without Conan) and, finally, adding a simple-MTto 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;