Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1.15.1 breaks build for MSVC v140 #3336

Closed
csandmann opened this issue Feb 6, 2025 · 8 comments
Closed

Patch 1.15.1 breaks build for MSVC v140 #3336

csandmann opened this issue Feb 6, 2025 · 8 comments

Comments

@csandmann
Copy link

csandmann commented Feb 6, 2025

Issue

Since version 1.15.1 the MSVC v140 build breaks with the attached errors.

cl : Command line warning D9002: ignoring unknown option '/Zc:__cplusplus' [spdlog\build\spdlog.vcxproj]
  spdlog.cpp
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2327: 'fmt::v11::basic_specs::data_': is not a type name, static, or enumerator [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2065: 'data_': undeclared identifier [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2338:  [spdlog\build\spdlog.vcxproj]
  stdout_sinks.cpp
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2327: 'fmt::v11::basic_specs::data_': is not a type name, static, or enumerator [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2065: 'data_': undeclared identifier [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2338:  [spdlog\build\spdlog.vcxproj]
  color_sinks.cpp
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2327: 'fmt::v11::basic_specs::data_': is not a type name, static, or enumerator [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2065: 'data_': undeclared identifier [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2338:  [spdlog\build\spdlog.vcxproj]
  file_sinks.cpp
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2327: 'fmt::v11::basic_specs::data_': is not a type name, static, or enumerator [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2065: 'data_': undeclared identifier [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2338:  [spdlog\build\spdlog.vcxproj]
  async.cpp
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2327: 'fmt::v11::basic_specs::data_': is not a type name, static, or enumerator [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2065: 'data_': undeclared identifier [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2338:  [spdlog\build\spdlog.vcxproj]
  cfg.cpp
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2327: 'fmt::v11::basic_specs::data_': is not a type name, static, or enumerator [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2065: 'data_': undeclared identifier [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2338:  [spdlog\build\spdlog.vcxproj]
  bundled_fmtlib_format.cpp
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2327: 'fmt::v11::basic_specs::data_': is not a type name, static, or enumerator [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2065: 'data_': undeclared identifier [spdlog\build\spdlog.vcxproj]
spdlog\include\spdlog\fmt\bundled\base.h(743): error C2338:  [spdlog\build\spdlog.vcxproj]

Details

  • spdlog v1.15.0 builds without issues
  • Latest visual studio toolchain (v1942) builds without issues
  • When removing the static_assert(...) in line 743, a new error appears when compiling example.cpp (details in comments)

System

Visual Studio 2022 (17.12.4) with extension MSVC v140 - VS 2015 C++-Buildtools (v14.00)

Steps to reproduce

  1. git checkout v1.15.1
  2. cmake -T v140 -S . -B build/ && cmake --build build/
@tt4g
Copy link
Contributor

tt4g commented Feb 6, 2025

Not recognizing data_ is obviously not right.

unsigned data_ = 1 << fill_size_shift;
static_assert(sizeof(data_) * CHAR_BIT >= 18, "");

Maybe the source code has been changed?

@csandmann
Copy link
Author

Yes, the file has changed significantly since the last release: The entire class basic_specs is new. The build works fine though with the latest toolset (v1942)

If I remove the static_assert(...), a new error appears, this time, when when building the example project.

------ Build started: Project: example, Configuration: Release x64 ------
2>example.cpp
2>spdlog\include\spdlog\fmt\bundled\base.h(2208): error C2664: 'fmt::v11::detail::value<Context>::value(fmt::v11::detail::value<Context> &&)': cannot convert argument 1 from 'spdlog::details::dump_info<std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<char>>>>' to 'const fmt::v11::detail::named_arg_info<Char> *'
2>        with
2>        [
2>            Context=fmt::v11::context
2>        ]
2>        and
2>        [
2>            Char=char
2>        ]

Note sure what the implication of this is: Maybe its a configuration issue, there is a lot of #ifdefs going on in the beginning.

@tt4g
Copy link
Contributor

tt4g commented Feb 6, 2025

Maybe the source code has been changed?

The above comment was meant to ask you to check if data_ is defined in the source code saved on your machine.
However, it is most likely a bug in MSVC since it can be built with another version toolset.

Since this source code was copied from the fmt repository, you should request that it be fixed in the fmt repository.
I recommend moving the issue to the fmt repository.

@csandmann
Copy link
Author

csandmann commented Feb 6, 2025

Thanks for the quick reaction. I was not aware that this part of the code comes from a different repository. I confirmed the latest version of fmtlib indeed comes with the same problem. I created a new issue fmtlib/fmt#4346

@csandmann
Copy link
Author

The linked upstream issue in fmtlib was closed due to this being a likely compiler issue. Do you see more than the following options to go forward?

  1. Try to fix fmtlib
  2. Downgrade fmtlib to version compatible with vc140
  3. Drop support for vc140

@tt4g
Copy link
Contributor

tt4g commented Feb 7, 2025

If it is a compiler bug, the second solution would be the only way.
If fmtlib is fixed, the third solution can be used.

@tt4g
Copy link
Contributor

tt4g commented Feb 7, 2025

For the second solution, you can define a CMake variable SPDLOG_FMT_EXTERNAL=ON and use the old version of fmt.

spdlog/CMakeLists.txt

Lines 91 to 92 in f355b3d

option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
option(SPDLOG_FMT_EXTERNAL_HO "Use external fmt header-only library instead of bundled" OFF)

@csandmann
Copy link
Author

csandmann commented Feb 7, 2025

I just confirmed this solution works. Following the discussion in the linked issue of fmtlib, the first bad commit is fmtlib/fmt@761d35f. This means that fmtlib 11.0.2 is the last working version for MSVC v140.

Build spdlog with fmtlib 11.0.2 and MSVC v140

Step 1: Build fmtlib

git checkout 11.0.2
cmake -S . -B build -T v140
cmake --build ./build --config Release
cmake --install ./build --prefix ${FMT_INSTALL_DIR}

Step 2: Build spdlog with external fmtlib

cmake -S . -B build/ -T v140 -DSPDLOG_FMT_EXTERNAL=ON -Dfmt_DIR="${FMT_INSTALL_DIR}\lib\cmake\fmt"
cmake --build build/ --config Release
cmake --install ./build --prefix ${SPDLOG_INSTALL_DIR}

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants