[llvm-bugs] [Bug 40484] New: relocation R_X86_64_PC32 against undefined hidden symbol error when building a C++ shared library that links against static boost libraries

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 26 16:59:18 PST 2019


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

            Bug ID: 40484
           Summary: relocation R_X86_64_PC32 against undefined hidden
                    symbol error when building a C++ shared library that
                    links against static boost libraries
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bgedik at unscrambl.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

We are getting a 'relocation R_X86_64_PC32 against undefined hidden symbol
error' when building a C++ shared library that links against static boost
libraries (built with -fPIC). I have a reproduction below. There a few details
that may help:

- The error only happens with clang (I tried 6 and 7) but not with gcc
- It does not matter whether boost is built with clang or gcc, so I believe the
problem is related to the compilation of the object file that is being made
into a shared library
- The problem is somewhat related to a class called 'wrapexcept' in boost, as
it is always a symbol related to this class that is causing a problem. The
symbol is a 'construction vtable', so there is multi-inheritance and templates
involved and certainly this is related to the fact that boost is built with
-fvisibility=hidden -fvisibility-inlines-hidden. 
- A potentially related earlier bug is:
https://bugs.llvm.org/show_bug.cgi?id=8713

Here is a reproduction:

I have a very simple test.cpp file:

=============
#include <boost/regex.hpp>

int test()
{
    boost::regex const regex("a");
    return 0;
}
=============

clang++-7 -fPIC -I $BOOST_PATH/include -c test.cpp

clang++-7 -fPIC -shared -o libtest.so test.o $BOOST_PATH//lib/libboost_regex.a

/usr/bin/ld: /opt/boost-1.69.0/lib/libboost_regex.a(regex.o): relocation
R_X86_64_PC32 against undefined hidden symbol
`_ZTCN5boost10wrapexceptISt13runtime_errorEE0_NS_16exception_detail10clone_implINS3_19error_info_injectorIS1_EEEE'
can not be used when making a shared object
/usr/bin/ld: final link failed: Bad value

c++filt
_ZTCN5boost10wrapexceptISt13runtime_errorEE0_NS_16exception_detail10clone_implINS3_19error_info_injectorIS1_EEEE
gives:

construction vtable for
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error>
>-in-boost::wrapexcept<std::runtime_error>

We are using Boost 1.69 with only static libaries. Here is how we built it:

./bootstrap.sh
./b2 -d+2 -a install -j 16 -prefix=$BOOST_PATH link=static cxxflags="-fPIC"
variant=release

-- 
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/20190127/48fc174d/attachment.html>


More information about the llvm-bugs mailing list