Open blockspacer opened 2 years ago
@memsharded
Is it possible to overcome that issue somehow (maybe i am doing something wrong)?
I just want to build code using clang-cl on windows and build fails due to issue above.
Note that build of conan new hello/0.1 -m=cmake_lib
also fails https://github.com/conan-io/conan/issues/12013#issuecomment-1236659063
Hi @blockspacer
Sorry, this is not clear. You are saying that you are using the new CMake integration, and have the configuration for it defined (for CMakeToolchain
and CMakeDeps
). Still, I can see the logs that the cmake
integration and the conanbuildinfo.cmake
are being used.
We have some tests that covers building with Clang in Windows, though it is true that this needs some work, and there is an ongoing effort to improve the Windows-Clang support. These are the current tests: https://github.com/conan-io/conan/blob/develop/conans/test/functional/toolchains/cmake/test_cmake_toolchain_win_clang.py
So the above conan new hello/0.1 -m=cmake_lib
should build with clang, at least our test suite is passing. It seems it is the other dependency hiredis
that is failing (because it is still using the legacy integrations), but we need to isolate and reproduce things in the most simple way to be able to fix them. So please, try the conan new
, but without adding extra stuff, no additional requirements, just the simplest profile that you can define, and let us know.
@memsharded
conan new hello/0.1 -m=cmake_lib
fails with ninja (message): The C++ compiler "C:/Program Files/LLVM/bin/clang-cl.exe"
is not able to compile a simple test program.
My conan profile:
[settings]
# Tested in Windows 10
os=Windows
arch=x86_64
compiler=clang
build_type=Debug
[options]
[tool_requires]
cmake/[>=3.23]
ninja/[>=1.11]
[buildenv]
CC=clang-cl.exe
CXX=clang-cl.exe
[build_requires]
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
[env]
CONAN_REVISIONS_ENABLED=1
CONAN_VERBOSE_TRACEBACK=1
CONAN_PRINT_RUN_COMMANDS=1
VERBOSE=1
CONAN_LOGGING_LEVEL=10
CONAN_USE_ALWAYS_SHORT_PATHS=1
Note that tools.cmake.cmaketoolchain:generator=Visual Studio 16
succeeds.
Conan version 1.51.3 SystemDirectory : C:\Windows\system32 Windows BuildNumber : 19044 Windows Version : 10.0.19044
clang-cl -v
clang version 14.0.6
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
Full log:
conan create . conan/stable -s build_type=Debug --profile clang_cl -pr:b=clang_cl --build missing
DEBUG :conan_api.py [176]: INIT: Using config 'C:\Users\den00\.conan\conan.conf' [2022-09-22 09:31:53,943]
DEBUG :tracer.py [156]: CONAN_API: create(name=None,version=None,user=conan,channel=stable,profile_names=['clang_cl'],settings=['build_type=Debug'],conf=None,options=None,env=None,test_folder=None,not_export=False,build_modes=['missing'],keep_source=False,keep_build=False,verify=None,manifests=None,manifests_interactive=None,remote_name=None,update=False,test_build_folder=None,lockfile=None,lockfile_out=None,ignore_dirty=False,profile_build=ProfileData(profiles=['clang_cl'], settings=None, options=None, env=None, conf=None),is_build_require=False,require_overrides=None) [2022-09-22 09:31:53,944]
DEBUG :profile_loader.py[120]: PROFILE LOAD: C:\Users\den00\.conan\profiles\default [2022-09-22 09:31:53,946]
DEBUG :profile_loader.py[120]: PROFILE LOAD: C:\Users\den00\.conan\profiles\clang_cl [2022-09-22 09:31:53,947]
DEBUG :profile_loader.py[120]: PROFILE LOAD: C:\Users\den00\.conan\profiles\default [2022-09-22 09:31:53,980]
DEBUG :profile_loader.py[120]: PROFILE LOAD: C:\Users\den00\.conan\profiles\clang_cl [2022-09-22 09:31:53,980]
DEBUG :export.py [114]: EXPORT: G:\files\conantest\conanfile.py [2022-09-22 09:31:54,025]
Exporting package recipe
hello/0.1@conan/stable exports_sources: Copied 1 '.txt' file: CMakeLists.txt
hello/0.1@conan/stable exports_sources: Copied 1 '.cpp' file: hello.cpp
hello/0.1@conan/stable exports_sources: Copied 1 '.h' file: hello.h
hello/0.1@conan/stable: The stored package has not changed
hello/0.1@conan/stable: Using the exported files summary hash as the recipe revision: 4fc80e430f8244be40256fab755f8c43
hello/0.1@conan/stable: Exported revision: 4fc80e430f8244be40256fab755f8c43
Configuration (profile_host):
[settings]
arch=x86_64
build_type=Debug
compiler=clang
compiler.version=14
os=Windows
[options]
[build_requires]
*: cmake/[>=3.23], ninja/[>=1.11]
[env]
CONAN_LOGGING_LEVEL=10
CONAN_PRINT_RUN_COMMANDS=1
CONAN_REVISIONS_ENABLED=1
CONAN_USE_ALWAYS_SHORT_PATHS=1
CONAN_VERBOSE_TRACEBACK=1
VERBOSE=1
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
[buildenv]
CC=clang-cl.exe
CXX=clang-cl.exe
Configuration (profile_build):
[settings]
arch=x86_64
build_type=Debug
compiler=clang
compiler.version=14
os=Windows
[options]
[build_requires]
*: cmake/[>=3.23], ninja/[>=1.11]
[env]
CONAN_LOGGING_LEVEL=10
CONAN_PRINT_RUN_COMMANDS=1
CONAN_REVISIONS_ENABLED=1
CONAN_USE_ALWAYS_SHORT_PATHS=1
CONAN_VERBOSE_TRACEBACK=1
VERBOSE=1
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
[buildenv]
CC=clang-cl.exe
CXX=clang-cl.exe
DEBUG :graph_builder.py[462]: GRAPH: new_node: hello/0.1@conan/stable [2022-09-22 09:31:54,074]
DEBUG :graph_builder.py[69]: GRAPH: Time to load deps 0.005983591079711914 [2022-09-22 09:31:54,077]
DEBUG :graph_builder.py[462]: GRAPH: new_node: cmake/3.24.1 [2022-09-22 09:31:54,092]
DEBUG :graph_builder.py[462]: GRAPH: new_node: ninja/1.11.0 [2022-09-22 09:31:54,098]
Version ranges solved
Version range '>=3.23' required by 'hello/0.1@conan/stable (test package)' resolved to 'cmake/3.24.1' in local cache
Version range '>=1.11' required by 'hello/0.1@conan/stable (test package)' resolved to 'ninja/1.11.0' in local cache
hello/0.1@conan/stable (test package): Installing package
Requirements
hello/0.1@conan/stable from local cache - Cache
Packages
hello/0.1@conan/stable:931d2edf6a5487d3fff35fc1858f3a207c7dd53f - Cache
Build requirements
cmake/3.24.1 from 'conancenter' - Cache
ninja/1.11.0 from 'conancenter' - Cache
Build requirements packages
cmake/3.24.1:01edd76db8e16db9b38c3cca44ec466a9444c388 - Cache
ninja/1.11.0:01edd76db8e16db9b38c3cca44ec466a9444c388 - Cache
Installing (downloading, building) binaries...
cmake/3.24.1: Already installed!
cmake/3.24.1: Appending PATH environment variable: C:\Users\den00\.conan\data\cmake\3.24.1\_\_\package\01edd76db8e16db9b38c3cca44ec466a9444c388\bin
hello/0.1@conan/stable: Already installed!
ninja/1.11.0: Already installed!
hello/0.1@conan/stable (test package): Applying build-requirement: cmake/3.24.1
hello/0.1@conan/stable (test package): Applying build-requirement: ninja/1.11.0
hello/0.1@conan/stable (test package): Generator 'VirtualRunEnv' calling 'generate()'
hello/0.1@conan/stable (test package): Generator 'VirtualBuildEnv' calling 'generate()'
hello/0.1@conan/stable (test package): Generator 'CMakeDeps' calling 'generate()'
hello/0.1@conan/stable (test package): Generator 'CMakeToolchain' calling 'generate()'
hello/0.1@conan/stable (test package): Generator txt created conanbuildinfo.txt
hello/0.1@conan/stable (test package): Aggregating env generators
hello/0.1@conan/stable (test package): Generated conaninfo.txt
hello/0.1@conan/stable (test package): Generated graphinfo
DEBUG :build.py [19]: BUILD: folder 'G:\files\conantest\test_package' [2022-09-22 09:31:54,863]
DEBUG :build.py [20]: BUILD: Conanfile at 'G:\files\conantest\test_package\conanfile.py' [2022-09-22 09:31:54,863]
Using lockfile: 'G:\files\conantest\test_package/conan.lock'
Using cached profile from lockfile
DEBUG :build.py [11]: Call conanfile.build() with files in build folder: ['CMakeCache.txt', 'CMakeFiles', 'example.exe', 'example.lib', 'example.pdb'] [2022-09-22 09:31:54,942]
hello/0.1@conan/stable (test package): Calling build()
hello/0.1@conan/stable (test package): CMake command: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="G:/files/conantest/test_package/build/generators/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Debug" "G:\files\conantest\test_package\."
----Running------
> "G:\files\conantest\test_package\build\generators\conanbuild.bat" && cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="G:/files/conantest/test_package/build/generators/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Debug" "G:\files\conantest\test_package\."
-----------------
Capturing current environment in G:\files\conantest\test_package\build\generators\deactivate_conanbuildenv-debug-x86_64.bat
Configuring environment variables
-- Using Conan toolchain: G:/files/conantest/test_package/build/generators/conan_toolchain.cmake
-- The CXX compiler identification is Clang 14.0.6 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe - broken
CMake Error at C:/Users/den00/.conan/data/cmake/3.24.1/_/_/package/01edd76db8e16db9b38c3cca44ec466a9444c388/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake:62 (message):
The C++ compiler
"C:/Program Files/LLVM/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: G:/files/conantest/test_package/build/Debug/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Users/den00/.conan/data/ninja/1.11.0/_/_/package/01edd76db8e16db9b38c3cca44ec466a9444c388/bin/ninja.exe cmTC_3c9ce && [1/2] Building CXX object CMakeFiles\cmTC_3c9ce.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_3c9ce.exe
FAILED: cmTC_3c9ce.exe
cmd.exe /C "cd . && C:\Users\den00\.conan\data\cmake\3.24.1\_\_\package\01edd76db8e16db9b38c3cca44ec466a9444c388\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_3c9ce.dir --rc=clang --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\LLVM\bin\lld-link.exe /nologo CMakeFiles\cmTC_3c9ce.dir\testCXXCompiler.cxx.obj /out:cmTC_3c9ce.exe /implib:cmTC_3c9ce.lib /pdb:cmTC_3c9ce.pdb /version:0.0 -m64 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "clang /fo CMakeFiles\cmTC_3c9ce.dir/manifest.res CMakeFiles\cmTC_3c9ce.dir/manifest.rc" failed (exit code 1) with the following output:
clang: error: no such file or directory: '/fo'
clang: error: no such file or directory: 'CMakeFiles\cmTC_3c9ce.dir/manifest.res'
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "G:/files/conantest/test_package/build/Debug/CMakeFiles/CMakeOutput.log".
See also "G:/files/conantest/test_package/build/Debug/CMakeFiles/CMakeError.log".
ERROR: Traceback (most recent call last):
File "C:\Python310\lib\site-packages\conans\errors.py", line 34, in conanfile_exception_formatter
yield
File "C:\Python310\lib\site-packages\conans\client\conanfile\build.py", line 16, in run_build_method
conanfile.build()
File "G:\files\conantest\test_package\conanfile.py", line 21, in build
cmake.configure()
File "C:\Python310\lib\site-packages\conan\tools\cmake\cmake.py", line 97, in configure
self._conanfile.run(command)
File "C:\Python310\lib\site-packages\conans\model\conan_file.py", line 443, in run
raise ConanException("Error %d while executing %s" % (retcode, command))
conans.errors.ConanException: Error 1 while executing cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="G:/files/conantest/test_package/build/generators/conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Debug" "G:\files\conantest\test_package\."
There is something weird in your log, the hello
package seems to already exist, like it was created previously succesfully, and it is failing in the test_package
step only:
hello/0.1@conan/stable from local cache - Cache
Then, a couple of hints:
generators = "VirtualBuildEnv"
, to inject correctly the [buildenv]
, or use the tools.env.virtualenv:auto_use=True
conf to enable this (2.0-compatible behavior)ClangCL
is intended to be run with the Visual Studio generators, while if using Ninja, the clang
compiler frontend is the one that correctly works, but not clang-cl
. Have you tried that?
I'm trying to build package that depends on hiredis/1.0.2 with clang-cl conan profile. Build fails and only known to me way to fix it is to manyally modify all recipes from conan-center-index (that i use as dependencies) with
tools.vcvars(self.settings, only_diff=False):
. Bug related to https://github.com/conan-io/conan/issues/6577My conan profile:
Environment Details (include every applicable attribute)
Steps to reproduce (Include if Applicable)
Build anything with clang-cl profile
Logs (Executed commands with output) (Include/Attach if Applicable)