conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.27k stars 981 forks source link

[bug] Error when compiling boost/1.76.0 on Windows with clang #14768

Open Drllap opened 1 year ago

Drllap commented 1 year ago

Environment details

Steps to reproduce

  1. A profile for clang version 16:
    [settings]
    os=Windows
    os_build=Windows   
    arch=x86_64        
    compiler=clang     
    compiler.version=16
    build_type=Debug   
    [options]
    [conf]
    [build_requires]
    [env]

    I call it ninja

  2. run conan install boost/1.76.0@ -pr ninja --build missing
  3. build failes

Logs

boost/1.76.0: Applying build-requirement: b2/4.8.0
boost/1.76.0: WARN: Build folder is dirty, removing it: C:\.conan\caa543\1
boost/1.76.0: Building your package in C:\.conan\caa543\1
boost/1.76.0: Generator txt created conanbuildinfo.txt
boost/1.76.0: Aggregating env generators
boost/1.76.0: Calling build()
WARN: replace_in_file didn't find pattern '/* thread_local */' in 'C:\.conan\707580\1\source_subfolder\boost\stacktrace\detail\libbacktrace_impls.hpp' file.
WARN: replace_in_file didn't find pattern '/* static __thread */' in 'C:\.conan\707580\1\source_subfolder\boost\stacktrace\detail\libbacktrace_impls.hpp' file.
WARN: replace_in_file didn't find pattern 'local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux ] ;' in 'C:\.conan\707580\1\source_subfold
er\tools\build\src\tools\gcc.jam' file.
WARN: replace_in_file didn't find pattern 'local no-threading = android beos haiku sgi darwin vxworks ;' in 'C:\.conan\707580\1\source_subfolder\tools\build\src\tools\gc
c.jam' file.
WARN: replace_in_file didn't find pattern '    <conditional>@numa' in 'C:\.conan\707580\1\source_subfolder\libs\fiber\build\Jamfile.v2' file.
boost/1.76.0: WARN: Patching user-config.jam
boost/1.76.0: WARN: 
using zlib : 1.2.12 : <include>"C:/Users/palli/.conan/data/zlib/1.2.12/_/_/package/c438badecc47e97cbd11f575a8aec4917a7cdf1f/include" <search>"C:/Users/palli/.conan/data/
zlib/1.2.12/_/_/package/c438badecc47e97cbd11f575a8aec4917a7cdf1f/lib" <name>zlib ;
using bzip2 : 1.0.8 : <include>"C:/Users/palli/.conan/data/bzip2/1.0.8/_/_/package/476df88c4386fb875187aee83f02b4ff597c4a04/include" <search>"C:/Users/palli/.conan/data/
bzip2/1.0.8/_/_/package/476df88c4386fb875187aee83f02b4ff597c4a04/lib" <name>bz2 ;
using "clang-win" :  :  C:/Program Files/LLVM/bin/clang++.exe :
 ;
boost/1.76.0: WARN: b2.exe -q numa=on target-os=windows architecture=x86 address-model=64 binary-format=pe abi=ms --layout=system --user-config=C:\.conan\707580\1\source
_subfolder\tools\build\user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=off --disable-iconv threadi
ng=multi visibility=hidden link=static variant=debug --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with
-exception --with-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-rand
om --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-wave toolset=clang-win pch=on link
flags="-stdlib=None" cxxflags="-fPIC -stdlib=None" install --prefix=C:\.conan\b742d1\1 -j8 --abbreviate-paths -d0 --debug-configuration --build-dir="C:\.conan\caa543\1" 
notice: found boost-build.jam at C:/.conan/707580/1/source_subfolder/boost-build.jam
notice: loading B2 from C:/.conan/707580/1/source_subfolder/tools/build/src/bootstrap.jam
warning: mismatched versions of B2 engine and core
warning: B2 engine (b2.exe) is 4.8.0
warning: B2 core (at C:/.conan/707580/1/source_subfolder/tools/build/src) is 4.4-git
notice: Searching 'C:\Users\palli' 'C:\Users\palli' 'C:/.conan/707580/1/source_subfolder/tools/build/src' 'C:/.conan/707580/1/source_subfolder/tools/build/src/kernel' 'C
:/.conan/707580/1/source_subfolder/tools/build/src/util' 'C:/.conan/707580/1/source_subfolder/tools/build/src/build' 'C:/.conan/707580/1/source_subfolder/tools/build/src
/tools' 'C:/.conan/707580/1/source_subfolder/tools/build/src/contrib' 'C:/.conan/707580/1/source_subfolder/tools/build/src/.' for site-config configuration file 'site-co
nfig.jam'.
notice: Configuration file 'site-config.jam' not found in 'C:\Users\palli' 'C:\Users\palli' 'C:/.conan/707580/1/source_subfolder/tools/build/src' 'C:/.conan/707580/1/sou
rce_subfolder/tools/build/src/kernel' 'C:/.conan/707580/1/source_subfolder/tools/build/src/util' 'C:/.conan/707580/1/source_subfolder/tools/build/src/build' 'C:/.conan/7
07580/1/source_subfolder/tools/build/src/tools' 'C:/.conan/707580/1/source_subfolder/tools/build/src/contrib' 'C:/.conan/707580/1/source_subfolder/tools/build/src/.'.   
notice: Loading explicitly specified user configuration file:
    C:\.conan\707580\1\source_subfolder\tools\build\user-config.jam
