conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
960 stars 1.77k forks source link

[package] <spdlog>/<1.14.1>: use_std_fmt option not working #25185

Open rdong8 opened 1 month ago

rdong8 commented 1 month ago

Description

The use_std_fmt for spdlog does not work properly. It is supposed to make spdlog use the (C++20 standard format library)[https://en.cppreference.com/w/cpp/utility/format/format] instead of fmt, but enabling it seems to simply stop fmt from being included as a dependency without actually using the standard format facilities.

Package and Environment Details

Conan profile

Host profile: [settings] arch=x86_64 build_type=Release compiler=clang compiler.cppstd=23 compiler.libcxx=libc++ compiler.version=18 os=Linux [buildenv] CC=clang CXX=clang++

Build profile: [settings] arch=x86_64 build_type=Release compiler=clang compiler.cppstd=23 compiler.libcxx=libc++ compiler.version=18 os=Linux [buildenv] CC=clang CXX=clang++

Steps to reproduce

The full example code is here:

example.zip

Note that the code in example.cpp comes from user_defined_example in spdlog's own example code.

make conan config build

Logs

Click to expand log ``` BUILD_DIR=build/ \ conan \ install . \ -b missing \ -s build_type=Release \ -s "&:build_type=Debug" ======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=clang compiler.cppstd=23 compiler.libcxx=libc++ compiler.version=18 os=Linux &:build_type=Debug [buildenv] CC=clang CXX=clang++ Profile build: [settings] arch=x86_64 build_type=Release compiler=clang compiler.cppstd=23 compiler.libcxx=libc++ compiler.version=18 os=Linux [buildenv] CC=clang CXX=clang++ ======== Computing dependency graph ======== Graph root conanfile.py: /home/rd8/tmp/spdlog/conanfile.py Requirements spdlog/1.14.1#972bbf70be1da4bc57ea589af0efde03 - Cache ======== Computing necessary packages ======== Requirements spdlog/1.14.1#972bbf70be1da4bc57ea589af0efde03:f5531dce08d48188ae2f58763ed909900b521a32#e4e664ca7351fdfe34910221589faee0 - Cache ======== Installing packages ======== spdlog/1.14.1: Already installed! (1 of 1) WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'cpp_info.names' used in: spdlog/1.14.1 ======== Finalizing install (deploy, generators) ======== conanfile.py: Writing generators to /home/rd8/tmp/spdlog/build/Debug/generators conanfile.py: Generator 'CMakeDeps' calling 'generate()' conanfile.py: CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(spdlog) target_link_libraries(... spdlog::spdlog) conanfile.py: Calling generate() conanfile.py: Generators folder: /home/rd8/tmp/spdlog/build/Debug/generators conanfile.py: CMakeToolchain generated: conan_toolchain.cmake conanfile.py: CMakeToolchain: Preset 'conan-debug' added to CMakePresets.json. (cmake>=3.23) cmake --preset conan-debug (cmake<3.23) cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Debug conanfile.py: CMakeToolchain generated: /home/rd8/tmp/spdlog/build/Debug/generators/CMakePresets.json conanfile.py: Generating aggregated env files conanfile.py: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] Install finished successfully cmake \ -B build/ \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_MAKE_PROGRAM=ninja \ -DCMAKE_TOOLCHAIN_FILE=build//Debug/generators/conan_toolchain.cmake \ -G "Ninja Multi-Config" \ -S . -- Using Conan toolchain: /home/rd8/tmp/spdlog/build/Debug/generators/conan_toolchain.cmake -- Conan toolchain: Defining architecture flag: -m64 -- Conan toolchain: Defining libcxx as C++ flags: -stdlib=libc++ -- Conan toolchain: C++ Standard 23 with extensions OFF -- The CXX compiler identification is Clang 18.1.6 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Conan: Component target declared 'spdlog::spdlog' -- Configuring done (0.3s) -- Generating done (0.0s) -- Build files have been written to: /home/rd8/tmp/spdlog/build cmake \ --build build/ \ --config Debug \ -j \ -t example \ -v Change Dir: '/home/rd8/tmp/spdlog/build' Run Build Command(s): ninja -v -f build-Debug.ninja example [1/4] "/usr/bin/clang-scan-deps" -format=p1689 -- /usr/bin/clang++ -DSPDLOG_COMPILED_LIB -DSPDLOG_USE_STD_FORMAT -DCMAKE_INTDIR=\"Debug\" -isystem /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include -m64 -stdlib=libc++ -g -std=c++23 -x c++ /home/rd8/tmp/spdlog/example.cpp -c -o CMakeFiles/example.dir/Debug/example.cpp.o -resource-dir "/usr/bin/../lib/clang/18" -MT CMakeFiles/example.dir/Debug/example.cpp.o.ddi -MD -MF CMakeFiles/example.dir/Debug/example.cpp.o.ddi.d > CMakeFiles/example.dir/Debug/example.cpp.o.ddi.tmp && mv CMakeFiles/example.dir/Debug/example.cpp.o.ddi.tmp CMakeFiles/example.dir/Debug/example.cpp.o.ddi [2/4] /var/lib/snapd/snap/cmake/1413/bin/cmake -E cmake_ninja_dyndep --tdi=CMakeFiles/example.dir/Debug/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=CMakeFiles/example.dir/Debug/CXX.dd @CMakeFiles/example.dir/Debug/CXX.dd.rsp [3/4] /usr/bin/clang++ -DSPDLOG_COMPILED_LIB -DSPDLOG_USE_STD_FORMAT -DCMAKE_INTDIR=\"Debug\" -isystem /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include -m64 -stdlib=libc++ -g -std=c++23 -MD -MT CMakeFiles/example.dir/Debug/example.cpp.o -MF CMakeFiles/example.dir/Debug/example.cpp.o.d @CMakeFiles/example.dir/Debug/example.cpp.o.modmap -o CMakeFiles/example.dir/Debug/example.cpp.o -c /home/rd8/tmp/spdlog/example.cpp FAILED: CMakeFiles/example.dir/Debug/example.cpp.o /usr/bin/clang++ -DSPDLOG_COMPILED_LIB -DSPDLOG_USE_STD_FORMAT -DCMAKE_INTDIR=\"Debug\" -isystem /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include -m64 -stdlib=libc++ -g -std=c++23 -MD -MT CMakeFiles/example.dir/Debug/example.cpp.o -MF CMakeFiles/example.dir/Debug/example.cpp.o.d @CMakeFiles/example.dir/Debug/example.cpp.o.modmap -o CMakeFiles/example.dir/Debug/example.cpp.o -c /home/rd8/tmp/spdlog/example.cpp In file included from /home/rd8/tmp/spdlog/example.cpp:1: In file included from /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include/spdlog/spdlog.h:12: In file included from /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include/spdlog/common.h:10: In file included from /usr/bin/../include/c++/v1/chrono:837: In file included from /usr/bin/../include/c++/v1/__chrono/formatter.h:23: In file included from /usr/bin/../include/c++/v1/__chrono/ostream.h:30: In file included from /usr/bin/../include/c++/v1/__format/format_functions.h:19: /usr/bin/../include/c++/v1/__format/format_arg_store.h:167:17: error: static assertion failed due to requirement '__arg != __arg_t::__none': the supplied type is not formattable 167 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/bin/../include/c++/v1/__format/format_arg_store.h:214:54: note: in instantiation of function template specialization 'std::__format::__create_format_arg' requested here 214 | basic_format_arg<_Context> __arg = __format::__create_format_arg<_Context>(__args); | ^ /usr/bin/../include/c++/v1/__format/format_arg_store.h:249:19: note: in instantiation of function template specialization 'std::__format::__create_packed_storage' requested here 249 | __format::__create_packed_storage(__storage.__types_, __storage.__values_, __args...); | ^ /usr/bin/../include/c++/v1/__format/format_functions.h:70:10: note: in instantiation of member function 'std::__format_arg_store::__format_arg_store' requested here 70 | return _VSTD::__format_arg_store<_Context, _Args...>(__args...); | ^ /usr/bin/../include/c++/v1/__config:880:17: note: expanded from macro '_VSTD' 880 | # define _VSTD std | ^ /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include/spdlog/logger.h:326:72: note: in instantiation of function template specialization 'std::make_format_args' requested here 326 | fmt_lib::vformat_to(std::back_inserter(buf), fmt, fmt_lib::make_format_args(args...)); | ^ /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include/spdlog/logger.h:80:9: note: in instantiation of function template specialization 'spdlog::logger::log_' requested here 80 | log_(loc, lvl, details::to_string_view(fmt), std::forward(args)...); | ^ /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include/spdlog/logger.h:85:9: note: in instantiation of function template specialization 'spdlog::logger::log' requested here 85 | log(source_loc{}, lvl, fmt, std::forward(args)...); | ^ /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include/spdlog/logger.h:140:9: note: in instantiation of function template specialization 'spdlog::logger::log' requested here 140 | log(level::info, fmt, std::forward(args)...); | ^ /home/rd8/.conan2/p/b/spdlo5d2aaeb64c977/p/include/spdlog/spdlog.h:168:27: note: in instantiation of function template specialization 'spdlog::logger::info' requested here 168 | default_logger_raw()->info(fmt, std::forward(args)...); | ^ /home/rd8/tmp/spdlog/example.cpp:19:39: note: in instantiation of function template specialization 'spdlog::info' requested here 19 | void user_defined_example() { spdlog::info("user defined type: {}", my_type(14)); } | ^ /usr/bin/../include/c++/v1/__format/format_arg_store.h:167:23: note: expression evaluates to '0 != 0' 167 | static_assert(__arg != __arg_t::__none, "the supplied type is not formattable"); | ~~~~~~^~~~~~~~~~~~~~~~~~ /usr/bin/../include/c++/v1/__format/format_arg_store.h:205:12: error: no matching constructor for initialization of 'basic_format_arg' 205 | return basic_format_arg<_Context>{__arg, __value}; | ^ ~~~~~~~~~~~~~~~~ /usr/bin/../include/c++/v1/__format/format_arg.h:251:34: note: candidate constructor not viable: no known conversion from 'my_type' to '__basic_format_arg_value' for 2nd argument 251 | _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(__format::__arg_t __type, | ^ 252 | __basic_format_arg_value<_Context> __value) noexcept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/bin/../include/c++/v1/__format/format_arg.h:225:28: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided 225 | class _LIBCPP_TEMPLATE_VIS basic_format_arg { | ^~~~~~~~~~~~~~~~ /usr/bin/../include/c++/v1/__format/format_arg.h:225:28: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided 225 | class _LIBCPP_TEMPLATE_VIS basic_format_arg { | ^~~~~~~~~~~~~~~~ /usr/bin/../include/c++/v1/__format/format_arg.h:229:25: note: candidate constructor not viable: requires 0 arguments, but 2 were provided 229 | _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept : __type_{__format::__arg_t::__none} {} | ^ 2 errors generated. ninja: build stopped: subcommand failed. make: *** [Makefile:27: build] Error 1 ```
Ahajha commented 1 month ago

I did some experimenting - I can reproduce this, but I think this might actually be a spdlog bug. This works using clang 20, but fails with clang 16 and 18. Or maybe not... might have done something incorrectly. Will keep testing.

Ahajha commented 1 month ago

Okay did a proper test using only spdlog, and I do believe it's a bug on their part. If I go to their main repo and do just

cmake -B build -DCMAKE_C_COMPILER=clang-16 -DCMAKE_CXX_COMPILER=clang++-16 -DSPDLOG_USE_STD_FORMAT=ON -DCMAKE_CXX_FLAGS="-stdlib=libc++" -G Ninja
cmake --build build

This also repros with clang 18 and 20. I can do some more testing, it's possible it's failing with its clang + libc++ handling.

tt4g commented 1 month ago

It seems to be a LLVM bug: llvm/llvm-project#66466 I think you can install the library by not building example.cpp in spdlog.