Different visibility warning
ld: warning: direct access in function 'fmt::v10::detail::format_error_code(fmt::v10::detail::buffer<char>&, int, fmt::v10::basic_string_view<char>)' from file '/usr/local/vcpkg/installed/x64-osx/lib/libfmt.a(format.cc.o)' to global weak symbol 'decltype(fp.begin()) fmt::v10::detail::parse_format_specs<int, fmt::v10::detail::compile_parse_context<char> >(fmt::v10::detail::compile_parse_context<char>&)' from file '/usr/local/vcpkg/installed/x64-osx/lib/libspdlog.a(spdlog.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
When linking with spdlog on macOS, it shows this warning.
And I've submit a pr in vcpkg to fix it. See https://github.com/microsoft/vcpkg/pull/35793
I just remove these lines and the warning disappeared https://github.com/fmtlib/fmt/blob/dbd9c89b3c1d4a92f15ab8296faec4507cf50ffb/CMakeLists.txt#L195-L205
But I'm not sure if it's the right fix.
Could you provide a repro that doesn't involve vcpkg?
Could you provide a repro that doesn't involve vcpkg?
@vitaut Sure, here is a minimal demo code which repro it. test_spdlog.zip
Just exec ./build.sh in test_spdlog directory under macOS and you will see this
Since we install fmt instead of addingfmt as a sub directory. FMT_MASTER_PROJECT will always be true.
Hi @vitaut, any progress on this?
I haven't looked into it. Also could you provide just the commands that use stock spdlog/fmt instead of a zip file?
Also could you provide just the commands that use stock spdlog/fmt instead of a zip file?
Only 3 file in this zip.
Unfortunately the repro doesn't work:
.../test_spdlog/vendor/spdlog/include/spdlog/fmt/fmt.h:32:14: fatal error: 'fmt/core.h' file not found
#include <fmt/core.h>
^~~~~~~~~~~~
One possible way to suppress the warning is annotating that function with FMT_VISIBILITY("default").
@vitaut
The master branch of spdlog and fmt is now incompatible.
Please try this new repro which use fmt 10.0.0
test_spdlog_v2.zip
Thanks for the updated repro. I don't see the visibility warning though, only:
ld: warning: ignoring duplicate libraries: '/Users/viz/Downloads/test_spdlog 2/install/lib/libfmt.a'
@vitaut Please check this page https://github.com/xiaozhuai/test_spdlog/actions/runs/7947550191
macos-11 and macos-12 prints
ld: warning: direct access in function 'fmt::v10::detail::format_error_code(fmt::v10::detail::buffer<char>&, int, fmt::v10::basic_string_view<char>)' from file '/Users/runner/work/test_spdlog/test_spdlog/install/lib/libfmt.a(format.cc.o)' to global weak symbol 'decltype(fp.begin()) fmt::v10::detail::parse_format_specs<int, fmt::v10::detail::compile_parse_context<char> >(fmt::v10::detail::compile_parse_context<char>&)' from file '/Users/runner/work/test_spdlog/test_spdlog/install/lib/libspdlog.a(spdlog.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
macos-13 prints
ld: warning: ignoring duplicate libraries: '/Users/runner/work/test_spdlog/test_spdlog/install/lib/libfmt.a'
Suppressed in https://github.com/fmtlib/fmt/commit/f68f452deaa15f222c7b2eee5f41c7a9bd249793. Thanks for reporting and putting together the repro.