notice: Searching 'C:\.conan\707580\1\source_subfolder\tools\build' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from 'C:/.conan/707580/1/source_subfolder/tools/build'.
notice: [zlib] Using pre-installed library
notice: [zlib] Condition
notice: [bzip2] Using pre-installed library
notice: [bzip2] Condition
notice: [msvc-cfg] msvc-14.2 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe'
notice: [msvc-cfg] msvc-14.1 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.12.25827\bin\Hostx64\x64\cl.exe'
warning: toolset clang-win initialization:
warning: can not find user-provided command 'C:/Program' 'Files/LLVM/bin/clang++.exe'
warning: initialized from C:\.conan\707580\1\source_subfolder\tools\build\user-config.jam:5
C:/.conan/707580/1/source_subfolder/tools/build/src/tools\clang-win.jam:74: in clang-win.init from module clang-win
error: Cannot configure toolset clang-win: no 'clang-cl.exe' command found or given
C:/.conan/707580/1/source_subfolder/tools/build/src/build\toolset.jam:44: in toolset.using from module toolset
C:/.conan/707580/1/source_subfolder/tools/build/src/build\project.jam:1104: in using from module project-rules
C:\.conan\707580\1\source_subfolder\tools\build\user-config.jam:5: in modules.load from module user-config
C:/.conan/707580/1/source_subfolder/tools/build/src\build-system.jam:255: in load-config from module build-system
C:/.conan/707580/1/source_subfolder/tools/build/src\build-system.jam:449: in load-configuration-files from module build-system
C:/.conan/707580/1/source_subfolder/tools/build/src\build-system.jam:607: in load from module build-system
C:/.conan/707580/1/source_subfolder/tools/build/src/kernel\modules.jam:295: in import from module modules
C:/.conan/707580/1/source_subfolder/tools/build/src/kernel/bootstrap.jam:139: in boost-build from module
C:/.conan/707580/1/source_subfolder/boost-build.jam:17: in module scope from module

boost/1.76.0: 
boost/1.76.0: ERROR: Package '94827d0ba849bed27351c49199c8a58f222aed1b' build failed
boost/1.76.0: WARN: Build folder C:\.conan\caa543\1
ERROR: boost/1.76.0: Error in build() method, line 875
        self.run(full_command, run_environment=True)
        ConanException: Error 1 while executing b2.exe -q numa=on target-os=windows architecture=x86 address-model=64 binary-format=pe abi=ms --layout=system --user-conf
ig=C:\.conan\707580\1\source_subfolder\tools\build\user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv
=off --disable-iconv threading=multi visibility=hidden link=static variant=debug --with-atomic --with-chrono --with-container --with-context --with-contract --with-corou
tine --with-date_time --with-exception --with-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with
-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-wave t
oolset=clang-win pch=on linkflags="-stdlib=None" cxxflags="-fPIC -stdlib=None" install --prefix=C:\.conan\b742d1\1 -j8 --abbreviate-paths -d0 --debug-configuration --bui
ld-dir="C:\.conan\caa543\1"
memsharded commented 1 year ago

Hi @Drllap

Thanks for your report. It might be possible that some configuration is missing, the profiles for Windows clang might require more information, depending on what clang are you using. I'd recommend reading https://blog.conan.io/2022/10/13/Different-flavors-Clang-compiler-Windows.html, and checking the profiles and information there.

Once the setup is clear, I'd also recommend running it with a simple recipe, like conan new hello/0.1 -m=cmake_lib, then building it with the specific clang profile, checking the output and the binaries to see if everything is ok, then finally trying with the boost package. Please let us know, thanks!

Todiq commented 1 year ago

Hello @memsharded,

