Last active
December 3, 2019 16:49
-
-
Save rcombs/e550349aa2e9d149eeb90e007cdaaa5e to your computer and use it in GitHub Desktop.
Linker visibility issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clang++ -std=gnu++14 -stdlib=libc++ -Wno-deprecated-declarations -c test.cpp -o test.o -fvisibility=hidden | |
/usr/local/opt/llvm/bin/ld64.lld -dynamic -undefined dynamic_lookup -o test test.o | |
# Or: | |
# ld -dynamic -undefined dynamic_lookup -o test test.o -lSystem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ objdump -t test.o | grep 4soci7details11type_holder | c++filt | |
0000000000005090 gw F __TEXT,__text tm soci::details::type_holder<tm>::value<tm>() const | |
0000000000004500 gw F __TEXT,__text std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > soci::details::type_holder<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::value<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >() const | |
0000000000000a40 gw F __TEXT,__text int soci::details::type_holder<int>::value<int>() const | |
0000000000005ac0 gw O __DATA,__const typeinfo for soci::details::type_holder<tm> | |
0000000000005a90 gw O __DATA,__const typeinfo for soci::details::type_holder<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > | |
00000000000058d8 gw O __DATA,__const typeinfo for soci::details::type_holder<int> | |
0000000000005886 gw O __TEXT,__const typeinfo name for soci::details::type_holder<tm> | |
00000000000057cc gw O __TEXT,__const typeinfo name for soci::details::type_holder<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > | |
00000000000056f4 gw O __TEXT,__const typeinfo name for soci::details::type_holder<int> | |
$ objdump -t test | grep 4soci7details11type_holder | c++filt | |
00000001000063ff lw O __TEXT,__const typeinfo name for soci::details::type_holder<tm> | |
00000001000071f8 lw O __DATA,__const typeinfo for soci::details::type_holder<tm> | |
0000000100005ce0 lw F __TEXT,__text tm soci::details::type_holder<tm>::value<tm>() const | |
0000000100005150 gw F __TEXT,__text std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > soci::details::type_holder<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::value<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >() const | |
0000000100001690 gw F __TEXT,__text int soci::details::type_holder<int>::value<int>() const | |
00000001000071c8 gw O __DATA,__const typeinfo for soci::details::type_holder<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > | |
0000000100007010 gw O __DATA,__const typeinfo for soci::details::type_holder<int> | |
0000000100006345 gw O __TEXT,__const typeinfo name for soci::details::type_holder<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > | |
000000010000626d gw O __TEXT,__const typeinfo name for soci::details::type_holder<int> | |
^ How did the symbols for the struct tm specialization (and only those) end up marked as local in the output file? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ctime> | |
#include <string> | |
#pragma GCC visibility push(default) | |
#include <soci/soci.h> | |
#pragma GCC visibility pop | |
using namespace std; | |
using namespace soci; | |
struct test_class | |
{ | |
int test_int; | |
string test_string; | |
tm test_tm; | |
}; | |
namespace soci { | |
template<> struct type_conversion<test_class> | |
{ | |
typedef values base_type; | |
static void from_base(values const &v, indicator ind, test_class &i); | |
}; | |
} | |
namespace soci { | |
void type_conversion<test_class>::from_base(values const &v, indicator ind, test_class &i) | |
{ | |
struct tm NullTm = {0}; | |
i.test_int = v.get<int>("test_int", -1); | |
i.test_string = v.get<string>("test_string", ""); | |
i.test_tm = v.get<tm>("test_tm", NullTm); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment