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

spdlog/fmt/bundled/core.h:472:150: error: 'constexpr ... when compiling a .cu file with nvcc #2893

Closed
EajksEajks opened this issue Oct 7, 2023 · 14 comments

Comments

@EajksEajks
Copy link

EajksEajks commented Oct 7, 2023

Hi,

compilation platform ubuntu 22.04 + intel oneapi 2023.2 + nvidia cuda 12.2
spdlog v1.10.0...v1.12.0 used in its header version.
spdlog as submodule in a bigger C++ + CUDA project.

Pure C++ files using spdlog compiled successfully with gcc or icx from Intel.
CU files using spdlog compiled with cuda 12.2 failed on a constexpr in fmt.

All files are compiled using C++20.

I'm looking for a workaround but have found none till now.

@EajksEajks
Copy link
Author

Strange enough same code compiles on win11 + intel oneapi 2023.2 + cuda 12.2...

@tt4g
Copy link
Contributor

tt4g commented Oct 7, 2023

spdlog/fmt/bundled/core.h fmt library source. Please open issue in fmt project.

@prospero-x
Copy link

Same issue building with v1.12.0 on SUSE linux with gcc v11.2.0. I get the error in:

  351 |     return spdlog::string_view_t{buf.data(), buf.size()};

It can compile successfully when I revert to spdlog v1.11.0.

@tt4g
Copy link
Contributor

tt4g commented Oct 8, 2023

@prospero-x No error message so I don't know anything, but probably a duplicate #2693 (already fixed #2694).

@EajksEajks
Copy link
Author

Sorry I forgot the error code

...
128.0 /src/code/sdk/dependencies/spdlog/include/spdlog/fmt/bundled/core.h:348:14: error: call to non-'constexpr' function 'void fmt::v9::detail::ignore_unused(const T& ...) [with T = {bool}]'
128.0   348 |   ignore_unused(default_value);
128.0       |   ~~~~~~~~~~~^~~~~~~~~~~~~~~
...
128.0 /src/code/sdk/dependencies/spdlog/include/spdlog/fmt/bundled/format.h:1099:29: error: call to non-'constexpr' function 'int fmt::v9::detail::count_digits_fallback(T) [with T = long unsigned int]'
128.0  1099 |   return count_digits_fallback(n);
128.0       |        ~~~~~~~~~~~~~~~~~~~~~^~~
...

I can open an issue in the fmt project but could you tell me which fmt version is bundled with spdlog, please?

@tt4g
Copy link
Contributor

tt4g commented Oct 9, 2023

fmt version is 9.1.0 in spdlog 1.12.0.
And this problem is already fixed in fmt 10.1.0 or above.

fmt issue: fmtlib/fmt#3543
fmt PR: fmtlib/fmt#3544

@EajksEajks
Copy link
Author

Do you plan to move from fmt 9.1.0 to 1.12.0 in the near future?

@tt4g
Copy link
Contributor

tt4g commented Oct 9, 2023

I don't now.
But you can use external fmt by CMake variable SPDLOG_FMT_EXTERNAL.

spdlog/CMakeLists.txt

Lines 91 to 92 in 91807c2

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)

@EajksEajks
Copy link
Author

It's something I've tried but it doesn't work yet and I don't know why. I'm using spdlog 1.12.0 as a submodule of a bigger project. I tried both combinations (SPDLOG_FMT_EXTERNAL=ON and spdlog::spdlog) and (SPDLOG_FMT_EXTERNAL_HO=ON and spdlog::spdlog_header_only) but it still uses the bundled fmt. I'm still trying tot figure out why.

@tt4g
Copy link
Contributor

tt4g commented Oct 9, 2023

There are many reports of using spdlog version 1.12.0 and external fmt, so it is a configuration problem with your CMake project.

@EajksEajks
Copy link
Author

Maybe... but whatever I do to change the SPDLOG_FMT_EXTERNAL or SPDLOG_FMT_EXTERNAL_HO variable, cmake still picks the bundled fmt. Even changing the default option value in your code doesn't change this behavior.

@tt4g
Copy link
Contributor

tt4g commented Oct 9, 2023

@EajksEajks Did you know that CMake variables are cached?
If you change an optional variable, it will not be updated unless you delete the cache.
If you do not understand the cache, please delete the CMake build directory and build again.

@EajksEajks
Copy link
Author

I know they are cached. The whole project is rebuilt within a docker container every time ; the docker cache is disabled so we rebuild from the base image and redo all build steps.

@tt4g
Copy link
Contributor

tt4g commented Oct 9, 2023

Docker also has a build cache, so the build cache must be disabled.
Make sure that SPDLOG_FMT_EXTERNAL is true before building spdlog.

In any case, that is a CMake issue and any further questions should be made on StackOverflow or the CMake project.

@gabime gabime closed this as completed Oct 15, 2023
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

4 participants