scylladb / seastar

High performance server-side application framework
http://seastar.io
Apache License 2.0
8.14k stars 1.53k forks source link

undefined reference to `seastar::logger::failed_to_log #2181

Open robinchrist opened 2 months ago

robinchrist commented 2 months ago

When building a very simple test application

# Make sure we use a relatively recent version - 3.27 is Nov 2023
cmake_minimum_required(VERSION 3.27)

project ("Kataklysmos")

find_package (Seastar REQUIRED)

add_executable (my_app
  src/main.cpp)

target_link_libraries (my_app PUBLIC Seastar::seastar)
#include <seastar/core/app-template.hh>
#include <seastar/core/seastar.hh>
#include <seastar/util/log.hh>

using namespace seastar;
logger applog("app");

int main(int argc, char** argv) {
    seastar::app_template app;
    app.run(argc, argv, [] () -> future<> {
        applog.info("Hello world!");
        return make_ready_future<>();
    });
}

I get the following linker error:

[3/3] Linking CXX executable my_app
FAILED: my_app 
: && /usr/bin/c++ -O3 -DNDEBUG  CMakeFiles/my_app.dir/src/main.cpp.o -o my_app  /data/dev/Kataklysmos/external/seastar/build/release/libseastar.a  /usr/lib/x86_64-linux-gnu/libboost_program_options.so  /usr/lib/x86_64-linux-gnu/libboost_thread.so  /usr/lib/x86_64-linux-gnu/libboost_chrono.so  /usr/lib/x86_64-linux-gnu/libboost_date_time.so  /usr/lib/x86_64-linux-gnu/libboost_atomic.so  /usr/lib/x86_64-linux-gnu/libcares.so  /usr/lib/x86_64-linux-gnu/libfmt.so.9.1.0  /usr/lib/x86_64-linux-gnu/liblz4.so  -ldl  /usr/lib/x86_64-linux-gnu/libgnutls.so  -latomic  /usr/lib/x86_64-linux-gnu/libsctp.so  /usr/lib/x86_64-linux-gnu/libprotobuf.so  /usr/lib/x86_64-linux-gnu/libyaml-cpp.so  /usr/lib/x86_64-linux-gnu/libhwloc.so  /usr/lib/x86_64-linux-gnu/liburing.so  /usr/lib/x86_64-linux-gnu/libnuma.so && :
/usr/bin/ld: CMakeFiles/my_app.dir/src/main.cpp.o: in function `std::_Function_handler<seastar::future<void> (), main::{lambda()#1}>::_M_invoke(std::_Any_data const&) [clone .cold]':
main.cpp:(.text.unlikely+0x40): undefined reference to `seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v9::basic_string_view<char>, seastar::internal::source_location)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Seastar was configured with

sudo ./install-dependencies.sh
./configure.py --mode=release --enable-dpdk
ninja -C build/release

with the Valgrind fix from https://github.com/scylladb/seastar/issues/2180 Tested https://github.com/scylladb/seastar/commit/b74a027c819ee5b9bfcee4f32edf8f37017bba12 and https://github.com/scylladb/seastar/commit/cd8a9133d2c02f63dbd578d882cf7333a427e194

With Clang (Seastar itself build with default GCC) I get the error:


/data/dev/Kataklysmos/src/main.cpp:32:21: error: call to consteval function 'seastar::logger::format_info<>::format_info<char[13], 0>' is not a constant expression
        applog.info("Hello world!");
                    ^
/data/dev/Kataklysmos/external/seastar/include/seastar/util/log.hh:141:58: note: non-constexpr function 'current' cannot be used in a constant expression
                           compat::source_location loc = compat::source_location::current()) noexcept
                                                         ^
/data/dev/Kataklysmos/external/seastar/include/seastar/util/source_location-compat.hh:50:21: note: declared here
    source_location current(const char* file = __builtin_FILE(), const char* func = __builtin_FUNCTION(), int line = __builtin_LINE(), int col = 0) noexcept {
                    ^
1 warning and 1 error generated.
ninja: build stopped: subcommand failed.
robinchrist commented 2 months ago

Same result when cooking fmt and upgrading to 10.2.1

robin@WS-DA-7773X:/data/dev/Kataklysmos/build$ ninja
[3/3] Linking CXX executable my_app
FAILED: my_app 
: && /usr/bin/c++ -O3 -DNDEBUG  CMakeFiles/my_app.dir/src/main.cpp.o -o my_app  /data/dev/Kataklysmos/external/seastar/build/release/libseastar.a  /usr/lib/x86_64-linux-gnu/libboost_program_options.so  /usr/lib/x86_64-linux-gnu/libboost_thread.so  /usr/lib/x86_64-linux-gnu/libboost_chrono.so  /usr/lib/x86_64-linux-gnu/libboost_date_time.so  /usr/lib/x86_64-linux-gnu/libboost_atomic.so  /usr/lib/x86_64-linux-gnu/libcares.so  /data/dev/Kataklysmos/external/seastar/build/release/_cooking/installed/lib/libfmt.a  /usr/lib/x86_64-linux-gnu/liblz4.so  -ldl  /usr/lib/x86_64-linux-gnu/libgnutls.so  -latomic  /usr/lib/x86_64-linux-gnu/libsctp.so  /usr/lib/x86_64-linux-gnu/libprotobuf.so  /usr/lib/x86_64-linux-gnu/libyaml-cpp.so  /usr/lib/x86_64-linux-gnu/libhwloc.so  /usr/lib/x86_64-linux-gnu/liburing.so  /usr/lib/x86_64-linux-gnu/libnuma.so && :
/usr/bin/ld: CMakeFiles/my_app.dir/src/main.cpp.o: in function `std::_Function_handler<seastar::future<void> (), main::{lambda()#1}>::_M_invoke(std::_Any_data const&) [clone .cold]':
main.cpp:(.text.unlikely+0x40): undefined reference to `seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, seastar::internal::source_location)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
robinchrist commented 2 months ago

Seems to be somehow related to boost?

./configure.py --mode=release --cook fmt --cook Boost --cook valgrind --c++-standard=20 --enable-dpdk

Works at least (with the Valgrind fix). I haven't had the nerve to test whether removing --cook Boost will fix the issue...

tchaikov commented 2 months ago

@robinchrist hi Robin, so there are two issues here:

  1. undefined reference toseastar::logger::failed_to_log()` with GCC
  2. call to consteval function 'seastar::logger::format_info<>::format_info<char[13], 0>' is not a constant express with Clang

may i learn the version of GCC and the version of Clang which you are using? have you tried to build both you application and Seastar with Clang?

the first issue is a mysterious to me. because this symbol should be included in libseastar.a, could you paste the output of

$ nm -C build/release/libseastar.a | grep failed_to_log
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
0000000000001200 T seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
0000000000003e50 t seastar::logger::lambda_log_writer<seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)::$_0>::operator()(seastar::internal::log_buf::inserter_iterator)
0000000000003e20 t seastar::logger::lambda_log_writer<seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)::$_0>::~lambda_log_writer()
00000000000012a0 t seastar::logger::lambda_log_writer<seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)::$_0>::~lambda_log_writer()
00000000000000a0 d typeinfo for seastar::logger::lambda_log_writer<seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)::$_0>
0000000000000079 r typeinfo name for seastar::logger::lambda_log_writer<seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)::$_0>
0000000000000078 d vtable for seastar::logger::lambda_log_writer<seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)::$_0>
                 U seastar::logger::failed_to_log(std::__exception_ptr::exception_ptr, fmt::v10::basic_string_view<char>, std::source_location)
robinchrist commented 1 month ago

It seems like this was related to C++17?

I can't reproduce it anymore after updating Seastar (because of https://github.com/scylladb/seastar/issues/2180)

What is working:

What is NOT working:

Seem like Clang 16 has some issues with C++23.

tchaikov commented 1 month ago

see https://github.com/scylladb/seastar/blob/master/doc/compatibility.md#compilers . we don't support Clang 16.

robinchrist commented 1 month ago

we don't support Clang 16.

Yeah that's not a problem. The results I posted above were merely findings with the stuff that is currently on my dev machine and as a reference for others who might run into the same issue, not a "bug report" that Clang 16 is not working :smile: