scylladb/seastar

partial specialization of ‘struct fmt::v10::formatter<std::basic_string_view<_CharT>, Char>’ after instantiation of ‘struct fmt::v10::formatter<std::basic_string_view<char> >’ [-fpermissive]

mickey298 opened this issue · 5 comments

Seastar commit: 4aa93b6
Code from tutorial.md
env: archlinux

//1.cpp
#include <seastar/core/app-template.hh>
#include <seastar/util/log.hh>
#include <iostream>
#include <stdexcept>

extern seastar::future<> f();

int main(int argc, char** argv) {
    seastar::app_template app;
    try {
        app.run(argc, argv, f);
    } catch(...) {
        std::cerr << "Couldn't start application: "
                  << std::current_exception() << "\n";
        return 1;
    }
    return 0;
}
//2.cpp
#include <seastar/core/sleep.hh>
#include <iostream>

seastar::future<> f() {
    std::cout << "Sleeping... " << std::flush;
    using namespace std::chrono_literals;
    return seastar::sleep(1s).then([] {
        std::cout << "Done.\n";
    });
}

compile

❯ g++ -g src/1.cpp src/2.cpp `pkg-config --cflags --libs --static seastar`                                         ─╯
In file included from /usr/include/fmt/ostream.h:21,
                 from /usr/include/seastar/core/sstring.hh:40,
                 from /usr/include/seastar/core/scheduling.hh:30,
                 from /usr/include/seastar/core/task.hh:24,
                 from /usr/include/seastar/core/future.hh:36,
                 from /usr/include/seastar/core/sleep.hh:29,
                 from src/2.cpp:2:
/usr/include/fmt/format.h:4051:1: error: partial specialization of ‘struct fmt::v10::formatter<std::basic_string_view<_CharT>, Char>’ after instantiation of ‘struct fmt::v10::formatter<std::basic_string_view<char> >’ [-fpermissive]
 4051 | FMT_FORMAT_AS(detail::std_string_view<Char>, basic_string_view<Char>);
  1. It's compiled ok if merge above code into 1 file without use extern.
  2. It's compiled ok on a new ubuntu vm.

Althought the difference of gcc version of system(ubuntu is 11 and the archlinux is 13),basically i believe it's fmt version problems.
the fmt on archlinux is 10.2 and the ubuntu is 8. And It is highly suspected that more version issues will be found in the future if we use fmt 10.2 because i seen many similar issues on fmt issue pages.
BTW. the package of libudev-dev and libunistring-dev missing in install-dependencies.sh
@tchaikov

sounds like a fmt issue.

the install-dependencies.sh issue should be addressed by #1997 .

another data point, i am building seasetar tree with fmt v10.2.1 and clang 19 just fine.

$ ./configure.py --mode debug --compile-commands-json --ccache --compiler clang++ --c-compiler clang 
$ ninja -C build/debug 
ninja: Entering directory `build/debug'
...
[259/259] Linking CXX executable apps/memcached/tests/app_memcached_test_ascii

another data point, i am building seasetar tree with fmt v10.2.1 and clang 19 just fine.

$ ./configure.py --mode debug --compile-commands-json --ccache --compiler clang++ --c-compiler clang 
$ ninja -C build/debug 
ninja: Entering directory `build/debug'
...
[259/259] Linking CXX executable apps/memcached/tests/app_memcached_test_ascii

Are you means building above code fines too? @tchaikov

no, i haven't got a chance to reproduce the above test case. will do.

i managed to reproduce fmtlib/fmt#2769 when testing a github workflow change, see https://github.com/tchaikov/seastar/actions/runs/8532553474/job/23373886423 .

when it comes to your issue, i guess it should be fixed by a newer {fmt} version which includes fmtlib/fmt@bbb784f . but {fmt} v10.2 should have it already...

anyway, i will see what we can do on our side.