[bug] zlib doesn't compile on windows with clang
Describe the bug
Environment
[settings]
os=Windows
arch=x86_64
compiler=clang
compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=18
[buildenv]
CC="C:/Program Files/LLVM/bin/clang.exe"
CXX="C:/Program Files/LLVM/bin/clang++.exe"
package
zlib/1.2.13
It fails to build with the following message:
zlib/1.2.13: Running CMake.build()
zlib/1.2.13: RUN: cmake --build "C:\Users\me\.conan2\p\b\zlib2ee4129c391ac\b\build\Debug" -- -j8
[1/17] Generating zlib1rc.obj
FAILED: zlib1rc.obj C:/Users/me/.conan2/p/b/zlib2ee4129c391ac/b/build/Debug/zlib1rc.obj
cmd.exe /C "cd /D C:\Users\me\.conan2\p\b\zlib2ee4129c391ac\b\build\Debug && "C:\Program Files\LLVM15\bin\llvm-rc.exe" -D GCC_WINDRES -I C:/Users/me/.conan2/p/b/zlib2ee4129c391ac/b/src -I C:/Users/me/.conan2/p/b/zlib2ee4129c391ac/b/build/Debug -o C:/Users/me/.conan2/p/b/zlib2ee4129c391ac/b/build/Debug/zlib1rc.obj -i C:/Users/me/.conan2/p/b/zlib2ee4129c391ac/b/src/win32/zlib1.rc"
clang: error: no such file or directory: 'C:/Users/me/.conan2/p/b/zlib2ee4129c391ac/b/build/Debug/zlib1rc.obj'
clang: error: no input files
llvm-rc: Preprocessing failed.
ninja: build stopped: subcommand failed.
zlib/1.2.13: ERROR:
Package '414a6140a48e12ab12d341df293047babc0550bb' build failed
zlib/1.2.13: WARN: Build folder C:\Users\me\.conan2\p\b\zlib2ee4129c391ac\b\build\Debug
ERROR: zlib/1.2.13: Error in build() method, line 86
cmake.build()
ConanException: Error 1 while executing
How to reproduce it
I'd really appreciate if someone could pass me some setting, flag, configuration, so I could make it compile on windows with clang
Hi @reawakingFudge
If you check https://blog.conan.io/2022/10/13/Different-flavors-Clang-compiler-Windows.html
It seems you are in the case of LLVM/Clang, and the profile would be missing some settings:
[settings]
os=Windows
arch=x86_64
build_type=Release
compiler=clang
compiler.version=13
compiler.cppstd=gnu14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.runtime_version=v143
[buildenv]
PATH=+(path)C:/ws/LLVM/Clang13/bin
PATH+=(path)C:/ws/msys64/mingw64/bin
(the blog post might not be fully up to date).
When reporting issues against the client, the suggestions in https://github.com/conan-io/conan-center-index/issues/26663#issuecomment-2674472842 of using a conan new cmake_lib template would be better.
I have compiler version 18, so cppstd gnu14 doesn't work. I use 20 instead.
However, I added the compiler.runtime settings and the paths.
Build failure still persists.
I'm really sad to hear, that packages are tested only with a single compiler on the windows platform and MSVC at that (because it doesn't report lots of issues in the code).
I'm really sad to hear, that packages are tested only with a single compiler on the windows platform and MSVC at that (because it doesn't report lots of issues in the code).
Market share for MSVC in Windows is massive, and ConanCenter CI is already very large, very expensive to run, and also costly to maintain and support. There are plans to add more builds for different ones but it takes time. Take into account that even only MSVC compiler is used in Windows, there are still several builds (shared/static, VS 16 and VS 17, etc), and packages also build multiple versions, a package like boost supports like 10 different versions, and building each one takes some time, now the number of combinations to build takes a huge amount of resources.
In any case, it is not the purpose of ConanCenter to report issues in the code itself, but to build packages, not sure if you mean the recipe code or the library code. For the library code, gcc, clang, and apple-clang compilers are used in other platforms, that should be pretty good coverage.
I'll try to reproduce a build of zlib with clang on Windows and let you know.
It seems it works fine here, with the profile used in the blog post:
[settings]
os=Windows
arch=x86_64
build_type=Release
compiler=clang
compiler.version=16
compiler.cppstd=gnu14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.runtime_version=v143
[buildenv]
PATH=+(path)C:/ws/LLVM/Clang16/bin
PATH+=(path)C:/ws/msys64/mingw64/bin
then
$ conan install --requires=zlib/1.3.1 -pr=clang.profile --build=missing
And it builds correctly using Clang, it can be seen in the output:
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/ws/LLVM/clang16/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - do
The problem is your profile.
You are declaring compiler.libcxx=libstdc++11, which is not compatible with the LLVM/Clang that you are using.
As the blog post describes, LLVM/Clang is using the VS backend, and as such, it must use the VS runtime, which is defined by:
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.runtime_version=v143
Please fix your profile and try again and let us know.
Hi @reawakingFudge
Any further feedback?
Your profile was incorrect, you were using "msys2 backend" settings, for LLVM/CLang, which uses MSVC backed runtime. With the above profile that I provided, things seems to work correctly.
Closing this ticket as staled and not able to reproduce. Please comment or create a new ticket if you have further feedback. Thanks!