Closed Tectu closed 3 years ago
I've run into a similar issue. I think its related to the changes in 8.0 for fmt
which now checks format strings at compile time by default. Right now I'm solving it by turning off automatic dependency fetching for malloy
and just pulling in an old version of spdlog
. The issue is in router
with log_or_throw
iirc, because we take in the format string as a const char*
. I'm guessing its not caught in the tests or examples because its a template and we don't use any paths which instantate it. nvm, looking at the code router::add
should cause it to be instantiated... I am a little confused honestly :p
Edit: I can't repro this even explicitly calling that method in a test, but I am getting this compile error if I try and consume malloy in another project
So we're both pretty much in the same spot here: It doesn't compile but currently no understanding as of why :p
I did find this (spdlog issue report) though, so I'm currently building spdlog from source to see if its the problem.
Edit: Nope, doesn't seem to. @Tectu Does everything work if you use a version of spdlog before fmt 8, e.g. 1.8.5? Your error is a little different to mine, I get this:
[...]/lib/malloy/server/routing/router.hpp: In instantiation of ‘bool malloy::server::router::log_or_throw(const std::exception&, spdlog::level::level_enum, const FormatString&, Args&& ...) [with FormatString = char [32]; Args = {const char*}]’:
[...]/lib/malloy/server/routing/router.cpp:25:28: required from here
[...]/lib/malloy/server/routing/router.hpp:558:30: error: ‘fmt’ is not a constant expression
558 | m_logger->log(level, fmt, std::forward<Args>(args)...);
Using spdlog
version 1.8.5
I am still getting build errors (when building an application consuming malloy
).
I did set spdlog
to version 1.8.5
both in the malloy dependency as well as my application itself for this test.
In file included from C:/Users/joel/Documents/projects/elx/cmake-build-debug/_deps/spdlog-src/include/spdlog/spdlog.h:14,
from C:/Users/joel/Documents/projects/elx/cmake-build-debug/_deps/malloy-src/lib/malloy/core/websocket/connection.hpp:14,
from C:/Users/joel/Documents/projects/elx/cmake-build-debug/_deps/malloy-src/lib/malloy/server/websocket/connection.hpp:3,
from C:\Users\joel\Documents\projects\elx\cmake-build-debug\_deps\malloy-src\lib\malloy\server\http\connection.hpp:4,
from C:\Users\joel\Documents\projects\elx\cmake-build-debug\_deps\malloy-src\lib\malloy\server\http\connection_plain.hpp:3,
from C:\Users\joel\Documents\projects\elx\cmake-build-debug\_deps\malloy-src\lib\malloy\server\http\connection_detector.cpp:2:
C:/Users/joel/Documents/projects/elx/cmake-build-debug/_deps/spdlog-src/include/spdlog/logger.h: In instantiation of 'void spdlog::logger::log_(spdlog::source_loc, spdlog::level::level_enum, const FormatString&, Args&& ...) [with FormatString = fmt::v8::basic_string_view<char>; Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]':
C:/Users/joel/Documents/projects/elx/cmake-build-debug/_deps/spdlog-src/include/spdlog/logger.h:87:13: required from 'void spdlog::logger::log(spdlog::source_loc, spdlog::level::level_enum, spdlog::string_view_t, Args&& ...) [with Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; spdlog::string_view_t = fmt::v8::basic_string_view<char>]'
C:/Users/joel/Documents/projects/elx/cmake-build-debug/_deps/spdlog-src/include/spdlog/logger.h:93:12: required from 'void spdlog::logger::log(spdlog::level::level_enum, const FormatString&, Args&& ...) [with FormatString = char [36]; Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]'
C:/Users/joel/Documents/projects/elx/cmake-build-debug/_deps/spdlog-src/include/spdlog/logger.h:129:12: required from 'void spdlog::logger::critical(const FormatString&, Args&& ...) [with FormatString = char [36]; Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]'
C:\Users\joel\Documents\projects\elx\cmake-build-debug\_deps\malloy-src\lib\malloy\server\http\connection_detector.cpp:77:79: required from here
C:/Users/joel/Documents/projects/elx/cmake-build-debug/_deps/spdlog-src/include/spdlog/logger.h:340:27: error: 'fmt' is not a constant expression
340 | fmt::format_to(buf, fmt, std::forward<Args>(args)...);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hmm, this is a problem because I do need 55eb2cf0fa81fefe1a6399202749810a2833a25f since I depend on fmt
seperately for most of my projects. Its even weirder because I don't seem to have run into the same issue as you, any idea what the code is thats causing this?
Honestly no idea. As you can see from the build log it is failing when compiling the malloy
dependency of the application. This happens long before the code of my actual application is being compiled.
Currently no idea how to continue from here - do you have anything on your mind?
I've been investigating a bit but I am honestly a bit out of ideas on this one...
I guess a "quick fix" for my situation(s) would be to make external FMT optional. However, that isn't really a fix and doesn't solve other usage problems like yours.
Any ideas?
Not really, I was thinking along the same lines of optional fmt, but I don't like it because its a "quick n dirty" fix and we can't easily reproduce the issue, or even be sure what it is.
It might be worth trying to compile with the current spdlog
head, your error looks very similar to the one shown in the issue I linked earlier. log_or_throw
is still an issue for me, and I'm guessing you'll run into it if this gets fixed since its still an issue even with the head spdlog, so that's what I'm going to try to fix for now :p.
Edit:
Well, it appears that I only get that issue with log_or_throw
if I'm using an spdlog version > 1.9.0, that is, 1.9.0 works fine but 1.9.1 or 1.9.2 fails with that issue above. Bear in mind, I'm using conan, but the fmt
version pulled in by 1.9.x is 8.0.1 so I don't think this is an fmt
issue. Not sure if this should be something reported on the spdlog issue tracker?
Edit2:
Alright, so if I tell malloy to pull in spdlog 1.9.2 instead of 1.9.0, it also fails with the above error. So, I can now reproduce the log_or_throw
issue for malloy on its own.
The application itself does also rely on spdlog and pulls it in via FetchContent(). However, that shouldn't be a problem as cmake can resolve those (and used to work well so far).
@Tectu Wait... so your depending on two seperate spdlog
s? With your other spdlog
, have you set the external fmt option? From the way malloy
is pulled in there, it looks like your telling malloy to pull in its own spdlog, which will be configured to use the external fmt also pulled in by it. I'm not sure why that would cause it to be unable to find the right fmt but having multiple spdlogs floating around can't be good. Have you tried it with MALLOY_DEPENDENCY_SPDLOG_DOWNLOAD=OFF
and setting SPDLOG_FMT_EXTERNAL=ON
on the version you pull in separately?
I'm surprised it worked at all tbh, I kept getting redefinition of spdlog::spdlog
issues which is why I added the option to disable automatic spdlog fetching in the first place :p
I'm not at my best today and I don't want to provide wrong information - I'll get back to this once my brain is fresh again :p
After your fix from #86 it seems that everything works well & as intended again. Honestly I'm not sure what is/was up with the different errors we were getting. I have obviously been toying around with it while investigating the issue so it's not unlikely that I left something in a state it was not supposed to be in.
Thanks for your fix!
Since commit 55eb2cf0fa81fefe1a6399202749810a2833a25f, my applications consuming
malloy
are not building anymore:This is how I include
malloy
in that project usingFetchContent()
:The application itself does also rely on
spdlog
and pulls it in viaFetchContent()
. However, that shouldn't be a problem as cmake can resolve those (and used to work well so far).@0x00002a do you know anything about this? It seems like the
fmt
library is not accessible tospdlog
.