I followed this particular link yesterday (https://blog.conan.io/2022/10/13/Different-flavors-Clang-compiler-Windows.html) but I can't compile boost either. I am using conan 2.0.11. I put all the info in here https://github.com/conan-io/conan-center-index/issues/19941, but I don't know if the error comes from the recipe or from the conan client itself.

lukester1975 commented 1 year ago

There's a few issues with boost & clang-cl, I think. I've hacked this which works for me: https://github.com/lukester1975/conan-center-index/commit/900f3f4afff9725f823d29032b23f64af5fdd9be

May not be PR-worthy but hopefully the experts can take it from there...

My (jinja) clang-cl profile debug:

[settings]
arch=x86_64
build_type=Debug
compiler=clang
compiler.cppstd=20
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.runtime_version=v143
# MS have a tendency to bump clang version mid VS release. Cope with 15 and 16 in VS2022 here.
compiler.version={{ os.popen("clang-cl --version").read().removeprefix("clang version ").split(".")[0] }}
os=Windows

[conf]
tools.cmake.cmaketoolchain:generator=Visual Studio 17

[buildenv]
# Boost builds via conan will fail without the .exe suffix.
CC=clang-cl.exe
CXX=clang-cl.exe

HTH

Drllap commented 11 months ago

@lukester1975 does this:

[conf]
tools.cmake.cmaketoolchain:generator=Visual Studio 17

mean that I need to have VS17 installed?

I tried this with

[conf]
tools.cmake.cmaketoolchain:generator=Visual Studio 19

but then I get an error when conan tries to build bzip2

ERROR: bzip2/1.0.8: Error in generate() method, line 58
        tc.generate()
        ConanException: CMakeToolchain with compiler=clang and a CMake 'Visual Studio' generator requires VS16 or VS17 
lukester1975 commented 11 months ago

Ah, VS and its plethora of version numbers... 17 is 2022, 16 is 2019, 15 is 2017 :)

Drllap commented 11 months ago

@memsharded I had a look at the blog post you posted and tested a few things. Basically what I want to do is to compile with the LLVM/Clang option described in the post. I have installed the LLVM from the github page as described, so I now have updated my LLVM:

clang --version
clang version 17.0.5
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin

I also updated my conan:

conan --version
Conan version 1.62.0

I also have been experimenting with my clang conan profile. This is what I'm currently using:

[settings]
os=Windows
build_type=Debug
arch=x86
compiler=clang
compiler.version=17
# compiler.cppstd=17
# compiler.runtime=dynamic
# compiler.runtime_type=Release
# compiler.runtime_version=v143

[options]

[build_requires]

[env]

[buildenv]
#PATH=+(path)C:/LLVM-conan-test/bin
#CC=clang.exe
#CXX=clang.exe

[conf]
# tools.env.virtualenv:auto_use=True
tools.cmake.cmaketoolchain:generator=Ninja
# tools.cmake.cmaketoolchain:generator=Visual Studio 16

With it I'm able create test conan packet and compile it, so this workes just fine:

conan new clang_test/1.0.0 -m=cmake_exe
conan create . -pr clang

which outputs this:

clang_test/1.0.0 (test package): Running test()
clang_test/1.0.0: Hello World Debug!
  clang_test/1.0.0: _M_IX86 defined
  clang_test/1.0.0: __i386__ defined
  clang_test/1.0.0: _MSC_VER1929
  clang_test/1.0.0: _MSVC_LANG201402
  clang_test/1.0.0: __cplusplus201402
  clang_test/1.0.0: __clang_major__17

So everything looks fine.

But this still fails:

conan install boost/1.76.0@ -pr=clang --build missing

I attached the output in log.txt

Drllap commented 11 months ago

@memsharded For whatever reason the main error message was missing from the log.txt above, so here it is:

boost/1.76.0: ERROR: Package '5d77e285165cd0388d422d68c69a632e3ff8e9fb' build failed
boost/1.76.0: WARN: Build folder C:\.conan\79fe4b\1\build-debug
ERROR: boost/1.76.0: Error in build() method, line 887
        self.run(full_command)
        ConanException: Error 1 while executing b2 -q numa=on target-os=windows architecture=x86 address-model=32 binary
-format=pe abi=ms --layout=system --user-config=C:\.conan\f63257\1\src\tools\build\user-config.jam -sNO_ZLIB=0 -sNO_BZIP
2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=off --disable-iconv threading=multi vi
sibility=hidden link=static variant=debug --with-atomic --with-chrono --with-container --with-context --with-contract --
with-coroutine --with-date_time --with-exception --with-fiber --with-filesystem --with-graph --with-iostreams --with-jso
n --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serializat
ion --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-wave toolset=clang
-win pch=on linkflags="-stdlib=None" cxxflags="-fPIC -stdlib=None" install --prefix=C:\.conan\fb1d02\1 -j8 --abbreviate-
paths -d0 --debug-configuration --build-dir="C:\.conan\79fe4b\1\build-debug"

Doesn't seem to be a lot of info in it.

Is there a way to get the actual error emit from b2 or clang in the build() method?

Todiq commented 3 months ago

Probably linked to https://github.com/conan-io/conan-center-index/pull/18764

memsharded commented 3 months ago

Sorry for not being able to follow up on this. Issues with specific recipes in conan-center-index are typically too much to handle in this repo, which is dedicated to issues in the Conan client, and for those issues, things can be better prioritized if reduced to minimal reproducible cases, not a full recipe from ConanCenter, specially one large as boost.