Boost logo

Boost Users :

From: Marco Craveiro (marco.craveiro_at_[hidden])
Date: 2022-09-29 08:05:20


Hi Boost Users,

First, a great thanks to the authors of the boost serialisation
library, which I have used successfully across projects and has proven
invaluable. Now to my problem. I have been investigating for a little
while a strange warning I get when linking on OSX; the results of my
investigation can be found here [1].

The TL; DR of it is as follows: my OSX debug build has a warning
(indented for ease of reading):

    ld: warning: direct access in function

    'boost::archive::basic_text_oprimitive<
        std::__1::basic_ostream<char, std::__1::char_traits<char> >
>::~basic_text_oprimitive()'

    from file

    'vcpkg_installed/x64-osx/debug/lib/libboost_serialization.a(basic_text_oprimitive.o)'

    to global weak symbol

    'std::__1::basic_ostream<char, std::__1::char_traits<char> >&
    std::__1::endl<char, std::__1::char_traits<char> >
   (std::__1::basic_ostream<char, std::__1::char_traits<char> >&)'

This warning is caused by a mismatch in visibility settings between my
project and vcpkg's build of boost. However, as far as I can see, both
projects are using "-fvisibility=default", meaning there should be no
mismatch. Also, no other warnings show up but if I change the project
settings I then get hundreds of warnings (again, for details see
ticket).

What I find even more puzzling is that I am using all three types of
archives (Text, XML and Binary). Of these three, only Text produces
this warning. As the problem is with the destructors, I did a quick
inventory of the destructors to see how they differ:

    basic_xml_oarchive.hpp: [2]
    BOOST_ARCHIVE_OR_WARCHIVE_DECL
    ~basic_xml_oarchive() BOOST_OVERRIDE;

    basic_text_oarchive.hpp: [3]
    ~basic_text_oarchive() BOOST_OVERRIDE {}

    basic_binary_oarchive.hpp: [4] no destructor.

So my question is, should text archive also have a
BOOST_ARCHIVE_OR_WARCHIVE_DECL macro, and would that fix my warning?
If so I can submit a PR.

Many thanks for your time.

Marco

[1] https://github.com/Microsoft/vcpkg/issues/4497
[2] https://github.com/boostorg/serialization/blob/develop/include/boost/archive/basic_xml_oarchive.hpp
[3] https://github.com/boostorg/serialization/blob/develop/include/boost/archive/basic_text_oarchive.hpp
[4] https://github.com/boostorg/serialization/blob/develop/include/boost/archive/basic_binary_oarchive.hpp

-- 
Marco Craveiro
MD, Domain Driven Consulting
blog: https://mcraveiro.github.io/index.html
twitter: https://twitter.com/MarcoCraveiro
That the Ideas are themselves manifestations (of the Idea-Idea) and
that the Idea-Idea is a-kind-of Manifestation-Idea—which is a-kind-of
itself, so that the system is completely self-describing— would have
been appreciated by Plato as an extremely practical joke [Plato]. --
Alan Key

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net