[llvm-bugs] [Bug 43140] New: libcxx tests fail when built with gcc (symbol visibility problem) std::__1::__vector_base_common<true>::__throw_length_error() const'

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 28 03:18:00 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43140

            Bug ID: 43140
           Summary: libcxx tests fail when built with gcc (symbol
                    visibility problem)
                    std::__1::__vector_base_common<true>::__throw_length_e
                    rror() const'
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: peter.smith at linaro.org
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

One of our libcxx buildbots
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-armv7-linux-noexceptions/builds/1102
is failing.

As a side effect of moving some buildbots around, this builder ended up
building libcxx, libcxxabi and libunwind with GCC 7.4.0. With this
configuration 437 tests fail due to link errors of the form:
more undefined references to
`std::__1::__vector_base_common<true>::__throw_length_error() const' follow

This is reproducible on x86_64 with or without -fno-exceptions and it looks
like it is related to symbol visibility differences.

The bits of code where the problem are:
File vector:

template <bool>
class __vector_base_common
{
protected:
    _LIBCPP_INLINE_VISIBILITY __vector_base_common() {}
    _LIBCPP_NORETURN void __throw_length_error() const;
    _LIBCPP_NORETURN void __throw_out_of_range() const;
};

template <bool __b>
void
__vector_base_common<__b>::__throw_length_error() const
{
    _VSTD::__throw_length_error("vector");
}

_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
__vector_base_common<true>)

File stdexcept
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
void __throw_length_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
    throw length_error(__msg);
#else
    ((void)__msg);
    _VSTD::abort();
#endif
} 

When compiled with clang:
00000000  w    F
.text._ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv   00000018
std::__1::__vector_base_common<true>::__throw_length_error() const
00000000  w    F .text._ZNSt3__120__throw_length_errorEPKc      00000010
.hidden std::__1::__throw_length_error(char const*)

When compiled with gcc:
00000000  w    F
.text._ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv   00000018
.hidden std::__1::__vector_base_common<true>::__throw_length_error() const

Note that std::__1::__vector_base_common<true>::__throw_length_error() const
has hidden visibility when compiled with GCC. This is the root cause of the
link errors.

This looks to be caused by the expansion of the macros in: 
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
__vector_base_common<true>)

With GCC this expands to:
extern template class __vector_base_common<true>;

With clang this expands to:
extern template class __attribute__ ((__visibility__("default"))) __vector_bas\
e_common<true>;

With the compilation options -fvisibility=hidden and
-fvisibility-inlines-hidden the end result is hidden visibilty when compiled
with GCC.

Depending on whether libc++ supports gcc, this is probably a bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190828/18f8cc14/attachment.html>


More information about the llvm-bugs mailing list