<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - relocation R_X86_64_PC32 against undefined hidden symbol error when building a C++ shared library that links against static boost libraries"
href="https://bugs.llvm.org/show_bug.cgi?id=40484">40484</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>relocation R_X86_64_PC32 against undefined hidden symbol error when building a C++ shared library that links against static boost libraries
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>bgedik@unscrambl.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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:
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - "relocation R_X86_64_PC32 against undefined symbol ...""
href="show_bug.cgi?id=8713">https://bugs.llvm.org/show_bug.cgi?id=8713</a>
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>
<span class="quote">>-in-boost::wrapexcept<std::runtime_error></span >
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>