https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92855

            Bug ID: 92855
           Summary: -fvisibility-inlines-hidden failing to hide
                    out-of-line copies of certain inline member functions
           Product: gcc
           Version: 9.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org
  Target Milestone: ---

Related to bug 47877 and bug 45065, but apparently different. Issue probably
goes back a long time.

We're compiling with -fvisibility=hidden -fvisibility-inlines-hidden and expect
that any inline functions used by libstdc++ to perform its job are hidden and
not exported from our library. Unfortunately, GCC is failing to hide some of
those functions and they can be seen with eu-readelf -s in the library output,
where they appear as "WEAK  DEFAULT".

This is currently not expected to be a big problem, since these functions *are*
inline and therefore expected to be emitted in any user code that needed to use
them. They just cause our symbol table to be bigger than it needs to be.

Testcase:
#include <future>

class QThreadCreateThread
{
public:
    explicit QThreadCreateThread(std::future<void> &&future)
        : m_future(std::move(future))
    {
    }

private:
    virtual void run()
    {
        m_future.get();
    }

    std::future<void> m_future;
};

// QThread *QThread::createThreadImpl(std::future<void> &&future)
QThreadCreateThread *createThreadImpl(std::future<void> &&future)
{
    return new QThreadCreateThread(std::move(future));
}

Compile with -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fno-inline to
force no inlining. In the assembly output, there are plenty of inline functions
with .hidden and plenty without. For example, see
std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release():

        .section       
.text.std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release(),"axG",@progbits,std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release(),comdat
        .align 2
        .p2align 4
        .weak   std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release()
        .type  
std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release(), @function
std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release():
[...]

No .hidden present.

Reply via email to